![]() |
Image Threshold Always Returns Black Image - C++ / Vision / AXIS
We have been struggling to get hot goal detection working using vision processing. We have an AXIS camera mounted with green LED rings and looking at the live camera feed we see the tape light up nicely. We have gone through camera settings and in the code can dump the raw image file and we see an expected dulled green target in a very dark background.
No matter what we have tried we keep getting an all black image back from the threshold operation. We originally had the camera settings "normal", and that did the same thing (except produced a standard light image of the target). We have messed around with all sorts of threshold values and code tweaks and nothing seems to work. We are command-based / C++ (and a snapshot of the code section is below). It should basically be the reference code. Some other items that we have tried - included changing to various sets of HSL and HSV settings (the reference code says one thing, the description online says another...), changed the ColorImage to HSLImage with no luck. The printf's all go through so it's running the threshold operation, but doesn't give us anything useful. Any ideas????:confused: Code:
void AutonomousCommandN::Execute() { |
Re: Image Threshold Always Returns Black Image - C++ / Vision / AXIS
If the libraries work the same for C++ as they do for LabVIEW, a BinaryImage has values of 0 and 1. If you use a normal color palette to view it, the image will consist of pixels that are either truly black or so dark as to appear black. Change the palette to distinguish clearly between those two values and you'll probably see what you expect.
|
Re: Image Threshold Always Returns Black Image - C++ / Vision / AXIS
Quote:
|
Re: Image Threshold Always Returns Black Image - C++ / Vision / AXIS
A few comments:
The NI Vision Assistant tool is really helpful for this; it will allow you to open a raw image on your PC and build and tune your filtering process. I've observed (but haven't confirmed in code) that your first call to Camera::GetInstance() is what initiates your connection to the camera, however it takes some time before you can get an image; you should do this in DisabledInit to ensure that when auto begins, the camera has images ready. (we use a framerate of 5, so it could be due to this as well, but the delay seems > 1sec) You don't have a convex hull operation; you will want to do this to combine smaller particles before you get particle reports. You can use Paint.net to inspect the HSV values, this can at least give you a rough idea of the hue and saturation ranges to use (since you are currently using an HSL filter). Keep in mind the numeric ranges for paint.net are different from those in the threshold (ie paint.net H range is 0 to 360, S range is 0 to 100, but I believe threshold is 0 to 255 for each). If you are using 320x240 (lower resolution than the default 640x480), the default value for #define AREA_MINIMUM is not appropriate, you need to divide that value by 4 since the resolution is halved in each direction. You don't show any delete operations in your code snippet, so the memory you use for each image is leaked/lost; not a major problem for one image, but it would be a problem if you run autonomous too many times. The following need to be deleted in if you are using the example code: image, thresholdImage, filteredImage, convexHullImage, reports, and scores. Scores should be deleted just before you leave the if condition where scores = New is called, filtered image and reports should be deleted at the end of your analysis, and the rest should be deleted after they are processed. |
Re: Image Threshold Always Returns Black Image - C++ / Vision / AXIS
Hey - thanks everyone...that was all helpful...
DJScribbles - I had only posted the first bunch of code until the threshold operation knowing it wasn't doing that, and figuring the rest didn't matter (yet). Our software guy will follow up with a more detailed analysis of what was wrong for everyone once we're done with tomorrow ( he made the changes, I only hack at the software). We were using paint.net previously, but didn't realize the 0-100 vs 0-255. And the divide by 4 as well. Thanks for all the help, again! |
| All times are GMT -5. The time now is 02:31. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi