Gpu Mat, Cpu Mat example code 1

cuda::GpuMat gpuImg;
 Mat img = imread("ss.jpg");

 unsigned long AAtime = 0, BBtime = 0;
 AAtime = getTickCount();
 gpuImg.upload(img); //upload
 vector< cuda::GpuMat > rgbGpuMat(3);
 cuda::split(gpuImg, rgbGpuMat); //cuda processing

 Mat r, g, b;
 rgbGpuMat[0].download(b); //download
 BBtime = getTickCount();
 printf("gpu : %.2lf second \n", (BBtime - AAtime) / getTickFrequency());

 vector< mat > rgbMat(3);
 split(img, rgbMat); //cuda processing
 //Mat r, g, b;
 b = rgbMat[0]; //download
 g = rgbMat[1];
 r = rgbMat[2];
 BBtime = getTickCount();
 printf("cpu : %.2lf second \n", (BBtime - AAtime) / getTickFrequency());

 namedWindow("r", 0); //make window
 imshow("r", r); //show
 namedWindow("g", 0); //make window
 imshow("g", g); //show
 namedWindow("b", 0); //make window
 imshow("b", b); //show


Popular posts from this blog

(OpenCV Study) Background subtractor MOG, MOG2, GMG example source code (BackgroundSubtractorMOG, BackgroundSubtractorMOG2, BackgroundSubtractorGMG)

OpenCV Stitching example (Stitcher class, Panorama)

AMP dose run on my pc?, AMP(Accelerated Massive Parallelism)

Example source code of extract HOG feature from images, save descriptor values to xml file, using opencv (using HOGDescriptor )

Optical Flow sample source code using OpenCV

Real-time N camera stitching Class.

OpenCV meanShiftFiltering example source code ( cpu: pyrMeanShiftFiltering, gpu:meanShiftFiltering, gpu:meanShiftSegmentation )

8 point algorithm (Matlab source code) / The method to get the Fundamental Matrix and the Essential matrix

Video Stabilization example source code, (using cvFindHomography, cvWarpPerspective functions in openCV)

Image warping (using opencv findHomography, warpPerspective)