I'm trying to work on vision code or at least displaying a camera feed on the dashboard, but the program crashes on the function where I set the camera server frame. I know about the StartAutomaticCapture function but I'm trying to actually have each frame in memory so I can threshold it or w/e. I have a command that executes this every update time (5 ms or whatever the default is).
Code:
cam->GetImage(NIframe);
CameraServer::GetInstance()->SetImage( NIframe );
Wait(0.1);
This causes the program to crash. The DriverStation says there is no RobotCode until I redeploy it/restart the roborio. The debugger says it is on this line (66) of wpilib's CameraServer.cpp.
Code:
while (start < dataSize - 1) {
if (data[start] == 0xFF && data[start + 1] == 0xD8) break;
else start++;
}
The header file for this command declares these variables
Code:
USBCamera *cam;
Threshold *thresh;
ColorImage *frame;
Image *NIframe;
BinaryImage *binaryFrame;
It's been pretty frustrating trying to figure this out. Any ideas? I'm not sure if I'm making an obvious mistake or this is actually an odd issue. Also, even without any vission stuff happening we seem to have communication drops for a second every once in a while, but this might just be low battery. Is my program perhaps too big? It is CommandBassed with like 10 command and 3 subsystems and a few PID loops. Thanks!