![]() |
Re: Tower Tracker 1.0
and how to modify the code to use HSV instead of RGB?
|
Re: Tower Tracker 1.0
Quote:
Also, those values seem fine to me. I think i see the issue. Tower Tracker checks if the goal bounding rectangle is wider than it is tall. So when viewing from sharp angles like that is not going to give you a selected contour. Do you have a test image where the goal is straight on? If not, you can just get rid of this segment of code: Code:
float aspect = (float)rec.width/(float)rec.height; |
Re: Tower Tracker 1.0
Oh! Thanks so much! We were hoping to have this running by this Saturday for our competition! :)
|
Re: Tower Tracker 1.0
So it works? If so, good luck at competition. Any questions, PM me or post here.
|
Re: Tower Tracker 1.0
Sorry for double post but just making sure you see this...
I would also check for solidity of the target. This makes sure you don't get stray objects even if it passes all other checks. Here is c++ code, very similar to java. Code:
float area = contourArea(contours[i]); |
Re: Tower Tracker 1.0
The aspect ratio part of the code helps filter out things that the hsv filter cannot. We know the target is always wider then it is tall therefor it's aspect ratio will always be greater then 1 and if it's not don't detect it as a possible target. There are other things you can do to help but my team has found its good enough. You always know it's going to be atleast a certain pixel range because you can only shoot from a certain part.
|
Re: Tower Tracker 1.0
Quote:
I also added checks for solidity in my c++ version here if you want to check it out. Just like in grip. |
Re: Tower Tracker 1.0
Yes! It turned out that the bounds are in HSV and not RGB and that solved some problems. I am hoping to get some good pics during field calibration today for the our event and calibrate correctly! Thanks guys for all the help!
|
Re: Tower Tracker 1.0
Quote:
|
Re: Tower Tracker 1.0
Quote:
Code:
Exception in thread "main" java.lang.NullPointerException at org.usfirst.frc.team5407.robot.TowerTracker.main(TowerTracker.java:107) |
Re: Tower Tracker 1.0
Yes, I messed up the github code but luckly one of my team members has the code on his github. https://github.com/Aventek/TowerTracker3019Modified
Hopefully this helps, pm me if you have any questions! |
Re: Tower Tracker 1.0
This may be a dumb question. But could someone please explain to me the "fun" math i am not really sure how its doing what it is doing.....
|
Re: Tower Tracker 1.0
Quote:
Code:
y = rec.br().y + rec.height / 2;Code:
double half_image_height = matOriginal.height() / 2;With that change, this operation makes a bit more sense. The point is to calculate the offset in normalized coordinates from the middle of the target to the horizon. The horizon is assumed to be at (matOriginal.height()/2). First, it subtracts the y-coordinate of the middle of the target from half of the image size in pixels. This results in the pixel offset between the horizon line on the image to the target y-coordinate. Then, the entire thing is normalized by dividing it by half the pixel image height. ![]() Code:
distance = (TOP_TARGET_HEIGHT - TOP_CAMERA_HEIGHT) / Math.tan((y * VERTICAL_FOV / 2.0 + CAMERA_ANGLE) * Math.PI / 180);There are two parts. First, the angle from the horizon to the target is approximated using the small angle approximation. Code:
(y * VERTICAL_FOV / 2.0 + CAMERA_ANGLE) * Math.PI / 180Code:
angle = arcsin( pixel_y * sin(VERTICAL_FOV/2.0) / half_image_height )Now the camera may be tilted relative to the field, meaning that its local "horizon" isn't the same, so the offset CAMERA_ANGLE is added, for the angle that the camera is tilted relative to the actual horizon. Now the final part is to calculate the distance using the known height of the target and this calculated angle to the horizon. ![]() h is the distance from the camera's height to the target's height (TOP_TARGET_HEIGHT - TOP_CAMERA_HEIGHT), so tan(alpha) = h/d => d = h/tan(alpha) I hope this explains it. |
Re: Tower Tracker 1.0
I am very likely working on a faulty understanding of FOV but wouldn't this be much simpler?
Code:
double AngleToHalfScreen = Vertical_FOV/2;Thank you so much for taking the time to explain this. |
| All times are GMT -5. The time now is 22:01. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi