Пример #1
0
IplImage* CvCaptureCAM_CMU::retrieveFrame()
{
    C1394Camera* cmucam = camera();
    if( !cmucam )
        return 0;
    cmucam->getRGB((uchar*)image->imageData, image->imageSize);
    cvConvertImage( image, image, CV_CVTIMG_SWAP_RB );
    return image;
}
Пример #2
0
DWORD Sync1394Camera::CamThread ()
{
	int fcount= 0;

	//init ARtaglocalizer***********************************************
	IplImage *undist_src = cvCreateImageHeader(cvSize(config.width,config.height),8,3);
	IplImage *gray = cvCreateImage(cvSize(config.width,config.height),8,1);	
	//******************************************************************
	printf("Cam %d Thread Started\n\n", camId);
	while (allCamInit == false)
	{
		Sleep(100);
	}

	while(isRunning) 
	{	
		C1394Camera* camptr = &camera;
		fcount++;
		unsigned long dlength=0;			
		int dFrames=0;

		if (CAM_SUCCESS != camptr->AcquireImageEx(TRUE,&dFrames))
		{
			if (fcount %100==0)
				printf("COULD NOT AQUIRE AN IMAGE FROM THE CAMERA %d.\n", camId);			
		}
		if (dFrames>0 && fcount>1) printf ("DROPPED %d FRAMES! %d\n",dFrames, camId);

		EnterCriticalSection(&camgrab_cs);		
		if (USE_SYSTIME)	curtimestamp = (float)(clock() - start_tick)/(float)CLOCKS_PER_SEC;

		if (config.isColor)
		{
			camptr->getRGB(buf,config.height * config.width * 3); dlength=1;
		}
		else
		{
			camptr = &camera;
			buf = camptr->GetRawData (&dlength);
		}
		
		if (0 == dlength) 
		{			
			LeaveCriticalSection(&camgrab_cs);
			continue;
		}

		if ((fcount %100==0) && (!config.AGC))
		{
			printf(".");
		}

		undist_src->imageData = (char*) buf;
		undist_src->imageDataOrigin = undist_src->imageData;

		cvCvtColor( undist_src, gray, CV_BGR2GRAY );
		if(!allStop)
		{
			artagLoc->getARtagPose(gray, undist_src, camId);
		}

		LeaveCriticalSection(&camgrab_cs);
		SetEvent (cameraEvent);	

	}

	cvReleaseImage(&gray);
	printf("\nCam %d Thread Ended\n", camId);
	return 0;
}