Go to Post I fear not the drive team who has practiced 10,000 defenses once, but I fear the drive team who has practiced one defense 10,000 times. -Bruce Lee - bEdhEd [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 19-01-2017, 21:56
RileyC3826 RileyC3826 is offline
Registered User
FRC #3826 (Sequim Robotics Federation)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2013
Location: Sequim, Washington
Posts: 9
RileyC3826 is an unknown quantity at this point
Multiple Vision Targets using GRIP

Our team is relatively new to vision processing, as this is actually the first year we have gotten it to work. My question is, how would we go about looking for and using multiple targets in our code? So far we can pretty easily detect a single piece of retro reflective tape, but when we put two in front of the camera, it just chooses one or the other to base its values on. To get our values, we are basically just using the example code from WPILIB, here more specifically:
https://wpilib.screenstepslive.com/s...-robot-program
We tried adding a statement that defines a second rectangle, but both of them end up getting the same values.
Reply With Quote
  #2   Spotlight this post!  
Unread 20-01-2017, 02:10
soundfx's Avatar
soundfx soundfx is offline
Registered User
AKA: Aaron J
FRC #3238 (Cyborg Ferrets)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2014
Location: Anacortes, WA
Posts: 17
soundfx is an unknown quantity at this point
Re: Multiple Vision Targets using GRIP

The findContours method used by GRIP should generate a list of contours (MatOfPoint), and it shouldn't be limited to just one contour. I'm not too familiar with grip generated code, but you should be able to modify it if needed to either get the full list of contours or get the first and second contours.
Our team has an example based off of grip's generated code that allows getting the full list of contours here. You can tune that to accept both contours.
__________________


"I got 99 problems but 0.999 ain't 1."
~Orteil
Reply With Quote
  #3   Spotlight this post!  
Unread 20-01-2017, 07:21
YairZiv's Avatar
YairZiv YairZiv is online now
Registered User
FRC #5951 (Makers Assemble)
Team Role: Programmer
 
Join Date: Oct 2016
Rookie Year: 2016
Location: Tel Aviv, Israel
Posts: 35
YairZiv is an unknown quantity at this point
Re: Multiple Vision Targets using GRIP

Quote:
Originally Posted by RileyC3826 View Post
Our team is relatively new to vision processing, as this is actually the first year we have gotten it to work. My question is, how would we go about looking for and using multiple targets in our code? So far we can pretty easily detect a single piece of retro reflective tape, but when we put two in front of the camera, it just chooses one or the other to base its values on. To get our values, we are basically just using the example code from WPILIB, here more specifically:
https://wpilib.screenstepslive.com/s...-robot-program
We tried adding a statement that defines a second rectangle, but both of them end up getting the same values.
What we've done (and I persume you guys use openCV directly and not through GRiP, but if you do then please excuse me), We've used the findContours() method and then used a function we created that sorts that list of contours from biggest to smallest, then we returned only the biggest 2. Using their data, you can do an avarage of their center Xs to check if your robot is centered on the rod of the gears or something like that.
Reply With Quote
  #4   Spotlight this post!  
Unread 20-01-2017, 20:07
RileyC3826 RileyC3826 is offline
Registered User
FRC #3826 (Sequim Robotics Federation)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2013
Location: Sequim, Washington
Posts: 9
RileyC3826 is an unknown quantity at this point
Re: Multiple Vision Targets using GRIP

Quote:
Originally Posted by soundfx View Post
The findContours method used by GRIP should generate a list of contours (MatOfPoint), and it shouldn't be limited to just one contour. I'm not too familiar with grip generated code, but you should be able to modify it if needed to either get the full list of contours or get the first and second contours.
Our team has an example based off of grip's generated code that allows getting the full list of contours here. You can tune that to accept both contours.
Okay, so I've looked at the code you provided and I can modify it so that it is using the same values for detecting the target, but could you provide an example on how I would get that list of contours to use in the rest of our code? I attempted to use
System.out.print({Class}.getContours());
but that ended up printing out nonsense:
https://postimg.org/image/nboabyidr/
Thanks,
Reply With Quote
  #5   Spotlight this post!  
Unread 23-01-2017, 21:23
RileyC3826 RileyC3826 is offline
Registered User
FRC #3826 (Sequim Robotics Federation)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2013
Location: Sequim, Washington
Posts: 9
RileyC3826 is an unknown quantity at this point
Re: Multiple Vision Targets using GRIP

I believe I have found the solution. I ended up modifying the code here:
https://wpilib.screenstepslive.com/s...-robot-program
I duplicated the statement that defines rectangle 'r', changed the second one to 'q', then changed the '0' in 'filterContoursOutput().get(0)' to a '1'. I also changed centerX to two different variables, one for rectangle r and one for rectangle q. My problem now is that sometimes, when running the robot, the values from the contours just suddenly stop, and will not update until I redeploy. I believe that for some reason, the visionThread is being stopped. If I try to use visionThread.start() somewhere in the program (besides robotInit), the program crashes (we suddenly lose robot code and comms in the driverstation). Anyone have an idea how I can resolve this issue?
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:22.

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