Given sample code like in this previous question (error checking deleted for brevity):
vx_image inputImage = vxCreateImage( graph, width, height, VX_DF_IMAGE_S16 );
vx_image outputImage = vxCreateImage( graph, width, height, VX_DF_IMAGE_S16 );
vx_graph graph = vxCreateGraph( context );
vx_image intermediate1 = vxCreateVirtualImage( graph, width, height, VX_DF_IMAGE_S16 );
vx_image intermediate2 = vxCreateVirtualImage( graph, width, height, VX_DF_IMAGE_S16 );
vx_image intermediate3 = vxCreateVirtualImage( graph, width, height, VX_DF_IMAGE_S16 );
vxSobel3x3Node(graph,inputImage,intermediate1,intermediate2);
vxMagnitudeNode(graph,intermediate1,intermediate2,intermediate3);
vxConvertDepthNode(graph,intermediate3,outputImage,VX_CONVERT_POLICY_WRAP,0);
vxVerifyGraph( graph );
vxProcessGraph( graph );
And the classic OpenCV reading video loop:
cv::VideoCapture cap;
cap.open("/Testing/test.avi");
for(;;)
{
cv::Mat frame;
cap >> frame;
if( frame.empty() ) break;
// TODO: what goes here?
vxProcessGraph( graph );
}
How do I get the frame
into the inputImage
so I can call vxProcessGraph()
correctly? I know that:
vx_image image = nvx_cv::createVXImageFromCVMat(frame);
Is a helper for getting a vx_image
, but I cannot seem to find an example of what to do next. Some NVidia documentation I read suggested:
vxAccessImagePatch(...);
// copy pixel-by-pixel??
vxCommitImagePatch(...);
However, this seems a bit too brute-force-like, so is there some nicer way (vxSetParameter
, perhaps, but the documentation is very unclear) to do this?