Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenCV program freezes after several seconds of execution
    primarykey
    data
    text
    <p>I am running a program in C++ with OpenCV that reads a camera image and then does some stuff. The camera operates at 15 FPS if I just let it run as fast as it can. I am trying to use a camera to regulate the FPS to a number of my choosing, like 10 FPS. I am using a timer to do this (a timespec object and a clock_gettime() function call). The clock running by itself works fine, and the camera will run fine by itself, but when I try to grab a frame every 100 ms on my own, the program will run for roughly 3 seconds, and then freeze completely. This is the while loop in my code:</p> <pre><code>/* Start the timer */ clock_gettime(CLOCK_REALTIME, &amp;ts); startBit = ts.tv_nsec; /* Show the image captured from the camera in the window and repeat */ while (1) { // main while loop clock_gettime(CLOCK_REALTIME, &amp;ts); endBit = ts.tv_nsec; if (endBit-startBit &gt;= 100000000) { // &gt; 100 ms fprintf(stderr, "%lu\n", endBit-startBit); clock_gettime(CLOCK_REALTIME, &amp;ts); startBit = ts.tv_nsec; // reset timer IplImage* frame = cvQueryFrame(capture); // Get one frame Mat limage(frame); // convert IplImage to Mat if (!frame) { fprintf(stderr, "ERROR: frame is null...\n"); getchar(); break; } cvWaitKey(90); } } </code></pre> <p>The program will print to the console the time that has passed. The way it is set up now it should print something close to 100 ms (100000000 ns) all the time. But the console gives a weird number once per second: 18446744072800674356. As I mentioned before, commenting out the camera image code, the timer works fine on its own (it still prints out that huge number, but it will run forever). And if I comment out the timer code, the camera will run at 15 FPS with no problems. However, when I run the code together, it freezes after about 3 seconds. Any help is appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload