isFrameNew() always reporting true.

I’m still new to OF and learning.

I’m working on a openCV project which I had recently gotten to perform at decent CPU/FPS level after implementing the isFrameNew().

After making some changes, I noticed that the CPU/FPS went back up to how it was running previously to using the isFrameNew().

I did a printf and noticed that the isFrameNew() is printing “1” (true) only. Is there any obvious reason this would happen? My camera is running at 30fps and OF at 120fps. I would assume, isFrameNew() should report “0” (false) 60 times per second. Is this correct?

  
  
  
bNewFrame = false;  
		  
#ifdef _USE_LIVE_VIDEO  
           
vidGrabber.grabFrame();  
	     
bNewFrame = vidGrabber.isFrameNew();  
  
printf("Boolean: %i \n",   
bNewFrame); //Reports '1' only  
  
#else  
        vidPlayer.idleMovie();  
        bNewFrame = vidPlayer.isFrameNew();  
  
        printf("Boolean: %i \n",   
        bNewFrame); //Reports '1's and '0's correctly  
#endif  

If I switch to using the vidPlayer, vidPlayer.isFrameNew() reports back 0s and 1s correctly. Is the live video having problems or am I doing something wrong/misunderstanding.

what platform / compiler are you on?

thanks
zach

Hi zach.

I’m on windows XP, using VS 2008.

I have one camera built into my laptop and another one plugged in. Both are having the same issue. I also tried a third camera, and it also reports back the same thing.

I’ve noticed that the openCV Example (both VS and codeblocks) also is having the same issue for me. When using live video, the isFrameNew() is reporting ‘true’ always (for all 3 cameras tested), while the videoPlayer is reporting true/false correctly. It’s hard to know if I was having this problem before or not since I never printed the output of isFraneNew() prior to having high CPU/low FPS in my application.

I was looking at the Directshow code in the VideoGrabber.cpp and I noticed that I couldn’t find where it would ever say isFrameNew is false (bIsFrameNew = false;).

The other capture devices (linux and mac) all seemed to have a “bIsFrameNew = false;” statement somewhere, but the Directshow one does not (that I can find).

After making the following change, everything seems to work now. My c++ is very minimal, so if this is handled somewhere else, let me know. Maybe I’m doing something wrong. If not and this is a fix, feel free to move this to the bug fix section. =)

  
  
	//---------------------------------  
	#ifdef OF_VIDEO_CAPTURE_DIRECTSHOW  
	//---------------------------------  
  
		if (bGrabberInited == true){  
  
				bIsFrameNew = false; //I added this line to set to false  
  
			if (VI.isFrameNew(device)){  
  
				bIsFrameNew = true;  
  

nice catch! – it looks like a bug in videoGrabber, I’ll post a patched version to the svn later today and it will get into the 0.06 release. Thanks for posting that and digging through.

many thanks!
zach

No problem zach, I’m glad I could help in some way. =)