Ask Your Question

Restrict flow field to horizontal disparity

asked 2016-07-20 18:17:30 -0500

emiswelt gravatar image


I was wondering if any of the flow field implementations in OpenCV can be restricted to only allow disparity along the horizontal axis.

Background: I know which linear movements are occurring and I only want to measure disparity along this axis.

If not, any hints on how such a feature could be implemented would be highly appreciate.

edit retag flag offensive close merge delete


Well, you can simply ignore the y components. With farneback, just split the flow matrix into two channels and drop the second.

Tetragramm gravatar imageTetragramm ( 2016-07-20 23:08:04 -0500 )edit

Thanks for your comment, but that does not work. For diagonal edges in the image, a diagonal flow might be detected. Dropping the Y component will just give an X component that's too short.

emiswelt gravatar imageemiswelt ( 2016-07-21 02:04:03 -0500 )edit

Well, you can try limiting the ROI to a small vertical amount and just processing the image in horizontal stripes. Might work.

If it doesn't, you can probably alter the methods yourself to ignore any y displacement. That's harder.

Tetragramm gravatar imageTetragramm ( 2016-07-21 07:44:44 -0500 )edit

ROI limiting does not work. The flow algorithms implemented in OpenCV require some margin along the image borders.

It should be possible to adjust the Gunnar Farneback Algorithm quite simply - the equation that finds the displacement from the calculated polynomials can be modified to solve along any given dimension. However I've found another approach, thus I don't need the modification anymore.

emiswelt gravatar imageemiswelt ( 2016-08-10 05:17:45 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2016-08-10 05:21:15 -0500

emiswelt gravatar image

It should be quite doable to modify the Gunnar Farnebäck algorithm implemented in OpenCV to find flows along a fixed axis. The equation that finds the displacement from the calculated polynomials can be changed to solve along any given dimension.

Please have a look at the paper for reference:

Sadly, the OpenCV implementation has virtually no comments, thus I'm not able to identify the corresponding lines in the code quickly.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-07-20 18:17:30 -0500

Seen: 165 times

Last updated: Aug 10 '16