Pose estimation engine update

Project Page Next project post Post History

In a recent post on detecting checkerboard patterns in images, I noted that I had to rework some of my matrix functions, because they were not giving correct numbers. And it occurred to me that I had an error that was popping up in my pose estimation engine, that appeared to happen at random places, which I hadn't resolved yet.

Here's what was happening: I was getting camera pose positions that were obviously incorrect. But they seem to be happening in random places. But, if you played around with the test scene enough, you could find one of those places where it failed. I saved the test scene file at one of these locations so I could come back to run the pose estimation to get the same incorrect result. It was repeatable, in the 'right' place.

Then I remembered I had to rework my matrix inverse and determinant functions for the checkerboard detection engine, and I had kept the old "get_determinant()" function in my code. Mostly just in case I needed to fall back to the original while making the new one. Even though it was wrong.

I then noticed that the code running the pose estimation was in fact still using the old determinant function. So I switched that out for the new one and hey presto, no more camera pose solve error!

As I've commented previously, it pays to make sure the functions you write run correctly from the get-go, otherwise it can have a cascading effect further down the line. It's good to have online helpers like matrix calculators that you can test against as well. These will help establish if your numbers are right or wrong.

Bug fixes like these can sometimes take an age to fix. Especially if it's part of code that was written quite some time ago. But it's a healthy thing to get on top of. Good clean working code is worth it's digital weight in gold.