我已将以下 OpenVx Sobel 立即代码转换为基于 Graph 的 . 但是做的结果匹配。
立即代码工作正常,它给出了正确的结果。而图形代码比单个图像的立即代码花费“更长的时间”并且也会产生错误的结果。
那么我的转换正确吗?
立即代码:
/* Intermediate images. */
vx_image dx = vxCreateImage(context, width, height, VX_DF_IMAGE_S16);
vx_image dy = vxCreateImage(context, width, height, VX_DF_IMAGE_S16);
vx_image mag = vxCreateImage(context, width, height, VX_DF_IMAGE_S16);
/* Perform Sobel convolution. */
if (vxuSobel3x3(context,image,dx, dy)!=VX_SUCCESS)
{
printf("ERROR: failed to do sobel!\n");
}
/* Calculate magnitude from gradients. */
if (vxuMagnitude(context,dx,dy,mag)!=VX_SUCCESS)
{
printf("ERROR: failed to do magnitude!\n");
}
//Convert result back to U8 image.
if (vxuConvertDepth(context,mag,image,VX_CONVERT_POLICY_WRAP,0)!=VX_SUCCESS)
{
printf("ERROR: failed to do color convert!\n");
}
上述即时代码的基于图形的代码
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 );
if(vxSobel3x3Node(graph,image,intermediate1,intermediate2) == 0)
{
printf("FAILED TO Create 1 graph node");
}
if(vxMagnitudeNode(graph,intermediate1,intermediate2,intermediate3) == 0)
{
printf("ERROR: failed to do magnitude!\n");
}
if(vxConvertDepthNode(graph,intermediate3,image,VX_CONVERT_POLICY_WRAP,0) == 0)
{
printf("ERROR failed to do color convert");
}
vxVerifyGraph( graph );
vxProcessGraph( graph ); // run in a loop