visionworks-1.6 vxOpticalFlowPyrLKNode issue

vx_node VX_API_CALL vxOpticalFlowPyrLKNode (vx_graph graph,
vx_pyramid old_images,
vx_pyramid new_images,
vx_array old_points,
vx_array new_points_estimates,
vx_array new_points,
vx_enum termination,
vx_scalar epsilon,
vx_scalar num_iterations,
vx_scalar use_initial_estimate,
vx_size window_dimension
)

void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg,
InputArray prevPts, InputOutputArray nextPts,
OutputArray status, OutputArray err,
Size winSize = Size(21,21), int maxLevel = 3,
TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01),
int flags = 0, double minEigThreshold = 1e-4 );

What is the difference between vxOpticalFlowPyrLKNode and cv::calcOpticalFlowPyrLK? There is no status output in the vxOpticalFlowPyrLKNode, and there is a status output in the calcOpticalFlowPyrLK api.When I use vxOpticalFlowPyrLKNode, how do I cull the feature points that failed to track?

Hi,

VisionWorks provide two execution models: Graph based execution and Immediate execution.
vxOpticalFlowPyrLKNode is an API of graph mode, which indicates the pipeline is pre-built and reused for each frame.

For graph mode, the verification is done in the initial time with this function:

// Graph verification
// Note: This verification is mandatory prior to graph execution
//
NVXIO_SAFE_CALL(vxVerifyGraph(main_graph_));

Please check our document for the detail usage of graph mode:
[i]>> VisionWorks API

Tutorials
VisionWorks Quick Start (Graph Mode)[/i]

Thanks.

Hi,AastaLLL,thank you for your reply!
When I use calcOpticalFlowPyrLK API, I can do the following things through the status parameter.

calcOpticalFlowPyrLK(prevGray, gray, points[0], points[1], status, err, winSize,3, termcrit, 0, 0.001);
size_t i, k;
for( i = k = 0; i < points[1].size(); i++ )
{
if( !status[i] )
continue;

     points[1][k++] = points[1][i];
  }

If I use vxOpticalFlowPyrLKNode API, how can I do the above? There is no status parameter output in the vxOpticalFlowPyrLKNode, I check the documentation for the visionworks api and didn’t find a solution.

Hi,

vxOpticalFlowPyrLKNode is an API for the graph mode, which means that the whole pipeline is prebuilt in the initial time.
You can get the status of whole pipeline from NVXIO_SAFE_CALL(vxVerifyGraph(main_graph_)).

If you want the status information each time, it’s recommended to use our immediate mode.
The API you are finding should be vxuOpticalFlowPyrLK, which return vx_status each time.

<b>vx_status </b>VX_API_CALL vxuOpticalFlowPyrLK  ( vx_context  	context,
		                             vx_pyramid  	old_images,
		                             vx_pyramid  	new_images,
		                             vx_array  	        old_points,
		                             vx_array  	        new_points_estimates,
		                             vx_array  	        new_points,
		                             vx_enum  	        termination,
		                             vx_scalar  	epsilon,
		                             vx_scalar  	num_iterations,
		                             vx_scalar  	use_initial_estimate,
		                             vx_size  	        window_dimension 
)

Thanks.

Hi,AastaLLL,thank you for your reply!

Maybe you didn’t understand my problem. In the calcOpticalFlowPyrLK api, the status is a vector type with the same size as the new points, each element of the vector is set to 1 if the flow for the corresponding features has been found, otherwise, it is set to 0. I can cull the points that failed to track in the new_points through the output value of status.

But in vxuOpticalFlowPyrLK/vxOpticalFlowPyrLKNode api, I didn’t find a similar vector output. The status you mentioned above means the execution status of the vxuOpticalFlowPyrLK function.

Hi,

Please correct me if I’m not understand your problem correctly.

vxuOpticalFlowPyrLK handle feature points array in a different way from the OpenCV.
All the data points in the new_points is matched, which means that the array is re-created with the valid matching only.
So it’s expected that the array size of new_points won’t be identical to the old_points.

Thanks.