|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
||||
|
||||
|
Re: Multiple Vision Targets using GRIP
Quote:
|
|
#4
|
|||
|
|||
|
Re: Multiple Vision Targets using GRIP
Quote:
System.out.print({Class}.getContours()); but that ended up printing out nonsense: https://postimg.org/image/nboabyidr/ Thanks, |
|
#5
|
|||
|
|||
|
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? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|