unsigned long AAtime = 0, BBtime = 0; cuda::GpuMat gpuImg, gpuImg_out; Mat img, img_out, img_out2; img = imread("2mb.jpg"); gpuImg.upload(img); AAtime = getTickCount(); cuda::bitwise_not(gpuImg, gpuImg_out); Ptr< cv::cuda::filter > filter = cuda::createSobelFilter(img.type(), img.type(), 1, 0); filter->apply(gpuImg_out, gpuImg_out); BBtime = getTickCount(); gpuImg_out.download(img_out); printf("gpu : %.2lf second \n", (BBtime - AAtime) / getTickFrequency()); AAtime = getTickCount(); bitwise_not(img, img_out2); Sobel(img_out2, img_out2, img_out2.depth(), 1, 0); BBtime = getTickCount(); printf("cpu : %.2lf second \n", (BBtime - AAtime) / getTickFrequency()); imshow("cpu_img", img_out); imshow("cpu_img", img_out2); waitKey(0);
Showing posts with label GpuMat. Show all posts
Showing posts with label GpuMat. Show all posts
12/16/2016
Gpu Mat, Cpu Mat example 2
Gpu Mat, Cpu Mat example code 1
...
#include "opencv2/opencv.hpp" #include "opencv2/highgui.hpp" #include "opencv2/cudaarithm.hpp" #include <iostream> #ifdef _DEBUG #pragma comment(lib, "opencv_core331d.lib") #pragma comment(lib, "opencv_highgui331d.lib") #pragma comment(lib, "opencv_imgcodecs331d.lib") #pragma comment(lib, "opencv_objdetect331d.lib") #pragma comment(lib, "opencv_imgproc331d.lib") #pragma comment(lib, "opencv_videoio331d.lib") #pragma comment(lib, "opencv_cudaarithm331d.lib") #else #pragma comment(lib, "opencv_core331.lib") #pragma comment(lib, "opencv_highgui331.lib") #pragma comment(lib, "opencv_imgcodecs331.lib") #pragma comment(lib, "opencv_objdetect331.lib") #pragma comment(lib, "opencv_imgproc331.lib") #pragma comment(lib, "opencv_videoio331.lib") #pragma comment(lib, "opencv_cudaarithm331d.lib") #endif using namespace std; using namespace cv; int main() { cuda::GpuMat gpuImg; Mat img = imread("ss.jpg"); gpuImg.upload(img); //upload vector< cuda::GpuMat> rgbGpuMat(3); cuda::split(gpuImg, rgbGpuMat); //cuda processing Mat r, g, b; rgbGpuMat[0].download(b); //download rgbGpuMat[1].download(g); rgbGpuMat[2].download(r); 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 waitKey(0); return 0; }...
Subscribe to:
Posts (Atom)
-
Logistic Classifier The logistic classifier is similar to equation of the plane. W is weight vector, X is input vector and y is output...
-
I use MOG2 algorithm to background subtraction. The process is resize to small for more fast processing to blur for avoid noise affectio...
-
This is data acquisition source code of LMS511(SICK co.) Source code is made by MFC(vs 2008). The sensor is communicated by TCP/IP. ...
-
Background subtractor example souce code. OpenCV support about 3 types subtraction algorithm. Those are MOG, MOG2, GMG algorithms. Det...
-
Image size of origin is 320*240. Processing time is 30.96 second took. The result of stitching The resul...
-
Created Date : 2009.10. Language : C++ Tool : Visual Studio C++ 2008 Library & Utilized : Point Grey-FlyCapture, Triclops, OpenCV...
-
As you can see in the following video, I created a class that stitching n cameras in real time. https://www.youtube.com/user/feelmare/sear...
-
The MNIST dataset is a dataset of handwritten digits, comprising 60 000 training examples and 10 000 test examples. The dataset can be downl...
-
This post is about how to copy Mat data to vector and copy vector data to Mat. Reference this example source code. printf ( "/////...
-
This example source code is to extract HOG feature from images. And save descriptors to XML file. The source code explain how to use HOGD...