![]() |
Camera code stops recieving images
Hi Everyone,
We are having an interesting problem with our camera code and we were wondering if anyone has seen anything like these. We have an auto targeting routine that works great but we are only able to call it about 6 times andd then the camera stops returning images. We still get the live feed on the dashboard though. Afterwards we have to reboot to get the camera code to work again. Any idea what might be wrong? Does anyone do anything special in sequential camera calls? |
Re: Camera code stops recieving images
One possibility is the camera task died. You need to look at your net console to see if that's the case.
|
Re: Camera code stops recieving images
Are you deleting the old images you are creating as part of your loop. I read somewhere that the old images will build up fast if you aren't removing them constantly.
|
Re: Camera code stops recieving images
Im having the same problem right now. I have one version where it doesn't occur and a more recent one where it does. The changes should* all be okay though...
The newer version organizes particles. That is the only change. My image is deleted also. As for the console, i have been using the ds lcd recently because after i connect target server when trying to open the console the target tools option is not available in the drop down menu. |
Re: Camera code stops recieving images
reports->at(highParticle).center_mass_y;
I think lines like this may be what is guilty... is there anything wrong with this? reports is the vector particle analysis report and high particle is an integer I commented all of these lines out (I used them to compare particles and create variables like highParticle or highParticleCenterX etc.) |
Re: Camera code stops recieving images
Quote:
|
Re: Camera code stops recieving images
Yes, i am sure(within reasonable doubt).
It works for a few iterations before failing. I had the 2 other team programmers look to check that everything was alright when this issue started (after I added code using those lines). The CPU usage in the DS climbs when it starts using the camera and plateaus for a while while it works before stopping. I could post before and after code if it would help. (this is reasonably short because it's simplified and camera-specific) I delete everything I use in any loops which I make it in. |
Re: Camera code stops recieving images
Yeah, it would help to diagnose the issue with the surrounding code.
|
Re: Camera code stops recieving images
1 Attachment(s)
Okay and thankyou!
|
Re: Camera code stops recieving images
Wait, which line is the culprit now? There is no line "reports->at(highParticle).center_mass_y;" in your alteredCode.cpp. I assume the workingCode.cpp is the working one and alteredCode.cpp is the one with problems, although I see more bugs in workingCode than alteredCode.
|
Re: Camera code stops recieving images
The primary differences between the two files are
Code:
centerX = reports->at(highParticle).center_mass_x_normalized;Code:
for (unsigned int i = 0; i < reports->size(); i++)I commented out these lines and the code began to work again. I also tried to make particle analysis report pointers like in the other file to compare results but that works in a similar fashion with the exception that when the code stops working instead of the CPU usage flat-lining it spikes and does not come down and the code stops as with the other way. I apologize for any distracting extraneous code or any bugs in the 'working' version. It is a save from when I got the camera to work as I intended (my lesson learned- this being the second time) Once again, thankyou. |
Re: Camera code stops recieving images
Okay, then the most logical explanation is that your reports->size() sometimes gives you zero, meaning that it can't find any target. In that case, your reference to particle 0 "reports->at(highParticle).center_mass_x_normalized;" will fault. To prove this, add something like this to your code. By switching this code, you will print out size() before you execute that centerX line that will fault. I'd bet, size() is zero.
Code:
numTargets = reports->size(); |
Re: Camera code stops recieving images
thankyou; i will try that as soon as possible.
I will check in the for loops also (which do something similar) |
Re: Camera code stops recieving images
That fixed it; thankyou very much
|
Re: Camera code stops recieving images
I am glad that's fixed. In general, you need to add more "error checking" code and always assume the WPI library calls could fail. For example, all the calls that generate images such as ThresholdRGB, FilterImages etc could fail and return NULL pointers. If you don't check and use them, you will fault. It may be unlikely but it could happen under unusual circumstances. For example, here is an excerpt of our vision processing code. Note that it checked for errors after each WPI library call and at the end when deleting the objects, we called SAFE_DELETE which is a macro that basically check for NULL pointer before it deleted the object.
Code:
int err = ERR_SUCCESS; |
Re: Camera code stops recieving images
duly noted; thank you!
|
| All times are GMT -5. The time now is 14:31. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi