Я делаю некоторую сегментацию Meanshift с использованием OpenCV и Cuda в cpp скрипте на Windows. Я установил все каталоги и зависимости, и в Visual Studio все работает нормально, но теперь я хочу создать какой-нибудь exe-файл из cmd, который будет запускать эту программу с Cuda. Я пробовал со строкой ниже, но я получаю ошибку:
nvcc -IC:\Cuda\opencv-master\build\install\include -LC:\Cuda\opencv-master\build\install\x64\vc15\lib meanShift.cpp
tmpxft_0000420c_00000000-8_mario_meanShift.obj : error LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree@cv@@YAXPEAX@Z) referenced in function "public: __cdecl cv::Mat::~Mat(void)" (??1Mat@cv@@QEAA@XZ)
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::Mat::deallocate(void)" (?deallocate@Mat@cv@@QEAAXXZ) referenced in function "public: void __cdecl cv::Mat::release(void)" (?release@Mat@cv@@QEAAXXZ)
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "__int64 __cdecl cv::getTickCount(void)" (?getTickCount@cv@@YA_JXZ) referenced in function "void __cdecl ProccTimePrint(unsigned long,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?ProccTimePrint@@YAXKV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "double __cdecl cv::getTickFrequency(void)" (?getTickFrequency@cv@@YANXZ) referenced in function "void __cdecl ProccTimePrint(unsigned long,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?ProccTimePrint@@YAXKV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread@cv@@YA?AVMat@1@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function main
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "bool __cdecl cv::imwrite(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &,class std::vector<int,class std::allocator<int> > const &)" (?imwrite@cv@@YA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV_InputArray@1@AEBV?$vector@HV?$allocator@H@std@@@3@@Z) referenced in function main
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?namedWindow@cv@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function main
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z) referenced in function main
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV_InputArray@1@@Z) referenced in function main
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "public: static class cv::cuda::GpuMat::Allocator * __cdecl cv::cuda::GpuMat::defaultAllocator(void)" (?defaultAllocator@GpuMat@cuda@cv@@SAPEAVAllocator@123@XZ) referenced in function main
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::cuda::GpuMat::release(void)" (?release@GpuMat@cuda@cv@@QEAAXXZ) referenced in function "public: __cdecl cv::cuda::GpuMat::~GpuMat(void)" (??1GpuMat@cuda@cv@@QEAA@XZ)
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::cuda::GpuMat::upload(class cv::_InputArray const &)" (?upload@GpuMat@cuda@cv@@QEAAXAEBV_InputArray@3@@Z) referenced in function main
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "public: static class cv::cuda::Stream & __cdecl cv::cuda::Stream::Null(void)" (?Null@Stream@cuda@cv@@SAAEAV123@XZ) referenced in function main
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cuda::cvtColor(class cv::_InputArray const &,class cv::_OutputArray const &,int,int,class cv::cuda::Stream &)" (?cvtColor@cuda@cv@@YAXAEBV_InputArray@2@AEBV_OutputArray@2@HHAEAVStream@12@@Z) referenced in function main
tmpxft_0000420c_00000000-8_meanShift.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cuda::meanShiftSegmentation(class cv::_InputArray const &,class cv::_OutputArray const &,int,int,int,class cv::TermCriteria,class cv::cuda::Stream &)" (?meanShiftSegmentation@cuda@cv@@YAXAEBV_InputArray@2@AEBV_OutputArray@2@HHHVTermCriteria@2@AEAVStream@12@@Z) referenced in function main
a.exe : fatal error LNK1120: 15 unresolved externalsidentifier":
Как включить все зависимости и каталоги в cmd для создания этого проекта? Какой компилятор использовать и какой синтаксис мне нужно использовать для создания этого исполняемого файла?
#include <time.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core/cuda.hpp>
#include <opencv2/core.hpp>
#include <opencv2/core/cuda_types.hpp>
#include <string>
#include <stdio.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/cudaimgproc.hpp>
using namespace cv;
using namespace std;
void ProccTimePrint(unsigned long Atime, string msg)
{
unsigned long Btime = 0;
float sec, fps;
Btime = getTickCount();
sec = (Btime - Atime) / getTickFrequency();
fps = 1 / sec;
printf("%s %.4lf(sec) / %.4lf(fps) \n", msg.c_str(), sec, fps);
}
int main()
{
unsigned long AAtime = 0;
Mat img, gray, out_canny;
img = imread("C:/path_to_some_image/test1.png", IMREAD_COLOR);
{
Mat out, image2, out_1, image;
cuda::GpuMat pimgGpu, pimgGpu2, imgGpu, imgGpu2, outImgGpu, dst;
AAtime = getTickCount();
pimgGpu.upload(img);
cuda::cvtColor(pimgGpu, imgGpu, COLOR_BGR2BGRA);
TermCriteria iteracija = TermCriteria(TermCriteria::MAX_ITER, 2, 0);
cuda::meanShiftSegmentation(imgGpu, out, 50, 50, 15000, iteration);
cout << "Speed GPU Meanshift: ";
ProccTimePrint(AAtime, "gpu");
namedWindow("Display frame", WINDOW_AUTOSIZE);
imshow("Display frame", out);
imwrite("C:/some_path/out_image.png", out);
waitKey(0);
return 0;
}
}
```