calcGlobalOrientation: problem with thin objects (e.g. a rod)

asked 2013-07-22 03:49:42 -0500

Alessio B gravatar image

updated 2013-07-22 04:01:13 -0500

Hi everyone,

I would like to pose a problem regarding the function calcGlobalOrientation when used with the Motion Template technique.

It seems that once the MHI's gradient is computed, calcGlobalOrientation fails to detect the correct direction of motion when an object has an aspect ratio far from 1. For instance, if you move a rod up and down, its global orientation tends to be normal to the longest edge.

Consider, for instance, this poster box:

image description

In the following screenshot, the MHI and the computed orientation of the box moving downwards are shown. As you can see, calcGlobalOrientation determines an angle close to 0, probably also due to the fact that there is a slight horizontal motion.

MHI and global orientation

When used with objects having an aspect ratio close to 1, calcGlobalOrientation works very well.

I believe that we should take into account this and re-design the computation of the global orientation otherwise the estimated motion orientation is not reliable. I experienced the same problems with other objects (e.g. violin bows).

Thanks in advance

Alessio

edit retag flag offensive close merge delete

Comments

A nice remark! I would suggest you, if interested, to look at the sourcecode and try to find a solution to your problem. Once you have found a patch to change it, you could submit it as a pull request for the source code. More information on : http://code.opencv.org/projects/opencv/wiki/How_to_contribute

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-22 04:20:51 -0500 )edit

Maybe before looking at the source code, I'd better to try with a workaround. I was thinking that given the angle measured by calcGlobalOrientation, I can go back to the y/x gradient ratio and apply a correcting factor using the bounding box aspect ratio. After that, I compute the angle and this might be a better estimation. When the aspect ratio is close to 1, the estimation doesn't change. But I fear that I also have to take into account whether the estimated orientation is normal to the longest edge (which might be tricky). The fact is that calcGlobalOrientation doesn't take into account the length of the trails in the MHIs. I'd like to share some thoughts with the authors of the function, hope that this post will be seen by them.

Alessio B gravatar imageAlessio B ( 2013-07-22 04:35:33 -0500 )edit