|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools |
Rating:
|
Display Modes |
|
#76
|
||||
|
||||
|
Re: Tower Tracker 1.0
and how to modify the code to use HSV instead of RGB?
|
|
#77
|
||||
|
||||
|
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;
if(aspect < 1.0)
iterator.remove();
|
|
#78
|
||||
|
||||
|
Re: Tower Tracker 1.0
Oh! Thanks so much! We were hoping to have this running by this Saturday for our competition!
![]() |
|
#79
|
||||
|
||||
|
Re: Tower Tracker 1.0
So it works? If so, good luck at competition. Any questions, PM me or post here.
|
|
#80
|
||||
|
||||
|
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]);
float hull_area = contourArea(hull);
float solidity = (float)area / hull_area;
if (aspect > 1 && rect.area() > 100 && (solidity >= .04 && solidity <= .4)) {
selected.push_back(contours[i]);
}
|
|
#81
|
|||
|
|||
|
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.
|
|
#82
|
||||
|
||||
|
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. |
|
#83
|
||||
|
||||
|
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!
|
|
#84
|
|||
|
|||
|
Re: Tower Tracker 1.0
if you need to you can save images every x amount of frames and write them to the driverstation laptop. My team did that during the match to see if we had the values correct (which we did). Sometimes fta is rude about measurement sometimes they are nice.
|
|
#85
|
|||
|
|||
|
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) |
|
#86
|
|||
|
|||
|
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! |
|
#87
|
|||
|
|||
|
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.....
|
|
#88
|
||||
|
||||
|
Re: Tower Tracker 1.0
Quote:
Code:
y = rec.br().y + rec.height / 2; y= -((2 * (y / matOriginal.height())) - 1); ). Let's rearrange the operationsCode:
double half_image_height = matOriginal.height() / 2; double pixel_y = half_image_height - (rec.br().y + rec.height / 2); y = pixel_y / half_image_height; 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 / 180 Code:
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. Last edited by euhlmann : 11-07-2016 at 12:15. |
|
#89
|
|||
|
|||
|
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;
double OffsetFromMiddle = Math.abs(targetY - pixelHeight/2);
double FractionofOffset = OffsetFromMiddle/(pixelHeight/2);
FinalAngle = AngleToHalfScreen+(AngleToHalfScreen*FractionofOffset);
Thank you so much for taking the time to explain this. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|