Log in

View Full Version : Camera Declaration/Initialization


scolbertrocks
21-02-2010, 09:20
I know there are lots of threads on the camera, but i havn't seen any on this topic specifically.
I'm just wondering how to declare/initalize the camera in an Iterative Robot based program.
Because (correct me if im wrong) you have to use AxisCamera &camera = AxisCamera::GetInstance(), the &camera is a reference, and MUST be initialized when it is declared.
If i put this line of code in the constructor, or TeleopInit, the reference can't be accessed in any other function.
If i put it in TeleopPeriodic, I will be able to access the camera reference where i need it, but it will be inneficiently called every loop

What is the best, or atleast a working way to get a working variable/reference of the camera that i can access in TeleopPeriodic for tracking?

scolbertrocks
21-02-2010, 11:42
Has anybody gotten the camera feed and tracking to work in iterative robot?

mandrews281
22-02-2010, 00:05
Yes. We resorted to a global variable so above our robot declaration we have:

AxisCamera &g_camera = AxisCamera::GetInstance();

class Robot281: public IterativeRobot {
etc.
};

byteit101
22-02-2010, 07:26
put it in the class:
public yourrobot:public IterativeRobot
{
...
AxisCamera &cam;
public:
yourrobot():
...
cam(AxisCamera::GetInstance())
{ }

....
};