Camera captures one frame only
Posted: 10 April 2010 12:53 AM   [ Ignore ]
New Member
Rank
Total Posts:  7
Joined  2010-02-21

Hi. I decided to use Playstation3 Eye camera in my app (optical tracker). I put all the code in place, but managed to get one frame only . After this CLEyeCameraGetFrame returns false all the times :( . I am running under Win32 XP SP3. I have written a separate test app that exposed same problem. here is the listing of the app. Could someone test it and see if it runs. Ideally someone would say “You need to do this and that” smile
I can run compiled examples that come with the SDK and they run ok as fas as I can tell.
Here is the test code:

#include "stdafx.h"
#include <crtdbg.h>

#ifdef DEBUG
#define VERIFY ASSERT
#else
#define VERIFY
#endif // DEBUG

void TestCam()
{
    GUID cameraGUID 
CLEyeGetCameraUUID(0);

    
CLEyeCameraInstance hCamera CLEyeCreateCamera(cameraGUIDCLEYE_COLOR_RAWCLEYE_VGA60);

    
ASSERT(hCamera);

    
// Get camera frame dimensions
    
int w,h;
    
VERIFYCLEyeCameraGetFrameDimensions(hCameraw) );

    
PBYTE pCapBuffer = new BYTE[w*h*4];

    
// Set some camera parameters
    
VERIFYCLEyeSetCameraParameter(hCameraCLEYE_GAIN0) );
    
VERIFYCLEyeSetCameraParameter(hCameraCLEYE_EXPOSURE511) );

    
// Start capturing
    
VERIFYCLEyeCameraStart(hCamera) );


    
// image capturing loop
    
while(GetAsyncKeyState(VK_ESCAPE) >= )
    
{
        
// Capture camera images
        
if( !CLEyeCameraGetFrame(hCamerapCapBuffer2000) )
        
{
            
continue;
        
}
        
::OutputDebugStr("Frame!\n");
    
}

    VERIFY
CLEyeCameraStop(hCamera) );
    
// Destroy camera object
    
VERIFYCLEyeDestroyCamera(hCamera) );
    
hCamera NULL;

    
// Destroy the allocated image
    
delete pCapBuffer;
    
pCapBuffer NULL;


Edit: As a matter of fact the code above does work when firstly started. Strangely if I put a breakpoint at the line
::OutputDebugStr(“Frame!\n”);
and let the debugger wait for couple of seconds the image stream ends and no no more images are received.

Profile
 
 
Posted: 11 April 2010 08:14 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  585
Joined  2009-09-17

On the first glance, your code looks ok. Could you try initializing the camera to something like 15fps and running it again?

Profile
 
 
Posted: 11 April 2010 11:50 AM   [ Ignore ]   [ # 2 ]
New Member
Rank
Total Posts:  7
Joined  2010-02-21

It actually works, but debugging is tricky, as setting a break point in the capture loop makes the driver to stop image capturing (internally). Please see the comment on the bottom of my prev post. I would guess it is a buffer overflow or some sort of timeout that occur in the SDK/driver.

Regards,
Pavel

Profile
 
 
Posted: 11 April 2010 06:23 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  585
Joined  2009-09-17

Of course you would lose the data if you stop the execution of your program inside the capture loop. Remember that you are not dealing with software only, but also with the hardware that does not know nothing about you debugging your program. Why would you stop inside the capture loop anyway? You already have the OutputDebugStr function call in there to tell you what’s going on.

Profile
 
 
Posted: 11 April 2010 09:43 PM   [ Ignore ]   [ # 4 ]
New Member
Rank
Total Posts:  7
Joined  2010-02-21

Losing frames is logical in that case, of course. What bothers me is that when I continue running the program from that point onward I receive no more images. I need to stop and start the capturing again to make it work - which kind of screws the whole debug session.

Regards,
Pavel

Profile
 
 
Posted: 21 April 2010 01:32 PM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  585
Joined  2009-09-17

The problem is that when you stop the application for debugging, all of the threads get suspended including some of the time critical ones used by the framework. Therefore, if camera frame data is lost for too long, it will not be able to continue frame capture process.

Profile
 
 
Posted: 22 April 2010 12:06 AM   [ Ignore ]   [ # 6 ]
New Member
Rank
Total Posts:  7
Joined  2010-02-21

I see, thanks.

Profile
 
 
 
 


RSS 2.0     Atom Feed