给定上一个问题中的示例代码(为简洁起见,删除了错误检查):
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 );
以及经典的 OpenCV 阅读视频循环:
cv::VideoCapture cap;
cap.open("/Testing/test.avi");
for(;;)
{
cv::Mat frame;
cap >> frame;
if( frame.empty() ) break;
// TODO: what goes here?
vxProcessGraph( graph );
}
如何frame
进入inputImage
以便我可以vxProcessGraph()
正确调用?我知道:
vx_image image = nvx_cv::createVXImageFromCVMat(frame);
是获得 a 的帮手vx_image
,但我似乎找不到下一步该做什么的例子。我读过的一些 NVidia 文档建议:
vxAccessImagePatch(...);
// copy pixel-by-pixel??
vxCommitImagePatch(...);
但是,这似乎有点太蛮力了,所以有没有更好的方法(vxSetParameter
也许,但文档很不清楚)来做到这一点?