I am trying to use opencl in opencv 3.1.0 , I copy some of the code in tutorials. However, my computer always shows " Display Driver Stopped Responding " message and crash.
and there are my code:
VideoCapture cap(0); // open the default camera
UMat edges;
UMat fgMaskMOG2;
Ptr<BackgroundSubtractor> pMOG2;
pMOG2 = createBackgroundSubtractorMOG2(500, 20.0, false);
for (;;)
{
UMat frame;
UMat frame2 = frame.clone();
cap >> frame; // get a new frame from camera
cvtColor(frame, edges, COLOR_BGR2GRAY);
GaussianBlur(edges, edges, cv::Size(7, 7), 1.5, 1.5);
// Canny(edges, edges, 0, 30, 3); // The program always crashes here and shows " Display Driver Stopped Responding "
pMOG2->apply(frame, fgMaskMOG2);
imshow("edges", edges);
imshow("edges2", frame);
imshow("FG Mask MOG 2", fgMaskMOG2);
if (waitKey(30) >= 0) break;
}
I think in opencv3.1.0, If I want to use gpu, all I need to do is change "Mat" into "UMat", the code work fine if there is no Canny , How should I do to use Canny if I want to use opencl in opencv? Thanks for your help and sorry for my poor English.