Axis Camera Exception: No Image Available

Hey all,

I’ve recently encountered a problem in saving images from the axis camera (M1101). I setup the camera according to instructions and it is working perfectly fine in every other aspect. I get a stream to the dashboard and it can be successfully pinged. However, when I try to use the getImage() function in my code I get an AxisCameraException saying no image is found even though the SmartDashboard is streaming well.

This is my code (very simple):


try
{
    Axis.getInstance("10.43.38.11").getImage().write("image.jpg");
}
catch (AxisCameraException ace)
{
    ace.printStackTrace();
}
catch (NIVisionException nive)
{
    nive.printStackTrace();
}

Thanks,

Evan Dastin-van Rijn

Once you get the instance of the camera it takes a few seconds to actually complete the connection, so for about 5-7 seconds after getting the instance no images will be available. Try getting the instance of the camera in robotInit and accessing it from there. We ran into this problem on Tuesday and that fixed it for us.

This is also what we experienced. When you see something like “ClassName.getInstance()”, it’s an example of the Singleton Pattern. The first time it is called, the object is constructed, so it takes a little bit of time (see the Lazy Initialization section of the link). calling getInstance() later should be pretty quick, though.

Thanks so much for the replies!

I am no longer getting the exception however when I ftp to the cRIO (10.43.38.2) in my browser “image.jpg” doesn’t show up. Am I correct in thinking the .write() function for Image writes tot he home directory of the cRIO and if not where does it save to?

Thanks,

Evan

Never mind, I figured it out. I found where the image was saved: 10.43.38.2/ni-rt/system. Thanks for all the help again!