![]() |
Re: Installing OpenCV
Obligatory tutorial post about bounding rectangles and minenclosing circle for those who are interested:
http://docs.opencv.org/doc/tutorials...s_circles.html Here is what I have done with these various methods: fitelipse: http://www.chiefdelphi.com/media/photos/39015 bounding rectangle: http://www.chiefdelphi.com/media/photos/39264 approxpoly: http://www.chiefdelphi.com/media/photos/39147 (from the stl regional) another approxpoly from 2012: http://www.chiefdelphi.com/media/photos/38819 Approxpoly is great at what it does, but it doesn't always return the proper corners, which is not ideal for doing a pose calculation to get distance in x y z and pitch roll yaw. To fix this, cornersubpix is used, which its whole existence is to refine corner locations. You give it where you think corners are, give it a matrix of pixels to look in around the corner(s) you gave it, and it outputs refined corner locations with subpixel accuracy. Tutorial: http://docs.opencv.org/doc/tutorials...ubpixeles.html LASTLY, to get an accurate center from find contours, apply a moment calculation so you have subpixel accuracy for the given contour: http://docs.opencv.org/doc/tutorials...s/moments.html |
Re: Installing OpenCV
I am going to try to get OpenFrameworks to work, alongside OpenCV. I guess that it would give me access to a couple more features!
The problem is that the installation instructions are how to install VS, not OF! :( :confused: :yikes: |
Re: Installing OpenCV
Quote:
Thanks for all the pointers and links! The only issue is, we are using Python and most of the tutorials available are for C++. There is no easy translation from one to the other. So, I'll keep pluggin' away. |
Re: Installing OpenCV
I need to learn how to use polygon functions to find balls! I tried hough-transforms, but for a function deemed as "very powerful" I was very disappointed. I was only able to detect a CD, and even that needed to be in an exact environment for the processing/detection to be successful/trustworthy!
|
Re: Installing OpenCV
Quote:
functions to look at: findcontours (this is a mus) with the output you could feed it into: Approxpoly fitelipse boundingrect contourarea to eliminate noise that passed your thresholds and morphological operations (aka erode and dilate) iscontourconvex - this will return contours with corners going outward. A shape that would not pass this for example is the number 7. minarearect is like boundingrectangle, but it can be rotated. I apply this when the static and dynamic target combine when I am 30+ feet away and check the "slope" of the box to test which corner I am looking at. The right corner will be positive and the left will be negative. minenclosingcircle: it is sort of like fitelispse, but it will return an actual circle. A ball will be circular no matter what angle you look at. A frisbee will not. I am using this function for ball tracking this year. It really comes down to pick your poison. I know there are other methods for object tracking (cough cough canny), but this all have example programs on them. Honourable reference: goodfeaturestotrack. Strange thing is I got houghllines and houghlinesp to work over the summer yet houghcircle just doesn't work. I'll see what I can do to fix it after this season. I have personally gotten all of these functions I have referenced to work, if anyone has questions, shoot me a pm. |
Re: Installing OpenCV
I think it could be my OpenCV version that sucks. I guess that if I migrate back to Windows, things will move much more smoothely! I really think it is a pain switching platforms, especially from Ubuntu to Windows because I first need to copy the files, and manually configure the compiler. I wonder if it is possible to get pkg-config-like library manager for windows so I don't need to spend half an hour creating a project!
|
Re: Installing OpenCV
If anyone's interested, I came up with this program:
http://www.youtube.com/watch?v=N2jXXdJkp2w |
Re: Installing OpenCV
Quote:
I was using that for generating a bin file for FindContours. Let's just say, not a good idea. I'm back to HSV processing and I'm doing way better now! |
Re: Installing OpenCV
OK, I'm feeling really dense right now.
I've gotten my detection code for the balls to reliable identify the balls and place the location parameters into an array. I am using cv.MinEnclosingCircle to generate the target location values. The issue is, I can't figure out how to get the data out of the array for displaying or using to move the robot. The format of the data is as follows form a "print Balls" command: [(1, (101.5, 137.5), 76.88045398)] I know the 101.5 is the center "X" value, the 137.5 is the center "Y" and the 76.88... is the Radius. When I try something like Code:
(x,y) = Balls [1]What simple Python command let's me parse this info out? (As you can tell, I'm still learning Python.) |
Re: Installing OpenCV
Try Balls[0][1]
Quote:
|
Re: Installing OpenCV
Quote:
Code:
x = Balls[0][1]Code:
(101.5, 137.5)So, two steps forward, one back. How would I parse out "x" and "y" from this. Next, any idea why it crashes out? Please ignore the "Crashing" I figured out it was crashing out when it didn't see any circles. I adjusted my code to prevent this. So, now I would just like to know how to parse out the three values separately. |
Re: Installing OpenCV
Quote:
|
Re: Installing OpenCV
Quote:
He tells me that if I want the "x" , "y" and radius values, I should use: Code:
x = Balls[0][1][0] |
Re: Installing OpenCV
Quote:
UPDATE**** I just googled and I think you may have messed up with some X and Y variables, causing the canvas size to be a tad small, triggering this error! That's something you may want to look at! |
Re: Installing OpenCV
Quote:
Quote:
Nope, the crash was caused by trying to parse out values from an empty array/tuple. If there are no values there and you try to parse it, the structure of the array is different from the structure of the parse, and thus it crashes! Our code is now working and tracking just how we want it to. |
| All times are GMT -5. The time now is 22:45. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi