Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Replace it with e.g.</p> <pre><code>while(1) </code></pre> <p>or</p> <pre><code>for(;;) </code></pre> <p>or you can do (defining <code>c</code> before the loop):</p> <pre><code>while (c != 27) { //grab each frame sequentially IplImage* frame = cvQueryFrame( capture ); if (!frame) break; //show the retrieved frame in the window cvShowImage("BLINK", frame); //wait for 20 ms c = cvWaitKey(20); //exit the loop if user press "Esc" key } </code></pre> <p>or without <code>c</code> at all, but this will <em>start</em> the loop with a 20ms wait:</p> <pre><code>while (cvWaitKey(20) != 27) { //grab each frame sequentially IplImage* frame = cvQueryFrame( capture ); if (!frame) break; //show the retrieved frame in the window cvShowImage("BLINK", frame); } </code></pre> <p>And a third possibility:</p> <pre><code>for(;;) { //grab each frame sequentially IplImage* frame = cvQueryFrame( capture ); if (!frame) break; //show the retrieved frame in the window cvShowImage("BLINK", frame); if (cvWaitKey(20) == 27) break; } </code></pre> <p><em>UPDATE</em>: while wondering whether it would be more correct to define</p> <pre><code>#define true 1 #define false 0 </code></pre> <p>or</p> <pre><code>#define true 1 #define false (!true) </code></pre> <p>or again</p> <pre><code>#define false 0 #define true (!false) </code></pre> <p>because if I, say, did:</p> <pre><code>int a = 5; if (a == true) { // This is false. a is 5 and not 1. So a is not true } if (a == false){ // This too is false. So a is not false } </code></pre> <p>I would come up with a really weird result, I found <a href="http://markshroyer.com/2012/06/c-both-true-and-false/" rel="nofollow">this link</a> to a slightly weirder result.</p> <p>I suspect that to solve this in a safe way would require some macro such as</p> <pre><code>#define IS_FALSE(a) (0 == (a)) #define IS_TRUE(a) (!IS_FALSE(a)) </code></pre>
 

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