I am trying to extract the motion field from the visionworks example. i saw the post in the nvidia forum here but i still do not understand how to get the motion field.
The documentation says that the motion fiels is a vx_image with type NVX_DF_IMAGE2F32, this means there are two channels.
Someone know the meaning of each channel? I even realize that the size of the image is the half of the input images used to detect the movement.
In the nvidia 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 with these parameters.
After some research i found the meaning. I write the solution in case is useful for someone else:
Here my understanding using cv::Mat that can be easily used to draw the result.
// 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[2];
cv::split(MotionImageMat, MotionImageMat_split);
//MotionImageMat_split[0](x,y) -> contains the increment for the pixel (x,y) in width (columns) direction between the current and previous frame.
// Example: if MotionImageMat_split[0] 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[1](x,y) -> contains the increment for the pixel (x,y) in height (rows) direction between the current and previous frame.
// Example: if MotionImageMat_split[0] at pixel (x,y) is 5 means that the difference between the current and previous frame in the height (rows) direction is 5