Ejemplo n.º 1
0
// snap and save a frame from the camera
void CameraSnap()
{
    if(!PvCaptureQueueFrame(GCamera.Handle,&(GCamera.Frame),NULL))
    {
        printf("waiting for a frame ...\n");

        while(PvCaptureWaitForFrameDone(GCamera.Handle,&(GCamera.Frame),1500) == ePvErrTimeout)
            printf("still waiting ...\n");

        if(GCamera.Frame.Status == ePvErrSuccess)
        {
            sprintf(GCamera.Filename,"./snap%04lu.tiff",++GCamera.Counter);

            if(!ImageWriteTiff(GCamera.Filename,&(GCamera.Frame)))
                printf("Failed to save the grabbed frame!");
            else
                printf("frame saved\n");
        }
        else
        if(GCamera.Frame.Status != ePvErrCancelled)
            printf("the frame failed to be captured ... %u\n",GCamera.Frame.Status);
    }
    else
        printf("failed to enqueue the frame\n");
}
Ejemplo n.º 2
0
// trigger and save a frame from the camera
// return value: true == success, false == fail
bool CameraSnap()
{
    tPvErr errCode = ePvErrSuccess;

    //wait for frame to return from camera to host
    printf("Waiting for SyncIn1 trigger input");
	while(!GCamera.Abort && ((errCode = PvCaptureWaitForFrameDone(GCamera.Handle,&(GCamera.Frame),800)) == ePvErrTimeout))
        printf(".");
	printf("\n");

	if(errCode != ePvErrSuccess  || GCamera.Abort)
    { 
		//likely camera unplugged
		GCamera.Abort = true;
		return false;
	}
	
	//check returned Frame.Status
	if(GCamera.Frame.Status == ePvErrSuccess)
    {
		sprintf_s(GCamera.Filename,sizeof(GCamera.Filename),"./snap%04lu.tiff",++GCamera.Counter);
		//save image
		if(!ImageWriteTiff(GCamera.Filename,&(GCamera.Frame)))
		{
			printf("ImageWriteTiff fail.\n");
			GCamera.Abort = true;
			return false;
		}
		printf("snap%04lu.tiff saved.\n", GCamera.Counter);
	}
    else
	{
		if (GCamera.Frame.Status == ePvErrDataMissing)
			printf("Dropped packets. Possible improper network card settings:\nSee GigE Installation Guide.");
		else
			printf("Frame.Status error: %u\n",GCamera.Frame.Status);
	}

	//requeue frame	
	if((errCode = PvCaptureQueueFrame(GCamera.Handle,&(GCamera.Frame),NULL)) != ePvErrSuccess)
	{
        printf("PvCaptureQueueFrame err: %u\n", errCode);
		GCamera.Abort = true;
		return false;
	}
	return true;
}
Ejemplo n.º 3
0
// snap and save a frame from the camera
void CameraSnap(tCamera* Camera)
{
    if(!PvCaptureQueueFrame(Camera->Handle,&(Camera->Frame),NULL))
    {
        printf("waiting for the frame to be done ...\n");
        while(PvCaptureWaitForFrameDone(Camera->Handle,&(Camera->Frame),100) == ePvErrTimeout)
            printf("still waiting ...\n");
        if(Camera->Frame.Status == ePvErrSuccess)
        {
            if(!ImageWriteTiff("./snap.tiff",&(Camera->Frame)))
                printf("Failed to save the grabbed frame!");
            else
                printf("frame saved\n");
        }
        else
            printf("the frame failed to be captured ...\n");
    }
    else
        printf("failed to enqueue the frame\n");
}