diff --git a/CMakeLists.txt b/CMakeLists.txt index db7dd95..0e81784 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,6 @@ esrocos_init() esrocos_export_function("camera_capture" "tutorial/cam_capture") #uncomment to export PKG-CONFIG-file -esrocos_export_pkg-config_info( VERSION 1.0 - REQUIRES opencv - ) +esrocos_export_pkgconfig( VERSION 1.0 + REQUIRES opencv + ) diff --git a/camera_capture/camera_capture.cc b/camera_capture/camera_capture.cc index 39a9937..4327591 100644 --- a/camera_capture/camera_capture.cc +++ b/camera_capture/camera_capture.cc @@ -14,19 +14,24 @@ void camera_capture_startup() void camera_capture_PI_capture() { VideoCapture cap(0); // open the default camera - if(!cap.isOpened()) // check if we succeeded - - namedWindow("raw",1); - namedWindow("edges",2); - - Mat frame; - Mat edges; - cap >> frame; // get a new frame from camera - cvtColor(frame, edges, COLOR_BGR2GRAY); - GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5); - Canny(edges, edges, 0, 30, 3); - imshow("raw", frame); - imshow("edges", edges); - if(waitKey(100) >= 0); + if(cap.isOpened()) // check if we succeeded + { + namedWindow("raw",1); + namedWindow("edges",2); + + Mat frame; + Mat edges; + cap >> frame; // get a new frame from camera + + if(frame.size().width > 0 && frame.size().height > 0) + { + cvtColor(frame, edges, COLOR_BGR2GRAY); + GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5); + Canny(edges, edges, 0, 30, 3); + imshow("raw", frame); + imshow("edges", edges); + if(waitKey(100) >= 0); + } + } }