-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MatchGrid assertion with small grid #25
Comments
If I remove the matchGrid where the assertion fails, and add a drawRects in, this is what i get: matchGrid is returning lots of random points. This seems to have been caused by having a bad template that returned too many matches. The template was bad because it was copied and pasted from the grid which was also bad. I printed it out on a second printer, and this is what I get: It does still fail the assertion though. |
Wow. That's a pretty fine grid. MatchGrid is failing because it's starving on cell matches. The assert says "i have no idea where this cell is". For more data, try a larger grid taken with slight offsets between pictures. The algorithm has a key assumption that the cell positioning error is small with respect to the grid size. With the lens distortion I'm seeing, the cell positioning error is large and the algorithm can't quite figure out where the cells are. MatchGrid serves two purposes:
Sounds like you're trying to do #2. The original lens distortion algorithm in OpenCV relies on lots of checkerboard pictures and aggregates over them all. MatchGrid simulates that by using one picture and chopping it up into sections. Basically it cheats and you're discovering that. For more accuracy on the lens distortion calcs, I suggest coarser grid, but take five pictures (x0y0, x1y0,x0y1,x-1y0,x0,y-1) and average out the coefficients. OpenCV lens correction is limited. It won't account for every single lens defect, and can only really model certain kinds of distortion. If the endolens has a weird unmodeled distortion, then OpenCV will try hard and give you uncertain results. With the RaspiCam I found myself using the middle 50% of the image and ignoring the periphery, which is where most of the distortion creeps in. |
The other thing I'm curious about is the template. This is not an actual picture of anything but a perfect ideal grid intersection. The image was actually generated by FireSight itself. It's not a photograph. I found that template matching works best with idealized images instead of photographs provided the recognition goal is a simple geometric object. The use of photographs is only appropriate for highly complex templates (e.g., Mona Lisa) that have no simple geometric shape. Grids are pretty vanilla, hence cross32.png. |
I've used the cross32.png plenty, and I have been using them interchangeably with the one I showed above. If I use it, the assert error doesn't go away. |
The cross32 wont affect the grid assert, since that happens after the On Saturday, August 22, 2015, Neil Jansen [email protected] wrote:
Karl Lew |
I'd like to leave the issue open, we might not get to this immediately but I do think this is a valid open issue for firesight. I'm not sure if this is just a documentation fix or something that will drive some code changes. Either way I think this is going to be something needed for FPD in the future and I'd like to not have this information forgotten about. |
Code change would be major since the design assumption is orthogonal grid On Saturday, August 22, 2015, Neil Jansen [email protected] wrote:
Karl Lew |
Using the following pipeline:
And the following grid / template:
I get the following assertion:
I've tried to look through the code, but I can't seem to find out what's causing it. We don't get this assertion with a larger grid. But I'm not sure what's causing it to fail with a smaller grid. The documentation and lack of comments in the code make this a bit confusing to follow. Any help would be appreciated.
The text was updated successfully, but these errors were encountered: