View Single Post
  #10   Spotlight this post!  
Unread 31-01-2012, 16:17
mathgeek01 mathgeek01 is offline
C++ Ninja in Training
FRC #3397 (Robolions)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: St. Louis, MO
Posts: 9
mathgeek01 is an unknown quantity at this point
Re: How to capture image from Axis 206 and save to cRIO?

I am having a similar problem to the OP. I'm using the below code, a modified version of what bob.wolff68 suggested. Running this function once at the beginning of teleop, I get the image size error on the DS LCD every time. Does anyone know what could be causing this behavior?

Code:
void CameraTest()
	{
		AxisCamera& pCamera = AxisCamera::GetInstance();
		pCamera.WriteResolution(AxisCamera::kResolution_320x240);
		pCamera.WriteCompression(20);
		pCamera.WriteBrightness(0);
		if (true/*pCamera*/) //since pCamera is not a pointer, this wouldn't work...
		{
		  ColorImage* pImage = pCamera.GetImage();
		  if (pImage)
		  {
		    if (pImage->GetHeight() == 0 || pImage->GetWidth()==0)
		    {
		      dslcd->PrintfLine(dslcd->kUser_Line4,"Error with image size - height/width is zero.");
		      dslcd->UpdateLCD();
		    }
		    else
		    {
		      pImage->Write("Image.jpg");
		      dslcd->PrintfLine(dslcd->kUser_Line4,"Wrote file out to Image.jpg...should be a success.");
		      dslcd->UpdateLCD();
		    }

		    delete pImage;
		  }
		  else
		  {
			dslcd->PrintfLine(dslcd->kUser_Line4,"Image returned by GetImage was NULL. Big error.");
			dslcd->UpdateLCD();
		  }
		}
		else
		{
			dslcd->PrintfLine(dslcd->kUser_Line4,"Never got the camera instance. Big error.");
			dslcd->UpdateLCD();
		}
	}
Daniel
Reply With Quote