![]() |
Sample Vision Code, ComputeThreshold() exception
So, our team is trying to get the sample vision code to work using the Axis M1011 camera, and we are getting a weird exception. As we step through the code, I'm finding that the cause (or at least where the error occurs) is when "image->ThresholdHSV(threshold)" is called.
By going into ColorImage.cpp we have found that the exception occurs on line 37 when "wpi_setImaqErrorWithContext(success, "ImaqThreshold error")" is called. The value of success is 0, which I assume means it was successful but I'm not sure. We have not tried this process with any images loaded onto the cRio. We can see the camera by viewing it on the Dashboard and/or in a web browser. The IP is set to 10.15.51.11. Any help or suggestions would be much appreciated. ![]() Code:
void Autonomous(void)Code:
BinaryImage *ColorImage::ComputeThreshold(ColorMode colorMode, |
Re: Sample Vision Code, ComputeThreshold() exception
Have you seen the error readout on the driver station? I am having the same problem and get an error saying that the image is not large enough. Although I can't use Windriver debugging or deploy code to the cRio through windriver and have an FTP workaround instead
|
Re: Sample Vision Code, ComputeThreshold() exception
I don't recall noticing anything on the drivers station, that's not to say I just didn't see it. I will definitely check to see what the readout says next time though, which might not be until Thursday unless another member can give it a try. We had the net console up at the time and the program just quits with a fatal kernel task exception.
We also had a lot of problems getting the debugger to work properly. I somehow got it working but I did not change anything that I know of, it just started to work. We have the same configurations (as far as I could tell) on my laptop and another team laptop and only mine can actually debug without it terminating too early. It's very frustrating. We can deploy new code fine, so that's not the issue. I don't think this should matter but we over-installed WR with the 2013 version. We have updated workbench with both the 1/5 and 1/18 updates. We've gone through the documentation several times so I'm not sure why this is happening. What errors do you get when you try to deploy code? You have the correct team number and x.out file selected correct? |
Re: Sample Vision Code, ComputeThreshold() exception
The IMAQ functions being used are documented here ... C:\Program Files (x86)\National Instruments\Vision\Documentation in the NIVisionCVI.chm file.
For the function imaqColorThreshold() it states that the return value is nonzero for success and zero for failure and states that imaqGetLastError() will give more detail. From what I see, that isn't happening, so the error is simply a generic threshold failure. There are several requirements documented for the original function. These requirement include that the image type of the dest is a U8, that the source is a three element color, either RGB or HS(LVI). From statically looking at the code fragments you attached, I see nothing wrong, which is why it would be key to see what the error code tells us. Greg McKaskle |
Re: Sample Vision Code, ComputeThreshold() exception
I don't get an error, the code simply starts transferring and gets anywhere from 50%to 90%before it stops transferring. It does not actually load code onto the cRIO. We have everything configured properly and the communication exists because we can load our code via FTP. It's an error somewhere in windriver's deploy function.
|
Re: Sample Vision Code, ComputeThreshold() exception
Quote:
|
Re: Sample Vision Code, ComputeThreshold() exception
Quote:
|
Re: Sample Vision Code, ComputeThreshold() exception
I had the same issue. I ended up solving it by recreating the main part of the code manually in my own function and class. All the other functions were copied over directly.
|
Re: Sample Vision Code, ComputeThreshold() exception
Because I'm having a similar issue, the Driver Station Messages are as follows:
Code:
<Code>-1074396120 ERROR: status = -1074396120 (0xBFF60428) Error in convex hull operation: ...in ConvexHull() in C:/WindRiver/workspace/WPILib/Vision/BinaryImage.cpp at line 209 |
Re: Sample Vision Code, ComputeThreshold() exception
Those errors are far less mysterious. It looks like one of the images used in threshold and convex hull and the other calls hasn't been allocated or has been closed or released before being used.
Inspect the code that creates the images that go into those calls. Greg McKaskle |
Re: Sample Vision Code, ComputeThreshold() exception
Last year, people had some issues with images that were valid pointers (I think), but had 0 width, and would crash (due to an exception). I used this guard code after getting the image, but before converting to a binaryImage.
Code: Code:
if ((colorImage == (void *) 0) || (colorImage->GetWidth() == 0) || (colorImage->GetHeight() == 0))My full code is here: https://github.com/TeamExcel/Project.../Robot2012.cpp Line 795 has the camera code. Edit/Delete Message |
Re: Sample Vision Code, ComputeThreshold() exception
We're having a similar issue as the OP with a fatal exception on the Threshold line. We invoked GetWidth() on the image prior to the call and got a very large non-sensical value.
(Sorry about the reply in 2 similar threads , but I'm not sure if both are getting the same attention.) |
Re: Sample Vision Code, ComputeThreshold() exception
I have been using the 2013 Vision Code example and am getting the same errors. We are using an 8-slot cRIO and a computer that didnt have windriver on it previously.
When I load the example code, and switch it so that it pulls in the image from the camera, I get an error on the driver station diagnostics: Warning <Code> 44002 ocurred at Ping Results: link-bad, DS radio(.4)-bad, robot radio(.1)-GOOD, cRIO(.2)-GOOD, FMS-bad Driver Station <time>1/15/2013 1:00:55 AM>unique#>4 FRC: Driver Station ping status has changed. (Our system clock and date are way off, ignore it) Emphasis mine. Also, earlier when I tried to change the value of the Hue in the code so that it could be any Hue, as we are using a white light and don't want just green, I got the same error message as the OP, in the Target Exception error box. |
Re: Sample Vision Code, ComputeThreshold() exception
Quote:
Unless you're using a separate router connected to the Driver Station (perhaps for better range or 5 GHz WiFi), the DS radio will show as bad, and that's okay. The FMS will always show as bad until you're actually plugged in to a competition field. |
Re: Sample Vision Code, ComputeThreshold() exception
We are also having trouble getting an image using the sample vision code.
I am a complete newbie wrt the FRC competition, and doing my best to learn. The camera.GetImage (image) function is not returning anything in image. The sample code does not initialize image, so it could point to garbage. The call to camera.GetImage (image) passes image by value so I don't see how it could change image and in our tests it doesn't appear to. Since it initially contains a garbage pointer, this might explain some of the errors people send when the code attempts to dereference the pointer. I've tried to find/guess a way to initialize the pointer without success. The sample code doesn't show any way to initialize it, so it's very puzzling to me how it could work. The function documentation is not very information, and all the examples/help talks about what to do once you've obtained an image. Any basic help would be appreciated. |
Re: Sample Vision Code, ComputeThreshold() exception
Quote:
Code:
int GetImage(ColorImage *image); |
Re: Sample Vision Code, ComputeThreshold() exception
Quote:
Trying storing a known value in image before calling GetImage and then comparing that to the value on return. Code:
ColorImage *image = NULL;P.S. Don't keep processing if image==NULL, the pointer dereference will cause an error. In our tests, the value in image never changed. I looked for other ways to initialize image but couldn't find anything. One thing I'll try when I next get a chance on the robot will be to put the access to the test image back in and see if that will work as a workable initializer. |
Re: Sample Vision Code, ComputeThreshold() exception
I have begun to try C++ and ran the 2013 vision example, but seem to be having a problem similar to what is described here.
I have not yet attempted to debug it much other than to know that the driver station crashes out starting with the following line when I'm trying to use the camera rather than trying the files. BinaryImage *thresholdImage = image->ThresholdHSV(threshold); I was hoping that someone would have posted a solution, but it's not clear from the description here that there is one. However, I presume that someone figured this out before competition. I have loaded the last update available and am using the M1011 camera. If someone identified a clear solution would you please post it. thanks. |
Re: Sample Vision Code, ComputeThreshold() exception
Code:
BinaryImage *thresholdImage = image->ThresholdHSV(threshold);Don't do that. Instead, declare the pointer, then allocate memory and set the pointer to point to the newly allocated memory. Only after that's done can you dereference the pointer. Alternatively, you might want to create thresholdImage as a BinaryImage instead of a pointer to one. |
| All times are GMT -5. The time now is 14:25. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi