Go to Post If there's one bit of advice I can give, its never underestimate the power of a hurricane. - Joshua May [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 30-01-2012, 11:31
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Image Threshold Produces Black Image

We used the NI Vision Assistant to generate code, and the script there works great on all our images, however once we generate code, modify to compile, and deploy to the robot, it doesn't seem to work properly.

I added code to write the image out to the CRIO filesystem as a jpeg before and after the threshold, the image going in looks normal, and can be loaded in vision assistant and results in particles as we expected; and the image saved after the threshold is just black.


We have additional steps doing particle analysis, and some custom code that decomposes the particle analysis results structure (which could be the problem, haven't debugged heavily yet).

Is there a reason this image is all black, I saw several labview topics where it has to do with the color pallete in labview, but is it a similar issue i'm seeing when I ftp to the robot where the squares are just dark-grey (and throwing me a red herring), or is there something different in the threshold function that is a problem.

Here is some psuedo code of what we're doing:
1.get camera image as color image (write it out)
2.run HSV threshold filter,
3.storing the result to binary image (write out binary image, this one looks black),
4.apply other image processing steps, convex hull + particle filter + particle analysis (we pass back the particle analysis by reference)
5.decompose the particle analysis results searching for the result name "Center Of Mass X" (i think) using if(strcmp() == 0)


If anyones got some helpful info or ideas it would be appreciated, once I figure this out I'll post back what went wrong.
tldr; I'm mostly curios if the black image is ok (just a color space issue) or if the threshold operation is failing to find anything.
Reply With Quote
  #2   Spotlight this post!  
Unread 30-01-2012, 11:54
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is online now
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Image Threshold Produces Black Image

I can almost certainly help you here. Our team ran into what sounds identical this weekend. One question though - when you do GetNumberOfParticles() on the BinaryImage, do you get non-zero results? If so...

When you call BinaryImage's Write() function, instead of writing a .JPG file, write a .BMP file.... what? Yea... seems to be a bug to me. We were writing Write("thresh.jpg") and it was all black. At some point, I decided to make it write a bitmap instead and changed to Write("thresh.bmp") and it works perfectly...

bob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
  #3   Spotlight this post!  
Unread 30-01-2012, 13:14
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Image Threshold Produces Black Image

Awesome thanks for the info.
I will try writing out a bmp later and hopefully see some more helpful results.

I'll have to take a closer look at the BinaryImage class too, I didn't look to much at it's interface because we're doing the bulk of processing in the generated C code, and only just added the HSV conversion in the calling code to try debugging this.
Reply With Quote
  #4   Spotlight this post!  
Unread 30-01-2012, 14:02
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is online now
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Image Threshold Produces Black Image

I must say that the C++ library is quite straight forward and seems to work quite well too.

AxisCamera::GetImage returns ColorImage* ... (or HSLImage* due to inheritance)
ColorImage::ThresholdHSL returns BinaryImage*
and BinaryImage:: has the particle analysis routines. Tada. Right down the line...very little babysitting other than making sure to delete the pointers given back to you or handle the GetImage differently by passing in your own ColorImage address.

bob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
  #5   Spotlight this post!  
Unread 30-01-2012, 15:36
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Image Threshold Produces Black Image

A binary image has pixel values of 0 and 1. That will display on a grayscale indicator as black and just slightly less black. Change the color palette of the image display to binary and you'll see it in much better contrast.
Reply With Quote
  #6   Spotlight this post!  
Unread 31-01-2012, 11:02
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Image Threshold Produces Black Image

So, we've had some success, though not in the way I expected.

The core issue was that we were attempting to do an HSV threshold on an RGB color image we aquired from the camera.

I switched to acquiring an HSL image from the camera and performing an HSL threshold on it, and was able to get some meaningful results.

On the PC, when FTPing the firefox preview (and I'm pretty sure MS Paint) does properly display a binary bitmap as black and red, I didn't try writing out a jpeg this way to see if it worked that way though.


A follow up question, for the sake of discussion:
(note: We are using a green light ring for activating the retroreflective tape)
Are there any advantages to using HSV over HSL? Would it be worth figuring out how to use that colorspace? It doesn't seem to be directly available through ColorImage. We chose HSV semi-arbitrarily, so I'm not sure if it's worth the fight to go back to it, or if we should just tune for HSL.
Reply With Quote
  #7   Spotlight this post!  
Unread 31-01-2012, 13:43
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is online now
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Image Threshold Produces Black Image

If you're looking to change colorspace and see what happens, go back (or start using) NI Vision Assistant. After acquiring an image and beginning to process it, if you go to the "threshold" processing area in the 2nd tab, you can select "RGB", "HSL", "HSV" etc in a drop-down list and then play with the filtering min/max values. This will give you the ability to experiment and see what works best. Then use those values in your actual call in C/C++ once you're happy with it.

The white paper on target finding this year goes into HSL/HSV to a decent degree BTW.

bob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
  #8   Spotlight this post!  
Unread 31-01-2012, 16:32
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Image Threshold Produces Black Image

The problem I encountered was occurring with the output from vision assistant, I switched to using the colorImage->threshold function after getting the black screen there. The vision assistant seems to perform some extra steps on the jpg you give it to put it into the proper color space, which doesn't get done in the generated c code.

Perhaps I need to close the loop on this whole fiasco, it maybe that it originally worked fine doing the conversion in the generated code, but combination of bad particle analysis decomposition and from writing my binary image as a jpeg caused it to look 'broken'.

But, throughout this, our vision assistant script has given us the expected result, while we were unable to get any results from the C++/c code (until switching color space).
Reply With Quote
  #9   Spotlight this post!  
Unread 31-01-2012, 19:51
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is online now
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Image Threshold Produces Black Image

So, if I read this right, you're on your way to health. Yes? If so, then we'll just close this out until there's something new or you get a rockin' great tracker!

bob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:26.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi