From df778c03af0570102e79d78ec336a81fd6ea3de5 Mon Sep 17 00:00:00 2001 From: ArMourMag <55202166+ArMourMag@users.noreply.github.com> Date: Wed, 13 Nov 2019 15:35:13 +0100 Subject: [PATCH 1/2] Fix export pkgconfig function in CMake file. --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 + ) From b37cfd36c93bbabbeeb7375ee26632b2ae4ee80e Mon Sep 17 00:00:00 2001 From: ArMourMag <55202166+ArMourMag@users.noreply.github.com> Date: Thu, 21 Nov 2019 10:53:10 +0100 Subject: [PATCH 2/2] Fix if error and check size of image. --- camera_capture/camera_capture.cc | 33 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) 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); + } + } }