View Single Post
  #7   Spotlight this post!  
Unread 23-01-2011, 10:38
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: CAMERA CODE HELP!!

Quote:
Originally Posted by sjspry View Post
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.

Code:
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...our_Camera.pdf

If there is any console output that you see before the program stops, posting that may be helpful.
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
Reply With Quote