Exemplo n.º 1
0
LRESULT CAv::OnPropertyChanged(WPARAM wParam, LPARAM lParam)
{
    updateProperty(getCameraModel()->getAv());
    return 0;
}
Exemplo n.º 2
0
LRESULT CEvfAFMode::OnPropertyDescChanged(WPARAM wParam, LPARAM lParam)
{
	updatePropertyDesc(&getCameraModel()->getEvfAFModeDesc());
	return 0;
}
Exemplo n.º 3
0
//=============================================================================
// querySteroeCamera()
//
// Given that the camera handle is a stereo camera, query the camera for 
// stereo specific information about this camera and populate the 
// PGRStereoCamera_t handle structure
//
dc1394error_t
queryStereoCamera( dc1394camera_t* 	camera,
		   PGRStereoCamera_t* 	stereoCamera )
{

   // set the camera handle
   stereoCamera->camera = camera;

   // find out what base model camera we have
   stereoCamera->model = getCameraModel( camera );
   if ( stereoCamera->model == UNKNOWN_CAMERA )
      return DC1394_FAILURE;


   dc1394error_t err;
   
   if ( stereoCamera->model != BUMBLEBEE )
   {
      err = getSensorInfo( camera,
			   &stereoCamera->bColor,
			   &stereoCamera->nRows,
			   &stereoCamera->nCols );
      if ( err != DC1394_SUCCESS )
      {
	 fprintf( stderr, "Could not query the Sensor Info Register!\n" );
	 return err;
      }
   }
   else // model == BUMBLEBEE
   {
      // This is a Bumblebee "1".  This camera does not support the
      // sensor board info register so we need to determine if it is color
      // and the resolution the hard way
      //	
      // It will be nice when we don't need to support BB1 anymore as it is
      // not completely DC-compliant

      dc1394video_modes_t 	video_modes;
      err = dc1394_video_get_supported_modes( camera, &video_modes );
      if ( err != DC1394_SUCCESS ) 
      {
	 fprintf( stderr, "Can't get video modes\n" );
	 return err;
      }

      // find the highest res mode that is greyscale (MONO16)
      printf( "Searching for the highest resolution MONO16 mode available...\n" );
      dc1394video_mode_t 	video_mode;
      dc1394color_coding_t 	coding;
      for ( int i = video_modes.num-1; i >= 0; i-- ) 
      {
	 // don't consider FORMAT 7 modes (i.e. "scalable")
	 if ( !dc1394_is_video_mode_scalable( video_modes.modes[i] ) ) 
	 {
	    dc1394_get_color_coding_from_video_mode( camera, video_modes.modes[i], &coding );
	    if ( coding == DC1394_COLOR_CODING_MONO16 ) 
	    {
	       video_mode = video_modes.modes[i];
	       break;
	    }
	 }
      }
      if ( video_mode == DC1394_VIDEO_MODE_640x480_MONO16 )
      {
	 stereoCamera->nRows = 480;
	 stereoCamera->nCols = 640;
      }
      else if ( video_mode == DC1394_VIDEO_MODE_1024x768_MONO16 )
      {
	 stereoCamera->nRows = 768;
	 stereoCamera->nCols = 1024;
      }
      else
      {
	 fprintf( stderr, "Cannot find valid MONO16 video mode!\n" );
	 return DC1394_FAILURE;
      }


      dc1394color_filter_t bayerPattern;
      err = getBayerTile( stereoCamera->camera, &bayerPattern );
      if ( err != DC1394_SUCCESS ) 
      {
	 fprintf( stderr, "Failed to read the Bayer Tile Pattern register\n" );
	 return err;
      }
      // at this point all we need to know is "is it color or mono?"
      if ( bayerPattern == 0 )
	 stereoCamera->bColor = false;
      else
	 stereoCamera->bColor = true;
      
   }
   
   // a hack to figure out how many bytes per pixel are needed.
   // if the camera is a BB3, then it is 3, otherwise 2
   if ( stereoCamera->nRows == 960 )
   {
      //stereoCamera->nBytesPerPixel	= 3;
      // note: for performance reasons we have changed the default behavior
      // of the XB3 for these examples to only use the 2 wide-baseline pair.
      // This makes for faster image transmission.
      // If you change the code to transmit all 3 images, this value will 
      // have to revert to 3.
      stereoCamera->nBytesPerPixel	= 2;
   }
   else
   {
      stereoCamera->nBytesPerPixel	= 2;
   }
   
   return DC1394_SUCCESS;
}
Exemplo n.º 4
0
LRESULT CMeteringMode::OnPropertyChanged(WPARAM wParam, LPARAM lParam)
{
	updateProperty(getCameraModel()->getMeteringMode());
	return 0;
}
Exemplo n.º 5
0
int  main()
{
	int width;
	char* bayer[] = {"RG","BG","GR","GB"};
	char* controls[MAX_CONTROL] = {"Exposure", "Gain", "Gamma", "WB_R", "WB_B", "Brightness", "USB Traffic"};

	int height;
	int i;
	char c;
	bool bresult;

	int time1,time2;
	int count=0;

	char buf[128]={0};

	int CamNum=0;
	
	///long exposure, exp_min, exp_max, exp_step, exp_flag, exp_default;
	//long gain, gain_min, gain_max,gain_step, gain_flag, gain_default;

	IplImage *pRgb;


	int numDevices = getNumberOfConnectedCameras();
	if(numDevices <= 0)
	{
		printf("no camera connected, press any key to exit\n");
		getchar();
		return -1;
	}
	else
		printf("attached cameras:\n");

	for(i = 0; i < numDevices; i++)
		printf("%d %s\n",i, getCameraModel(i));

	printf("\nselect one to privew\n");
	scanf("%d", &CamNum);


	bresult = openCamera(CamNum);
	if(!bresult)
	{
		printf("OpenCamera error,are you root?,press any key to exit\n");
		getchar();
		return -1;
	}

	printf("%s information\n",getCameraModel(CamNum));
	int iMaxWidth, iMaxHeight;
	iMaxWidth = getMaxWidth();
	iMaxHeight =  getMaxHeight();
	printf("resolution:%dX%d\n", iMaxWidth, iMaxHeight);
	if(isColorCam())
		printf("Color Camera: bayer pattern:%s\n",bayer[getColorBayer()]);
	else
		printf("Mono camera\n");
	
	for( i = 0; i < MAX_CONTROL; i++)
	{
			if(isAvailable((Control_TYPE)i))
				printf("%s support:Yes\n", controls[i]);
			else
				printf("%s support:No\n", controls[i]);
	}

	printf("\nPlease input the <width height bin image_type> with one space, ie. 640 480 2 0. use max resolution if input is 0. Press ESC when video window is focused to quit capture\n");
	int bin = 1, Image_type;
	scanf("%d %d %d %d", &width, &height, &bin, &Image_type);
	if(width == 0 || height == 0)
	{
		width = iMaxWidth;
		height = iMaxHeight;
	}

	initCamera(); //this must be called before camera operation. and it only need init once
	printf("sensor temperature:%02f\n", getSensorTemp());

//	IMG_TYPE image_type;
	
	while(!setImageFormat(width, height, bin, (IMG_TYPE)Image_type))//IMG_RAW8
	{
		printf("Set format error, please check the width and height\n ASI120's data size(width*height) must be integer multiple of 1024\n");
		printf("Please input the width and height again£¬ie. 640 480\n");
		scanf("%d %d %d %d", &width, &height, &bin, &Image_type);
	}
	printf("\nset image format %d %d %d %d success, start privew, press ESC to stop \n", width, height, bin, Image_type);

	
	if(Image_type == IMG_RAW16)
		pRgb=cvCreateImage(cvSize(getWidth(),getHeight()), IPL_DEPTH_16U, 1);
	else if(Image_type == IMG_RGB24)
		pRgb=cvCreateImage(cvSize(getWidth(),getHeight()), IPL_DEPTH_8U, 3);
	else
		pRgb=cvCreateImage(cvSize(getWidth(),getHeight()), IPL_DEPTH_8U, 1);

	setValue(CONTROL_EXPOSURE, 100*1000, false); //ms//auto
	setValue(CONTROL_GAIN,getMin(CONTROL_GAIN), false); 
	setValue(CONTROL_BANDWIDTHOVERLOAD, getMin(CONTROL_BANDWIDTHOVERLOAD), false); //low transfer speed

	setValue(CONTROL_WB_B, 90, false);
 	setValue(CONTROL_WB_R, 48, false);
  	setAutoPara(getMax(CONTROL_GAIN)/2,10,150); //max auto gain and exposure and target brightness
//	EnableDarkSubtract("dark.bmp"); //dark subtract will be disabled when exposure set auto and exposure below 500ms
	startCapture(); //start privew


	

	bDisplay = 1;
#ifdef _LIN
	pthread_t thread_display;
	pthread_create(&thread_display, NULL, Display, (void*)pRgb);
#elif defined _WINDOWS
	HANDLE thread_setgainexp;
	thread_setgainexp = (HANDLE)_beginthread(Display,  NULL, (void*)pRgb);
#endif

	time1 = GetTickCount();
	int iStrLen = 0, iTextX = 40, iTextY = 60;
	void* retval;
//	int time0, iWaitMs = -1;
//	bool bGetImg;
	while(bMain)
	{

//		time0 = GetTickCount();
		getImageData((unsigned char*)pRgb->imageData, pRgb->imageSize, 200);

//		bGetImg = getImageData((unsigned char*)pRgb->imageData, pRgb->imageSize, iWaitMs);
		time2 = GetTickCount();
//		printf("waitMs%d, deltaMs%d, %d\n", iWaitMs, time2 - time0, bGetImg);
		count++;
		
		if(time2-time1 > 1000 )
		{
			sprintf(buf, "fps:%d dropped frames:%lu ImageType:%d",count, getDroppedFrames(), (int)getImgType());

			count = 0;
			time1=GetTickCount();	
			printf(buf);
			printf("\n");

		}
		if(Image_type != IMG_RGB24 && Image_type != IMG_RAW16)
		{
			iStrLen = strlen(buf);
			CvRect rect = cvRect(iTextX, iTextY - 15, iStrLen* 11, 20);
			cvSetImageROI(pRgb , rect);
			cvSet(pRgb, CV_RGB(180, 180, 180)); 
			cvResetImageROI(pRgb);
		}
		cvText(pRgb, buf, iTextX,iTextY );

		if(bChangeFormat)
		{
			bChangeFormat = 0;
			bDisplay = false;
			pthread_join(thread_display, &retval);
			cvReleaseImage(&pRgb);
			stopCapture();
			
			switch(change)
			{
				 case change_imagetype:
					Image_type++;
					if(Image_type > 3)
						Image_type = 0;
					
					break;
				case change_bin:
					if(bin == 1)
					{
						bin = 2;
						width/=2;
						height/=2;
					}
					else 
					{
						bin = 1;
						width*=2;
						height*=2;
					}
					break;
				case change_size_smaller:
					if(width > 320 && height > 240)
					{
						width/= 2;
						height/= 2;
					}
					break;
				
				case change_size_bigger:
				
					if(width*2*bin <= iMaxWidth && height*2*bin <= iMaxHeight)
					{
						width*= 2;
						height*= 2;
					}
					break;
			}
			setImageFormat(width, height, bin, (IMG_TYPE)Image_type);
			if(Image_type == IMG_RAW16)
				pRgb=cvCreateImage(cvSize(getWidth(),getHeight()), IPL_DEPTH_16U, 1);
			else if(Image_type == IMG_RGB24)
				pRgb=cvCreateImage(cvSize(getWidth(),getHeight()), IPL_DEPTH_8U, 3);
			else
				pRgb=cvCreateImage(cvSize(getWidth(),getHeight()), IPL_DEPTH_8U, 1);
			bDisplay = 1;
			pthread_create(&thread_display, NULL, Display, (void*)pRgb);
			startCapture(); //start privew
		}
	}
END:
	
	if(bDisplay)
	{
		bDisplay = 0;
#ifdef _LIN
   		pthread_join(thread_display, &retval);
#elif defined _WINDOWS
		Sleep(50);
#endif
	}
	
	stopCapture();
	closeCamera();
	cvReleaseImage(&pRgb);
	printf("main function over\n");
	return 1;
}
Exemplo n.º 6
0
LRESULT CImageQuality::OnPropertyDescChanged(WPARAM wParam, LPARAM lParam)
{
	updatePropertyDesc(&getCameraModel()->getImageQualityDesc());
	return 0;
}
Exemplo n.º 7
0
LRESULT CExposureComp::OnPropertyDescChanged(WPARAM wParam, LPARAM lParam)
{
	updatePropertyDesc(&getCameraModel()->getExposureCompensationDesc());
	return 0;
}