Click here to Skip to main content
15,881,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written a program that detects my face and tracks my face in the webcam frame. Now, say i am watching a video and my face detection program is running in the background, so when no face is detected the program should pause the VLC media player and play it only when it detects my face. Since, the faces that is detected is stored in a vector, i have tried to write an if statement like
if(faces.size()==0) {keybd_event(VK_SPACE,0,0,0); but the problem is it keeps pressing the space bar continously and i want it to press it just once and then exit the loop. Also, it should automatically press the space bar when it detects my face by pressing the space bar once. How can i do this? I am really confused.
Posted
Comments
[no name] 22-Sep-14 16:37pm    
http://msdn.microsoft.com/en-us/library/37zc9d2w.aspx
Rebecca1995 22-Sep-14 16:49pm    
@wes aday:- Thanks for your reply.I tried using break but it dint work. Can you correct me where i am wrong?
while(faces.size()<2)
{
if(faces.size()==1)
{
keybd_event(VK_SPACE,0,0,0);
break;
}

}

1 solution

Just set a flag telling you that the video is paused (or not)

So use something like

C#
if (!videoIsPaused && !faceRecognised)
{
  PauseVideo();
  videoIsPaused = true;
}
if (videoIsPaused && faceRecognised)
{
  UnPauseVideo();
  videoIsPaused = false;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900