Our team has been having some trouble with vision… big surprise. Like most people we are having trouble ‘getting’ the image because the width of the image that the robot is using is 0. This has happened in two drafts of code written by two different programmers, and we have tried writing the compression to 30.
brightness needs to be set non-zero - 50 may even be a nice number. You can try different values by going to the webpage for the camera and experimenting but in the real deal, you’ll need to set this in the pits based upon regional lighting.
Doing the AxisCamera::GetInstance() followed by setting settings for each image/trial is likely a bad thing for the camera. The settings are not sent to the camera right away as they are sent en-batch in a separate task. You’re MUCH more advised to do your GetInstance and settings at initialization time and simply use the instance you get back throughout your code in autonomous and teleop (or at least one for each). Also, you may want to do what many are doing…after setting the settings, do a Wait(3.0); (I’m not sure that 3 seconds is required, but that’s what I’ve seen a lot of and haven’t experimented to refute the number)
You have a line where you get the binary image by using:
There is a memory leak here. camera.GetImage() returns you a ColorImage* which IT ALLOCATED – it is your responsibility to delete it after you are done with it. So you’ll need a temp variable in there to allow for that.
With the following code block I am seeing some issues…
a) ‘results->size() < 0’ … I don’t think this is even possible. Did you mean ‘results->size() <= 0’ which would check to see if there are NO PARTICLES ?
b) if you wind up in the if-block, you return ‘returnresults’ which is a pointer that is uninitialized. Gonna cause you issues. I’d suggest maybe prepping the caller that you might return NULL in this case and that NULL is their signal that you got nothing in terms of particles.
Lastly - when you do return ‘returnresults’ to the caller, you must be careful and have the caller delete returnresults (and take care of each item in the vector<> deleting them along the way iteratively prior to deletion of the vector* itself).