I have converted the following OpenVx Sobel immediate code to Graph based . But the results done match.
Immediate code works fine, it gives proper result. Whereas Graph code takes "longer" than the immediate code for a single image and produces wrong results too.
So is my conversion correct ?
Immediate Code :
/* 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");
}
Graph based code of the above immediate code
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