View Single Post
  #5   Spotlight this post!  
Unread 26-01-2012, 10:08
enrique's Avatar
enrique enrique is offline
Registered User
FRC #1251 (Tech Tigers)
Team Role: Electrical
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Florida
Posts: 87
enrique will become famous soon enough
Send a message via Yahoo to enrique
Re: Camera GetImage not getting image

Quote:
Originally Posted by bob.wolff68 View Post
I might suggest a couple things...

Set your resolution, brightness, and compression before getting any images. Shouldn't be some major failure point, but....good practice.

Also, I thought that GetImage returned a ColorImage and while HSLImage is related, I'd give a shot at going to the basics that way.

Otherwise, I might suspect config issues - have you tried NI Vision assistant and is it able to grab images?

Lastly - after looking once again - I would suggest using a standard while(isOperatorControl()) {} and place your if (isFreshImage()) inside there. Remember, this is a realtime gig and while your desktop is faster than the cRio, the cRio is 400MHz and so it'll crank through the camera items very quickly. It is possible that after gaining access to the camera, it isn't ready for you to grab an image. I'd suggest sometime like:

Code:
...OperatorControl() {
int iWidth = 0;
Error &err;
ColorImage *image;	

AxisCamera &m_camera = AxisCamera::GetInstance("10.12.51.11");
m_camera.WriteResolution(AxisCamera::kResolution_3 20x240);
m_camera.WriteCompression(20);
m_camera.WriteBrightness(0);

while (isOperatorControl())
{
  if (m_camera.isFreshImage())
  {
    image = m_camera.GetImage();

    err = m_camera.GetError();	
    if (err.GetLineNumber() != 0)
    {
  // Might this supposed to be err.GetCode() for a code value?
  // Not going to fix the problem - but will be more informative I think.
      printf("AxisCamera error number %f \n", err.GetLineNumber());
      printf(err.GetMessage());
    }
    else
    {
      iWidth = image->GetWidth();
    }

  delete image;
  }
}

return;
}
This will test to make sure that you're REALLY waiting on the camera to become ready and grabbing an image, checking errors, and width etc. If you have are actively debugging, I'd breakpoint on 'iWidth=' line or do a printf() or something to alert yourself that you really did get a valid image at some point.

bob
P.S. This is being typed @ work - no compilers involved. Likely has minor issues or more...
Ok I tried this code, but isFreshImage is always false.
also. I had to use HSLImage *image; instead of ColorImage *image; in order to compile with no type mismatch.

Last edited by enrique : 26-01-2012 at 10:10. Reason: more info
Reply With Quote