Go to Post I think I speak to everyone who ever attended nationals there when I say...say it with me..."Please stand clear of the doors. Por Favor Metengan se alijados de las puertas." - Justin [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
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 24-01-2013, 21:26
JM033's Avatar
JM033 JM033 is offline
Registered User
AKA: J
FRC #0240 (Tempest)
Team Role: Leadership
 
Join Date: Jan 2013
Rookie Year: 2009
Location: Michigan
Posts: 46
JM033 is an unknown quantity at this point
Exclamation Help with Locating Disks with Vision

Before I start, I'm not really good with programming vision and have encountered some errors. Vision is something we need this year and I'm stuck right now. I have made a script with the three different colored disks with the labview vision assistant that detects the 'calipar' and 'location' of each disk. I followed a tutorial found here to basically help me:
https://docs.google.com/viewer?a=v&q...6Jr3M4FLLswFYQ

I have done exactly what it says in the tutorial, I believe. But when I test and probe the various outputs in the vision processing vi such as "matches (locate blue) I get absolutely no response when I hold a blue frisbee at the camera. The camera is an axis camera and is working fine, streams video that is relatively smooth, and has no issues atm.
Here is my vision processing code, along with the script I made with labview Vision Assistant, and included is the pictures I have taken to make the script. Make sure if you downloaded the .zip to unzip and place in new folder.
https://www.dropbox.com/sh/d6mssqq2lggorzw/xjZSQ3Ne_j

Thanks, btw we are doing offboard image processing
Reply With Quote
  #2   Spotlight this post!  
Unread 30-01-2013, 01:34
blackflame2996's Avatar
blackflame2996 blackflame2996 is offline
Alumni
AKA: David Donahue
FRC #2996 (Cougars Gone Wired)
Team Role: Alumni
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Colorado springs, CO
Posts: 67
blackflame2996 is a name known to allblackflame2996 is a name known to allblackflame2996 is a name known to allblackflame2996 is a name known to allblackflame2996 is a name known to allblackflame2996 is a name known to all
Re: Help with Locating Disks with Vision

You might try looking at example code in LabVIEW such as 'Follow Blob'. These need a lot of tuning, but are a great starting point for basic imaq processing in LabVIEW.
__________________
2009 Regional Winners
2011 Regional Chairman's Award
2012 Regional Winners
2013 Regional Chairman's Award
Reply With Quote
  #3   Spotlight this post!  
Unread 30-01-2013, 07:27
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Help with Locating Disks with Vision

I think what is going on is that the tutorial you are following uses a very accurate, but very unforgiving method of locating colored objects. It assumes that you have very good control over the type and amount of light, distance to the object, etc.

I'm sure that you can write simple color threshold code to locate a frisbee, and you can do a few additional particle measurements to see if it is round. This approach will be more forgiving in varied lighting conditions. Even then, make sure to follow the recommendations in the white paper regarding camera white balance setting, compressions, focus, etc.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 04-08-2013, 11:37
faust1706's Avatar
faust1706 faust1706 is offline
Registered User
FRC #1706 (Ratchet Rockers)
Team Role: College Student
 
Join Date: Apr 2012
Rookie Year: 2011
Location: St Louis
Posts: 498
faust1706 is infamous around these partsfaust1706 is infamous around these parts
Re: Help with Locating Disks with Vision

Quote:
Originally Posted by Greg McKaskle View Post
I'm sure that you can write simple color threshold code to locate a frisbee, and you can do a few additional particle measurements to see if it is round. This approach will be more forgiving in varied lighting conditions. Even then, make sure to follow the recommendations in the white paper regarding camera white balance setting, compressions, focus, etc.
this is exactly what we did this year (though we had to scrap the project due to weight issues which causes us to turn into a FCS only).

The steps:

Acquire image

Convert it to HSV (hue, saturation, and value)

(Binary) Threshold image to locate only the desired colour (red, white blue)

This is where vision programming has a lot of diversity...

We found the contour of an image, that is, where black meets white.

Approximate a polygon (I promise I will make this better before next build season for squares for teams that want to do pose)

then I said

if (result > 5))
[
it's a circle;
}

result being the amount of sides of the contour.

From then, you ideally should have located the circle.

To find the center:

// Calculate the moments to estimate the position of the frisbee
CvMoments *moments = (CvMoments*)malloc(sizeof(CvMoments));
cvMoments(*yourcontourhere*, moments, 1);

// The actual moment values
double moment10 = cvGetSpatialMoment(moments, 1, 0);
double moment01 = cvGetSpatialMoment(moments, 0, 1);
double area = cvGetCentralMoment(moments, 0, 0);

posX = moment10/area;
posY = moment01/area;

This gives subpixel accuracy for the center

Now you have the center of a frisbee based off the specified colour. Congrats. BUT, what if there was more than 1 of the same coloured frisbee?

This simple algorithm solves this problem (keep in mine that I used opencv and changed the center from the top left to the center of the screen to make the logic easier)

Int prevclosestfrisbee = 300 (arbitary pixel value that is high on the screen. *note the greater the y pixel value, the further it will be away.)

if (frisbee.y < prevclosestfrisbee)
{ prevclosestfrisbee = frisbee.y
}
else
{
contours = contours ->h_next:
}

after you go through all the contours (the frisbees that passed the threshold test and the approximate polygon test, then you're left with one with the lowest y value.

**note, you can do this with all 3 coloured frisbees, I posted an image on here of a frame while tracking all 3 disks. It does take a fairly large amount of processing power (this program ran ~13 fps while the program that tracked the alliance wall ran at ~27, but it is do able!)

Hope this helped!
__________________
"You're a gentleman," they used to say to him. "You shouldn't have gone murdering people with a hatchet; that's no occupation for a gentleman."
Reply With Quote
  #5   Spotlight this post!  
Unread 30-01-2013, 07:42
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: Help with Locating Disks with Vision

Quote:
Originally Posted by JM033 View Post
I get absolutely no response when I hold a blue frisbee at the camera.
I have a very basic question: why do you need to detect a blue frisbee with the camera?

Is it possible to simplify what you need it to do? During autonomous, all of the frisbees in play are white. During teleop, you can use your drivers eyes to detect the color. Because of this, I can't see a reason to detect the colored frisbees. Simplify and be relieved.
__________________
-
An ounce of perception is worth a pound of obscure.
Reply With Quote
  #6   Spotlight this post!  
Unread 30-01-2013, 07:58
JesseK's Avatar
JesseK JesseK is offline
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 3,659
JesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond repute
Re: Help with Locating Disks with Vision

I second Chris's suggestion. White discs are available in Autonomous. The driver is available (and more adaptable) in teleop.
__________________

Drive Coach, 1885 (2007-present)
CAD Library Updated 5/1/16 - 2016 Curie/Carver Industrial Design Winner
GitHub
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 10:47.

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