Facing issues while setting the graph parameters

Hi all,

I am new to OpenVX.

Issue:
I am facing problems in setting the graph parameters with the reference to the created graph.

My implimentation:
I am feeding the stream of frames from another application to my OpenVX graph. My graph just applies sobel3x3 filter on the input image. The output image from the graph will be dumped into a file or displayed on the screen.

Code:
/* function to create input image from the frame data received by other application */

vx_image create_image(frame_data_from_other_app_to_create_image)
{
[…]
vx_image image = vxCreateImageFromHandle(
context,
VX_DF_IMAGE_UYVY,
addrs,
data,
VX_IMPORT_TYPE_HOST);
[…]

return image;
}
/* function to create the graph */
vx_graph create_graph(vx_context context, vx_image input_img, vx_image output_img)
{
[…]
vx_node node[] = {
vxChannelExtractNode(graph, input_img, VX_CHANNEL_Y, virt_image[0]),
vxSobel3x3Node(graph, virt_image[0], virt_image[1], virt_image[2]),
vxMagnitudeNode(graph, virt_image[1], virt_image[2], virt_image[3]),
vxConvertDepthNode(graph, virt_image[3], output_img, VX_CONVERT_POLICY_WRAP, shift),
};

            vxAddParameterToGraphByIndex(graph, node[0], 0); //input
            vxAddParameterToGraphByIndex(graph, node[3], 1); //output

[…]
return graph;
}

/* function where we can access the incoming frame buffer (640x480) from another application */

func (frame_data_from_the_stream_640x480) // This function is invoked whenever there is new input frame from the other application. All the incoming frames are 640x480, UYVY color format
{
[…]
vx_image input = create_images(frame_data_to_create_image);
vx_image output = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);

/* I want to create the graph only once and make use of it */
if(g_flag != TRUE) // g_flag will be initialized to FALSE when the application starts
{
vx_graph graph = create_graph(context, input, output);
g_flag = TRUE;
}

    if(vxSetGraphParameterByIndex(graph, 0, (vx_reference)input) != VX_SUCCESS)
    {
            //handle error
    }
    if(vxSetGraphParameterByIndex(graph, 1, (vx_reference)output) != VX_SUCCESS)
    {
            //handle error
    }

    if(vxProcessGraph(graph) != VX_SUCCESS)
    {
            //handle error
    }

[…]
}

Observation:

  1. When I try to access the data from the output image, there is no data in it, only the first output image will have graph processed data, rest all will have black pixels.
  2. I am not getting any error from vxSetGraphParameterByIndex(), vxAddParameterToGraphByIndex(), vxVerifyGraph() and vxProcessgraph() functions.
  3. The input image which will be fed to the graph is being created properly, I tried displaying the created input images on the screen and it works fine.
  4. If I release the graph and create it again for each incoming frame, everything works perfectly fine. But, I don’t want to do this.

My question:

  1. Am I setting the graph parameters properly?
  2. Any solutions or workarounds to solve this issue?

I am stuck with this issue from past 3 days, please help me.

Thanks in advance.

Kiran

You may have found a bug in the implementation. You should not have to release the graph and recreate it to change the input image data, or the the input image (it may require re-verification, I don’t remember). If you just
1.) vxProcessGraph();
2.) dump the output image.
3.) clear the output image
4.) goto #1

Will you get the same output every time? Don’t change the input image in this test. You should get the same output image each time. Externally mapped memory maybe being transferred to another vx_image internally. You can check the CPU side pointer when you use a vxAccess against the pointer you gave it when you created the memory. If that’s happening, you may need to:
1.) recreate the vx_image from external handle.
2.) Set it to graph parameter
3.) Test for vxVerify needing to run, and run if needed (vxVerifygraph may do that internally)
4.) vxProcesGraph

Test to see if that works.

Thank you very much for your reply. I used vxAccess/vxCommit in between graph executions to solve this issue.

I faced issue using VX_IMPORT_TYPE_HOST and replaced with VX_MEMORY_TYPE_HOST which works for me. You might need a re-check here.

Also, you need to call create_images() for output to access data directly.