vss
vss

Reputation: 607

openCV : Detect object without displaying the webcam view window

I am using Haar cascade classifiers to detect eyes from the webcam. I don't want to display what the webcam is capturing. This is part of a project for eye movement analysis. I want to know where on screen the user is looking. if I display the window showing their face, they inevitably tend to look only at that part of the screen where this window is.

I tried removing the statement

cv2.imshow('frame', frame)

But the next statement

if cv2.waitKey(1) & 0xFF == ord('q'):
  break

seems to be causing a problem. So I replaced it with

cv2.waitKey(delay=5000)
  break

But it does not wait for the specified delay time and goes on to executing the next statements, which I do not want.

What am I doing wrong and how do I fix it? I am using python 2.7.9 and openCV 2.4.9

Upvotes: 2

Views: 1138

Answers (1)

sietschie
sietschie

Reputation: 7553

The documentation states about the waitKey command:

Note: The function only works if there is at least one HighGUI window created and the window is active. If there are several HighGUI windows, any of them can be active.

So you can either open a window that does show something other than the current image of the webcam or use another sleep command to wait for a specified time.

Upvotes: 1

Related Questions