source code
#include < iostream> #include "opencv2\objdetect\objdetect.hpp" #include "opencv2\highgui\highgui.hpp" #include "opencv2\imgproc\imgproc.hpp" #include "opencv2\cudaobjdetect.hpp" #include "opencv2\cudaimgproc.hpp" #include "opencv2\cudawarping.hpp" #ifdef _DEBUG #pragma comment(lib, "opencv_core300d.lib") #pragma comment(lib, "opencv_highgui300d.lib") #pragma comment(lib, "opencv_imgcodecs300d.lib") #pragma comment(lib, "opencv_objdetect300d.lib") #pragma comment(lib, "opencv_imgproc300d.lib") #pragma comment(lib, "opencv_videoio300d.lib") #pragma comment(lib, "opencv_cudaobjdetect300d.lib") #pragma comment(lib, "opencv_cudawarping300d.lib") #pragma comment(lib, "opencv_cudaimgproc300d.lib") #else #pragma comment(lib, "opencv_core300.lib") #pragma comment(lib, "opencv_highgui300.lib") #pragma comment(lib, "opencv_imgcodecs300.lib") #pragma comment(lib, "opencv_objdetect300.lib") #pragma comment(lib, "opencv_imgproc300.lib") #pragma comment(lib, "opencv_videoio300.lib") #pragma comment(lib, "opencv_cudaobjdetect300.lib") #pragma comment(lib, "opencv_cudawarping300.lib") #pragma comment(lib, "opencv_cudaimgproc300.lib") #endif using namespace std; using namespace cv; void main() { cv::Ptr< cv::cuda::HOG> d_hog = cv::cuda::HOG::create(Size(48, 96)); //Size(64, 128));// d_hog->setSVMDetector(d_hog->getDefaultPeopleDetector()); //video loading Mat img; VideoCapture cap("M:\\____videoSample____\\tracking\\TownCentreXVID.avi"); //loading test cap >> img; if (img.empty()) return; //window namedWindow("pedestrian", 0); //processing time check unsigned long AAtime = 0, BBtime = 0; //resize double scale = float(800) / img.cols; cuda::GpuMat GpuImg, rGpuImg; GpuImg.upload(img); cuda::resize(GpuImg, rGpuImg, Size(GpuImg.cols * scale, GpuImg.rows * scale)); Mat rInimg; rGpuImg.download(rInimg); while (1) { //time check AAtime = getTickCount(); //loading cap >> img; if (img.empty()) break; //resize GpuImg.upload(img); cuda::resize(GpuImg, rGpuImg, Size(GpuImg.cols * scale, GpuImg.rows * scale)); rGpuImg.download(rInimg); cuda::cvtColor(rGpuImg, rGpuImg, CV_BGR2GRAY); vector< Point> found_locations; d_hog->detect(rGpuImg, found_locations); std::vector< cv::Rect> found_locations_rect; d_hog->detectMultiScale(rGpuImg, found_locations_rect); for (int i = 0; i < found_locations_rect.size(); ++i) { cv::rectangle(rInimg, found_locations_rect[i], CvScalar(0, 0, 255), 1); } imshow("pedestrian", rInimg); waitKey(10); //time check BBtime = getTickCount(); double s_time = (BBtime - AAtime) / getTickFrequency(); double fps_time = 1/s_time; printf("%.2lf sec / %.2lf fps \n", s_time, fps_time); } }
μλ νμΈμ λΈλ‘κ·Έ νμ μ λ³΄κ³ μμ΅λλ€.
ReplyDeleteobject tracking κ΄λ ¨νμ¬ κ³΅λΆνκ³ μλ νμμ λλ€.
μ΄ μ½λλ₯Ό νλ² ν μ€νΈν΄λ³΄κ³ μΆμ΄μ CUDA λ₯Ό κΉκ³ opencvλ μ°λμ νμλλ°
GpuImg, rGpuImg λ±μμ λΉ¨κ°μ€μ΄ λ¨κ³ μλμ κ°μ μ€λ₯κ° λ¨λλ°
no suitable user-defined conversion from "cv::cuda::GpuMat" to "const cv::_InputArray" exists
CUDA μ΄μΈμλ λ μ€μ ν΄μ£Όμ΄μΌ ν κ²μ΄ μλμ? λ΅λ³ λΆνλ립λλ€ T.T
cuda κ΄λ ¨ λ¬Έμ λ‘ λ³΄μ΄λ€μ..
DeleteλΉ νμΌμμ cuda::Gpumat μ μΈ, upload, resize, download μ κ°μ κΈ°λ³Έμ μΈ μ½λλ‘ ν μ€νΈλ₯Ό ν΄λ³΄μΈμ.
λ€ κ°μ¬ν©λλ€ μ’μν루λμΈμ :)
Delete