CAMERA CODE HELP!!

Hey guys i was wondering if anyone knew how to get the camera feed on the dashboard?? the camera worked fine last year with the following code

AxisCamera.getInstance().writeResolution(AxisCamera.ResolutionT.k320x240);
AxisCamera.getInstance().writeBrightness(0);

but this year it does not work. Whenever this camera code is put onto our robot, nothing happens, and the drive does not work either. it totally kills the code.

any suggestions??

team 1652

Make sure you have

AxisCamera camera = AxisCamera.getInstance();

in your constructor. Otherwise, you’re not actually initializing it.

Also, make sure there is an account on the camera with a username of “FRC” and a password of “FRC” (without quotations for each). Apparently you couldn’t have a feed without that account last year as well. I just found out, and now we have a working feed. Time for bed now. :smiley:

We are also having trouble with getting the camera to show on the dashboard.
For configuring it do we need to change the subnet? or router IP?

make sure the camera is connected.
if the camera is not connected it causes the system to crash.
I ran into this every time i removed the camera from the system.

as was said before, get the Axis Cam utility and add an admin username: FRC pass: FRC.

also check out this response from NI

Also, note that when you call “getInstance” of the AxisCamera, it initializes and returns a class the first time you do this. If you don’t capture this class in a variable and keep it “alive” during the whole of your robot’s run, it will get garbage collected and the thread it creates to relay information will be killed.

This is not true. AxisCamera.getInstance() will create a new instance of the AxisCamera class and return it the first time it is called. Any time after that, it returns the one instance that it already created. There is no destructor that kills the camera thread, and a reference to the singleton AxisCamera instance is always stored within the AxisCamera class in AxisCamera.m_instance. A call to AxisCamera.getInstance() will always return this instance.


public class AxisCamera implements ISensor{
    private static AxisCamera m_instance = null;
    
    ...

    public static synchronized AxisCamera getInstance() {
        if (m_instance == null) {
            m_instance = new AxisCamera();
        }
        return m_instance;
    }

The constructor calls the AxisCameraStart function that is part of the C++ library. That function starts up the PCVideoServer. Even if there was destruction of the AxisCamera object, it would not signal this thread to stop.

To get back to the original question:
Make sure the camera is configured per the instructions located here: http://www.usfirst.org/uploadedFiles/Robotics_Programs/FRC/Game_and_Season__Info/2011_Assets/Kit_of_Parts/How_to_Configure_Your_Camera.pdf

If there is any console output that you see before the program stops, posting that may be helpful.

Don’t try to adjust any camera settings from your code. Do all of your setting adjustments by going to the camera’s webpage by connecting directly to it with your computer. The reason I say this, is because from my experience this year WPI Lib’s camera parameters code is broken and crashes if you try to adjust any parameters.

In other words, try using just one line of code for streaming images from the camera:

AxisCamera camera = AxisCamera.getInstance();

we’ve only had success this year with streaming images from the new camera by doing this.