Open GoogleCodeExporter opened 8 years ago
I'm not sure I understand your problem, but this is how cvWaitKey(n) works:
If n = 0, it'll wait until the user presses a key, and return the key code of
that key.
If n > 0, it'll wait for either a key is pressed or approximately n miliseconds
has
elapsed. In the former case, it returns the key code. In the latter case, it
returns -1.
Hope that helps.
Minh-Tri
Original comment by pmtri80@gmail.com
on 1 Apr 2010 at 10:27
Perhaps, you might want to write your code like the following?
recording = False
while 1:
frame = cvQueryFrame(capture)
cvShowImage('Camera', frame)
if recording:
cvWriteFrame(writer, frame)
c = cvWaitKey(1) & 255
if c==114:
recording = !recording
print "Started recording..." if recording else "Stopped recording..."
elif c==115:
break
Cheers,
Minh-Tri
Original comment by pmtri80@gmail.com
on 1 Apr 2010 at 10:35
Thank you Minh-Tri.
The question in other words would be: Is there another way to control the
recording besides the cvWaitKey?
Is there no work around? Because, in the end it means, my finger pressing on
the keyboard is the logic controlling
the recording procedure.
Has no one tried to write a code controlled recording?
Meaning, starting and stopping the recording from a command within the code,
not the keyboard.
The example below woulc be a function, to record for 5 seconds, but it doesn't
work flawlessly
the recording takes place, but there is no image being displayed while
recording.
def recFiveSeconds():
timeStart = time.clock()
timeElapsed = 0
while timeElapsed <= 5:
frame = cvQueryFrame(capture)
cvShowImage('Camera', frame)
cvWriteFrame(writer, frame)
timeElapsed = time.clock() - timeStart
Original comment by raphael....@zhdk.ch
on 2 Apr 2010 at 8:27
Oh, I see.
Nope, there's no other way. OpenCV uses polling to refresh the windows. Thus,
you
have to have a cvWaitKey() call in your main loop. I usually just invoke
"cvWaitKey(1)". It's probably a technical issue that you need to check with the
Willow Garage people.
Cheers,
Minh-Tri
Original comment by pmtri80@gmail.com
on 2 Apr 2010 at 8:43
Original issue reported on code.google.com by
raphael....@zhdk.ch
on 31 Mar 2010 at 11:56