[Solved] Simple application crash without errors

asked 2014-10-11 12:28:41 -0500

Snow4Life gravatar image

updated 2014-10-13 07:56:56 -0500

The application is this:

#include "opencv2/opencv.hpp"

using namespace cv;

int main(int, char**)
{
    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
        return -1;
Mat edges;
namedWindow("edges",1);
for(;;)
{
    Mat frame;
    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("edges", edges);
    if(waitKey(30) >= 0) break;
}

cap.release();  
return 0;

}

This used to run with OpenCV3, but recently I upgraded and rebuilded (as static library because of other reasons, but the same was prior upgrading) and now when I run the executable it hang without any error. (the only difference is that now I have installed Qt5, but also reverting to Qt4 lead to the same result) If I run it with GDB i get this:

(gdb) run

Starting program: /root/programs/pc_camera/build/pc_camera

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".

[Inferior 1 (process 7290) exited with code 0377]

Which for me is not really helpful.

Does someone know at least how to get a hint on what is failing?

edit retag flag offensive close merge delete

Comments

2

cap >> frame; // get a new frame from camera


sometimes, cameras need a 'warmup' time, and deliver empty frames.

throw in a :

if ( frame.empty() ) continue;

also, please run a 'debug' build. lots of serious assertions get skipped in release.

berak gravatar imageberak ( 2014-10-11 13:05:50 -0500 )edit