Go to Post "Simple" is about staying within boundaries. - dtengineering [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 01-31-2014, 11:46 PM
Sparkyshires Sparkyshires is offline
Registered User
AKA: Michael Shires
FRC #0384 (Sparky)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2006
Location: Virginia
Posts: 226
Sparkyshires is an unknown quantity at this point
Vision sample code

hey guys, just a quick annoying thing that's been messing with our team. We've been trying to use the vision sample project 2014 with the m1013 camera. we've looked through it many times, and it appears that it should either just output not or not hot, correct? am I wrong in this assumption of what the sample code does? And then secondly, is there anything that you have to do to set up in the code? We set the camera ip to 10.3.84.11 (Sparky 384 w00t w00t!) and compression to 30, and all the other steps that the wpilib screensteps tutorial tell you to do in this page:
https://wpilib.screenstepslive.com/s...amera-settings

So in conclusion: What exactly is the vision sample project supposed to do?

what are requirements, if any, to set up the camera that aren't detailed in the screensteps?

Is there any code modifications that you have to make to the vision sample project 2014 before building and deploying?

Thank you all very much!
__________________
"Measure with a micrometer, mark with chalk, cut with an axe."
Reply With Quote
  #2   Spotlight this post!  
Unread 02-01-2014, 12:53 AM
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: Vision sample code

https://wpilib.screenstepslive.com/s...-compatibility

The 013 is a wider angle lens. Definitely pros and cons to using this. The out of box code was designed for cameras with a smaller angle. However you should be able to see both targets from your side of the truss, which most likely won't be true for the other cameras.

Also the vision code has a lot of other stuff in there, if you are solely trying to detect hot or not, you can do that in a much simpler fashion. i.e. look at the height to width ratio of each particle and see if you a particle that appears to match the hot reflector.

Our team is using a min ratio and min width to detect hot or not.
__________________
"Never let your schooling interfere with your education" -Mark Twain

Last edited by mwtidd : 02-01-2014 at 06:37 AM.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-01-2014, 11:10 AM
Sparkyshires Sparkyshires is offline
Registered User
AKA: Michael Shires
FRC #0384 (Sparky)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2006
Location: Virginia
Posts: 226
Sparkyshires is an unknown quantity at this point
Re: Vision sample code

Ok. How would we go about getting just a basic whether hot or not? I don't even know where to start
__________________
"Measure with a micrometer, mark with chalk, cut with an axe."
Reply With Quote
  #4   Spotlight this post!  
Unread 02-01-2014, 04:10 PM
ayantes's Avatar
ayantes ayantes is offline
Registered User
AKA: Andy Yantes
FRC #3193 (Falco Tech)
Team Role: Mentor
 
Join Date: May 2012
Rookie Year: 2011
Location: Austintown, Oh
Posts: 5
ayantes is an unknown quantity at this point
Re: Vision sample code

You need to setup Netconsole to view the Output of the printf commands. Example:
particle: 0 is a Vertical Target centerX: 219 centerY: 73
Scores rect: 71.474359 ARvert: 68.804771
ARhoriz: 1.463931
particle: 1 is a Horizontal Target centerX: 190 centerY: 45
Scores rect: 79.473684 ARvert: 0.000000
ARhoriz: 54.441782
Hot target located
Distance: 18.566375


particle: 0 is a Vertical Target centerX: 219 centerY: 73
Scores rect: 70.833333 ARvert: 67.708301
ARhoriz: 1.440602
particle: 1 is not a Target centerX: 190 centerY: 45
Scores rect: 79.459459 ARvert: 0.000000
ARhoriz: 44.115830
No hot target present
Distance: 18.500995
Reply With Quote
  #5   Spotlight this post!  
Unread 02-06-2014, 06:21 PM
Sparkyshires Sparkyshires is offline
Registered User
AKA: Michael Shires
FRC #0384 (Sparky)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2006
Location: Virginia
Posts: 226
Sparkyshires is an unknown quantity at this point
Re: Vision sample code

Yeah i got the printf set up and I got a couple of things to print out, but nothing inside the really big if loop. In the sample code in autonomous, where it is: if(reports->size() > 0) we can get it to printf up until that point. Which means that thats evaluating to false. The only issue is that I have no idea why D: I didn't change anything else in the code.
__________________
"Measure with a micrometer, mark with chalk, cut with an axe."
Reply With Quote
  #6   Spotlight this post!  
Unread 02-06-2014, 06:37 PM
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 985
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Vision sample code

Have you done anything to calibrate the thresholds to your lighting and camera? It sounds like you aren't ending up with any blobs after the threshold and size filter.

To find out you can try commenting out the while loop and un-commenting the lines that write the image to a bmp. Then ftp to the cRIO and grab the image from the threshold step to see if your target is there in red.

If not you will need to tweak the values of the threshold. The Calibration section describes one way using NI Vision Assistant: http://wpilib.screenstepslive.com/s/...61-calibration

Another option is to take a snapshot as described at the beginning of that document, then use your favorite image editing program to grab the HSL value of some arbitrary pixels of the target and then just try some ranges around that (+/-10, +/-20, +/-50) and look at the image you get each time.
Reply With Quote
  #7   Spotlight this post!  
Unread 02-06-2014, 06:48 PM
Sparkyshires Sparkyshires is offline
Registered User
AKA: Michael Shires
FRC #0384 (Sparky)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2006
Location: Virginia
Posts: 226
Sparkyshires is an unknown quantity at this point
Re: Vision sample code

Thats the other issue, I don't really understand what a "threshold" is. I know i've hard-set the brightness to 30 by going to the camera setup in browser and setting it there.
__________________
"Measure with a micrometer, mark with chalk, cut with an axe."
Reply With Quote
  #8   Spotlight this post!  
Unread 02-09-2014, 01:36 AM
sailorjoe sailorjoe is offline
Mentor, RoboEagles, FWHS
AKA: Joe Hafner
FRC #4579 (RoboEagles)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Auburn, WA
Posts: 10
sailorjoe is an unknown quantity at this point
Re: Vision sample code

Hi, SparkyShires. Thresholding is a way to separate the bright areas from the not-so-bright areas of in image. Basically, any pixel value below the threshold is converted to completely dark, or black. For extra complexity, This happens in each of the three color planes, which is why the Thresholding method requires so many parameters. After thresholding, the image will have only a few areas of interest, which were the bright areas in the image before thresholding. These are called "particles". The vision code processes these particles to determine Hot or Not.

When I moved the sample code into my robot program, I had to change some things. I took a few statements used to initialize the camera out to a separate method. Then I changed the VisionAnalysis method from void to boolean, and had it return the HotOrNot decision with a return statement just above the catch statements. With the changes made, I copied the whole kit-and-kabootle into a Camera Subsystem, which I call from an Autonomous Command.
More work to do! Good luck.
Reply With Quote
  #9   Spotlight this post!  
Unread 02-15-2014, 03:33 AM
sailorjoe sailorjoe is offline
Mentor, RoboEagles, FWHS
AKA: Joe Hafner
FRC #4579 (RoboEagles)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Auburn, WA
Posts: 10
sailorjoe is an unknown quantity at this point
Re: Vision sample code

Hi, SparkyShires. This might help, but my apologies if this is redundant. I spent two days trying to get an image. I'd start the the sample code, see about ten thousand error lines, shut down the code, and continue to debug the program. Eventually I realized that the first image took almost five seconds to materialize, and about 25 ms for each image thereafter. So unless you wait around for at least 5 seconds to get an image, your report size will be zero.

It's also possible to take a perfectly good image, and with thresholding and filtering, make all the pixels go away. You can see if this is happening by using your favorite web browser to FTP into the cRIO. In the URL window, type in "ftp://10.xx.yy.2", without the quotes. If you've captured images, they'll show up in the cRIO directory. By the way, you have to refresh the browser when you have a new image captured.
Good luck!
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 09:51 AM.

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