# Visionworks Motion estimator . Extract motion fields

Hi,

I am trying to extract the motion field from the vision work example, i saw the post here Visionworks Motion Fields Extract but i still do not understand how to get the motion field.

The mfOutROI_ is a vx_image with type NVX_DF_IMAGE2F32, this means there are two channels.

What is the meaning of each channel?

In the previous post the moderator said " that value(x, y) is the motion of the point (x, y)", but i do not understand what this means.

I understand the concept explained

More precisely, for point(x, y) with field value(mx, my) in frame N. The matched point in the frame N-1 is (x+mx, y+my).

but i could not match the result i get in the vx_image mfOutROI_ with these parameters.

Can someone with me an example of the values of each channel of vx_image mfOutROI_ for a simple case. Something like… one frame has one pixel at x = 0 and y = 0, then this pixels moves towards x direction until position x = 2, y = 0.

Many thanks
Victor

After some research i found the meaning. I write the solution in case is useful for someone else:

Here my understanding using cv::Mat

``````// get the motion in vx_image format
vx_image MotionImage = ime.getMotionField();

//convert to cv::Mat (or GpuMat as you like...)
nvx_cv::VXImageToCVMatMapper map(MotionImage);
//cv::cuda::GpuMat MotionImageGpuMat = map.getGpuMat();
cv::Mat MotionImageMatMap = map.getMat();

//resize the motion map as it is the half of the original image used to compute the motion
cv::Mat MotionImageMat;
cv::resize(MotionImageMatMap,MotionImageMat,cv::Size(),2.0,2.0,cv::INTER_NEAREST);

//split in two channels
cv::Mat MotionImageMat_split;
cv::split(MotionImageMat, MotionImageMat_split);

//MotionImageMat_split(x,y) -> contains the increment for the pixel (x,y) in width (columns) direction between the current and previous frame.
//   Example: if MotionImageMat_split at pixel (x,y) is 5 means that the difference between the current and previous frame in the width (columns) direction is 5

//MotionImageMat_split(x,y) -> contains the increment for the pixel (x,y) in height (rows) direction between the current and previous frame.
//   Example: if MotionImageMat_split at pixel (x,y) is 5 means that the difference between the current and previous frame in the height (rows) direction is 5
``````

Good, thanks for your sharing to community!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.