I try to read a camera frame and show it through cv::namedWindow
using cv::cuda::GpuMat
.
Here is my C++ code:
cv::namedWindow("frame", cv::WINDOW_OPENGL);
cv::resizeWindow("frame", FRAME_WIDTH, FRAME_HEIGHT);
while (true) {
cv::Mat frame;
cv::cuda::GpuMat frame_gpu;
camera.read(frame);
frame_gpu.upload(frame);
cv::imshow("frame", frame_gpu);
//frame_gpu.download(frame);
if (cv::waitKey(1) == 27) {
break;
}
}
cv::destroyAllWindows();
If I close the window I got this error:
OpenCV Error: The function/feature is not implemented (You should explicitly call download method for cuda::GpuMat object) in getMat_, file /home/nvidia/opencv-3.2.0/modules/core/src/matrix.cpp, line 1276
terminate called after throwing an instance of 'cv::Exception'
what(): /home/nvidia/opencv-3.2.0/modules/core/src/matrix.cpp:1276: error: (-213) You should explicitly call download method for cuda::GpuMat object in function getMat_
Aborted (core dumped)
If I type Esc
key to end the logic, it does not raise any exception.
Why do I get this error and how can I solve this?