Question

I would like to measure the displacement of an object between two images. The displacement can be anything in the image plane. The result should give the displacement, if possible in sub pixel accuracy.

There are some assumptions, which should make it easier, but didn't help me so far:

  • the camara objective is virtualy distortion free (telecentric) and oriented perpendicular to the object plane
  • the object plane never changes
  • the flat marker object (could be known image, e.g. a play card) is always in the object plane, so it isn't scaled or warped -> only rotational and translational changing.

My first approach was to take the feature recognition example from EmguCV, find the first object in the first image, take the relevant piece of that picture, use it now as template and search it in the second image. This did work, but a little unsatisfactory. There was scaling and warpping in the homography matrix (probably because of some points, that where assigned wrong) and the placing accuracy was quite bad.

I tried this once with the demo of the commercial image processing software Halcon and it worked like a charm in sub pixel accuracy. There you can do some sort of least square fit of a template to the image you are searching the object in. The result is an affine transform matrix and very precise.

Is there something comparable in EmguCV/OpenCV?

Thank you in advance!

Edit:

Found the solution in EmguCV in the function

CameraCalibration.EstimateRigidTransform(PointF[] src, PointF[] dest, bool fullAffine);

with fullAffine set to false. My problem before was, that I was using

Features2DToolbox.GetHomographyMatrixFromMatchedFeatures();

from the matching example.

Was it helpful?

Solution

Found the solution in EmguCV in the function

CameraCalibration.EstimateRigidTransform(PointF[] src, PointF[] dest, bool fullAffine);

with fullAffine set to false. My problem before was, that I was using

Features2DToolbox.GetHomographyMatrixFromMatchedFeatures();

from the matching example.

The only problem left was the small scaling still produced by EstimateRigidTransform, but I was able to calculate it out of the result.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top