Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

OpenCL in OpenCV 3.0.0

$
0
0
I'm attempting to use OpenCV 3.0.0 (yes, I know it's a development version) to work with OpenCL. I'm using the UMat structure instead of the ocl::oclMat structure found in earlier versions. As expected, those matrices *are* getting created on the GPU side. However, when I attempt to run GaussianBlur for example on those matrices, things slow down to a crawl. Earlier, this would have been solved by using ocl::GaussianBlur, but that does not exist anymore. How is one supposed to achieve this in OpenCV 3.0? **EDIT** Now that I have ostensibly enabled using OpenCL for dealing with UMats, things are still slowing down to a crawl. Here is the code that I am currently using to test this out: #include "opencv2/opencv.hpp" #include "opencv2/core/ocl.hpp" #include using namespace cv; using namespace std; int main(int argc, char** argv) { ocl::setUseOpenCL(true); Mat gpuFrame; UMat gpuBW; UMat gpuBlur; UMat gpuEdges; VideoCapture cap(0); // open the default camera if(!cap.isOpened()) // check if we succeeded return -1; namedWindow("edges",1); for(;;) { cap >> gpuFrame; // get a new frame from camera cvtColor(gpuFrame, gpuBW, COLOR_BGR2GRAY); GaussianBlur(gpuBW, gpuBlur, Size(1,1), 1.5, 1.5); Canny(gpuBlur, gpuEdges, 0, 30, 3); imshow("edges", gpuEdges); if(waitKey(30) >= 0) break; } // the camera will be deinitialized automatically in VideoCapture destructor return 0; } **EDIT 2** Changing the gpuFrame to be a regular matrix seems to have solved the issue. Thank you! :) **Edit 3** I seem to have spoken too soon --- changing gpuFrame to a regular Mat object fixed everything because everything then became CPU computations! Why is it that I cannot do multiple computations using OpenCL and not have the GPU freeze up? In my dmesg, it says the following whenever I run my program: [670017.262677] [drm] Enabling RC6 states: RC6 on, RC6p off, RC6pp off [670025.273070] [drm] stuck on render ring [670025.273999] [drm] GPU HANG: ecode 0:0x8fd8ffff, in VideoCapture [26945], reason: Ring hung, action: reset [670027.274692] [drm] Enabling RC6 states: RC6 on, RC6p off, RC6pp off [670031.265908] [drm] stuck on render ring [670031.266856] [drm] GPU HANG: ecode 0:0x8fd8ffff, in VideoCapture [26945], reason: Ring hung, action: reset [670031.266984] [drm:i915_context_is_banned] *ERROR* gpu hanging too fast, banning! [670033.267655] [drm] Enabling RC6 states: RC6 on, RC6p off, RC6pp off This seems to suggest that my loop is going too quickly. But the GPU should be quicker at computations (especially matrix computations) than a CPU, right? So what's going on? Thank you very much! Sincerely, Chaanakya

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>