This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OpenVX: tivxVpacLdcNode : tivxCreateNodeByKernelName

Hi TI,

I am new to OpenVX and trying to utilize the tivxVpacLdcNode in order convert the image into Bird Eye view.  As per my understanding, it's the TI defined API so it doesn't require the user kernel definition. In order to use this API, I created input and output images, generated the defined the homogaphy matrix and inserted into this node somehow like this 

tivxVpacLdcNode(graph, NULL, perspect_matrix,
NULL, NULL,
NULL, NULL, in_image,
out_image, NULL);

However, it generates the error: tivxCreateNodeByKernelName: Call to vxGetKernelByName failed; kernel may not be registered. Do I have to create the kernel, how to achieve it ? Thank you.

With best regards,

H.M.Owais

  • Hi Owais,

    Could you please mention the SDK version that you are using? It will help in determining next actions.

    Regards

    Karthik

  • Hi Karthik,

    I am currently using psdk_rtos_auto_j7_06_01_00_15 for my testing. Thank you.

    With best regards,

    H.M. Owais

  • Hi TI,

    Anyone would like to give an update on this matter? Thank you.

    With best regards,

    H.M. Owais

  • Your query is coming during the Christmas holiday season, which is the cause for the delay.  I hope you understand.

    The HWA kernels are loaded using the tivxHwaLoadKernels function.  In the demo apps in vision apps, this function is called from the main files.  Can you check if you have called this in your application?

    You may also need to check that your R5 image code contains registration function during initialization: tivxRegisterHwaTargetVpacLdcKernels(). In our demos, this is part of the common app_init.c file, if you are using that.

    Regards,

    Jesse

  • Hi Jesse,

    Thank you for your reply and sorry for forgetting about the Christmas Holidays. Wish you a Happy New Year and Happy Christmas Season.

    I have followed your suggestions: jumped from vxuWarpPerspective to tivxVpacLdcNode. Fixed all the necessary bugs which it was generating. However the result is still the same as it was given by the vxuWarpPerspective. I am unable to understand why I am getting such result. I need your help and valuable advice on this thing. Would you mind looking at the code and tell me where the problem can be?

    I have attached the file in which I used the sample code of vx_tutorial_graph_image_gradients and integrated my part tivxVpacLdcNode in it in order to test it. I added the registration functions and loaded and unloaded the kernels in order to remove the errors. The output is still the same as the previous. Looking forward to your response. Thank you.

    With best regards,

    H.M. Owais

    /*
    *
    * Copyright (c) 2017 Texas Instruments Incorporated
    *
    * All rights reserved not granted herein.
    *
    * Limited License.
    *
    * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
    * license under copyrights and patents it now or hereafter owns or controls to make,
    * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
    * terms herein.  With respect to the foregoing patent license, such license is granted
    * solely to the extent that any such patent is necessary to Utilize the software alone.
    * The patent license shall not apply to any combinations which include this software,
    * other than combinations with devices manufactured by or for TI ("TI Devices").
    * No hardware patent is licensed hereunder.
    *
    * Redistributions must preserve existing copyright notices and reproduce this license
    * (including the above copyright notice and the disclaimer and (if applicable) source
    * code license limitations below) in the documentation and/or other materials provided
    * with the distribution
    *
    * Redistribution and use in binary form, without modification, are permitted provided
    * that the following conditions are met:
    *
    * *       No reverse engineering, decompilation, or disassembly of this software is
    * permitted with respect to any software provided in binary form.
    *
    * *       any redistribution and use are licensed by TI for use only with TI Devices.
    *
    * *       Nothing shall obligate TI to provide you with source code for the software
    * licensed and provided to you in object code.
    *
    * If software source code is provided to you, modification and redistribution of the
    * source code are permitted provided that the following conditions are met:
    *
    * *       any redistribution and use of the source code, including any resulting derivative
    * works, are licensed by TI for use only with TI Devices.
    *
    * *       any redistribution and use of any object code compiled from the source code
    * and any resulting derivative works, are licensed by TI for use only with TI Devices.
    *
    * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
    *
    * may be used to endorse or promote products derived from this software without
    * specific prior written permission.
    *
    * DISCLAIMER.
    *
    * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
    * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
    * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    * OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */
    
    
    
    /**
     * \file vx_tutorial_graph_image_gradients.c Performs a Sobel filter followed by a magnitude node
     * and phase node on the X and Y outputs of the Sobel filter.
     *
     * In this tutorial we learn the below concepts,
     *
     * - How to create OpenVX context, OpenVX image data object and OpenVX virtual image data object
     * - How to read a BMP file and load the pixel values into the image data object
     * - How to query the image data object for attributes like width, height
     * - How to create OpenVX node and associate it with previously created graph
     * - How to choose a CPU core for an OpenVX to execute on
     * - How to schedule OpenVX graph for execution then execute the graph
     * - How to query the node data object for attributes like width, height
     * - How to query the graph data object for attributes like number of nodes and parameters
     * - How to read pixel values from an image data object and save it as a BMP file
     * - How to cleanup all created resources and exit the OpenVX application
     *
     * To include OpenVX interfaces include below file
     * \code
     * #include <VX/vx.h>
     * \endcode
     *
     * Follow the comments in the function vx_tutorial_graph_image_gradients()
     * to understand this tutorial
     *
     */
    
    
    #include <stdio.h>
    #include <VX/vx.h>
    #include <TI/tivx.h>
    #include <utility.h>
    #include <TI/j7_vpac_ldc.h>
    #include <TI/j7_kernels.h>
    #include <TI/tivx_target_kernel.h>
    
    
    /** \brief Input file name */
    #define IN_FILE_NAME         "convert1.bmp"
    
    /** \brief Phase file name */
    #define PHASE_FILE_NAME      "vx_tutorial_graph_image_gradients_phase_out.bmp"
    
    /** \brief Magnitude file name */
    #define MAGNITUDE_FILE_NAME  "vx_tutorial_graph_image_gradients_magnitude_out.bmp"
    
    /** \brief Gradient X file name */
    #define GRAD_X_FILE_NAME     "vx_tutorial_graph_image_gradients_grad_x_out.bmp"
    
    /** \brief Gradient Y file name */
    #define GRAD_Y_FILE_NAME     "vx_tutorial_graph_image_gradients_grad_y_out.bmp"
    
    #define NUM_NODES    (7u)
    
    /**
     * \brief Tutorial Entry Point
     */
    void vx_warp_test()
    {
        /**
         * - Define objects that we wish to create in the OpenVX application.
         *
         * A vx_context object is defined which is used as input parameter for all subesquent
         * OpenVX object create APIs
         * \code
         */
        vx_context context;
        vx_image in_image = NULL;
        vx_image grad_x = NULL;
        vx_image grad_y = NULL;
        vx_image magnitude = NULL;
        vx_image phase = NULL;
        vx_image magnitude_image = NULL;
        vx_image grad_x_image = NULL;
        vx_image grad_y_image = NULL;
        vx_graph graph = NULL;
        vx_scalar shift = NULL;
        vx_node node[NUM_NODES] = {NULL};
        /** \endcode */
        int32_t shift_value = 0;
        vx_uint32 width, height;
        vx_status status;
        uint32_t i;
    
        vx_image out_image = NULL;
    
        // vx_user_data_object ldc_in_config;
        // tivx_vpac_ldc_params_t  ldcPrms;
    
    
        // ldcPrms.luma_interpolation_type = 1; //BILINEAR
        // ldcPrms.input_align_12bit = 0;
        // ldcPrms.yc_mode = 0;
        // ldcPrms.init_x = 0;
        // ldcPrms.init_y = 0;
    
        // tivxRegisterHwaTargetVpacLdcKernels();
    
        printf(" vx_tutorial_graph_image_gradients: Tutorial Started !!! \n");
    
        /**
         * - Create OpenVX context.
         *
         * This MUST be done first before any OpenVX API call.
         * The context that is returned is used as input for subsequent OpenVX APIs
         * \code
         */
        context = vxCreateContext();
        /** \endcode */
    
        printf(" Loading file %s ...\n", IN_FILE_NAME);
    
    
    //    ldc_in_config = vxCreateUserDataObject(context, "tivx_vpac_ldc_params_t", sizeof(tivx_vpac_ldc_params_t), &ldcPrms);
    //    tivxHwaLoadKernels(context);
    
        /**
         * - Create image object.
         *
         * Follow the comments in create_image_from_file() to see
         * how a vx_image object is created and filled with RGB data from BMP file \ref IN_FILE_NAME
         * \code
         */
        in_image = create_image_from_file(context, IN_FILE_NAME, vx_true_e);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)in_image, "INPUT");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(in_image);
        /** \endcode */
    
        // ldc_in_config = vxCreateUserDataObject(context, "tivx_vpac_ldc_params_t", sizeof(tivx_vpac_ldc_params_t), &ldcPrms);
       // APP_ASSERT_VALID_REF(ldc_in_config);
    
        // vxSetReferenceName((vx_reference)ldc_in_config, "LDC_Config");
    
    
    
    
        vxQueryImage(in_image, VX_IMAGE_WIDTH, &width, sizeof(vx_uint32));
        vxQueryImage(in_image, VX_IMAGE_HEIGHT, &height, sizeof(vx_uint32));
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
    
        out_image = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)out_image, "output image");
         
        show_image_attributes(out_image);
        
    
        grad_x = vxCreateImage(context, width, height, VX_DF_IMAGE_S16);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)grad_x, "GRAD_X");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(out_image);
        show_image_attributes(grad_x);
        /** \endcode */
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
        grad_y = vxCreateImage(context, width, height, VX_DF_IMAGE_S16);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)grad_y, "GRAD_Y");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(grad_y);
        /** \endcode */
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
        magnitude = vxCreateImage(context, width, height, VX_DF_IMAGE_S16);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)magnitude, "MAGNITUDE");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(magnitude);
        /** \endcode */
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
        magnitude_image = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)magnitude_image, "MAGNITUDE_IMAGE");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(magnitude_image);
        /** \endcode */
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
        grad_x_image = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)grad_x_image, "GRAD_X_IMAGE");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(grad_x_image);
        /** \endcode */
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
        grad_y_image = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)grad_y_image, "GRAD_Y_IMAGE");
    
     
    
    
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(grad_y_image);
    
    
    
        /** \endcode */
    
        shift = vxCreateScalar(context, VX_TYPE_INT32, &shift_value);
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
        phase = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
        /** \endcode */
        vxSetReferenceName((vx_reference)phase, "PHASE");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(phase);
        /** \endcode */
    
        /**
         * - Create OpenVX graph.
         *
         * \code
         */
        graph = vxCreateGraph(context);
        /** \endcode */
        i = 0;
    
        /**
         * - Create OpenVX node object.
         *
         * Creates an OpenVX Sobel 3x3 node with in_image input
         * and grad_x and grad_y output.
         *
         * \code
         */
        node[i] = vxSobel3x3Node(graph, in_image, grad_x, grad_y);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)node[i], "SOBEL3x3");
    
        /**
         * - Set node target CPU.
         *
         * Sets target CPU for node[i] to DSP1
         * \code
         */
        vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        /** \endcode */
        i++;
    
        /**
         * - Create OpenVX node object.
         *
         * Creates an OpenVX Magnitude node with grad_x and grad_y input
         * and magnitude output.
         *
         * \code
         */
        node[i] = vxMagnitudeNode(graph, grad_x, grad_y, magnitude);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)node[i], "MAGNITUDE");
    
        /**
         * - Set node target CPU.
         *
         * Sets target CPU for node[i] to DSP1
         * \code
         */
        vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        /** \endcode */
        i++;
    
        /**
         * - Create OpenVX node object.
         *
         * Creates an OpenVX Phase node with grad_x and grad_y input
         * and phase output.
         *
         * \code
         */
        node[i] = vxPhaseNode(graph, grad_x, grad_y, phase);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)node[i], "PHASE");
        /**
         * - Set node target CPU.
         *
         * Sets target CPU for node[i] to DSP2
         * \code
         */
        if (vx_true_e == tivxIsTargetEnabled(TIVX_TARGET_DSP2))
        {
            vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP2);
        }
        else /* DSP2 is not present on some platforms, so changing target to DSP1 */
        {
            vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        }
        /** \endcode */
        i++;
    
        /**
         * - Create OpenVX node object.
         *
         * Creates an OpenVX Convert Depth node with magnitude input
         * and magnitude_image output. The conversion policy is Saturate
         * and the shift value is shift.
         *
         * \code
         */
        node[i] = vxConvertDepthNode(graph,
                        magnitude, magnitude_image,
                        VX_CONVERT_POLICY_SATURATE,
                        shift);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)node[i], "MAGNITUDE_IMAGE");
    
        /**
         * - Set node target CPU.
         *
         * Sets target CPU for node[i] to DSP1
         * \code
         */
        vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        /** \endcode */
    
        i++;
    
        /**
         * - Create OpenVX node object.
         *
         * Creates an OpenVX Convert Depth node with grad_x input
         * and grad_x_image output. The conversion policy is Saturate
         * and the shift value is shift.
         *
         * \code
         */
        node[i] = vxConvertDepthNode(graph,
                        grad_x, grad_x_image,
                        VX_CONVERT_POLICY_SATURATE,
                        shift);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)node[i], "GRAD_X_IMAGE");
    
        /**
         * - Set node target CPU.
         *
         * Sets target CPU for node[i] to DSP1
         * \code
         */
        vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        /** \endcode */
    
        i++;
    
    
    
        // vx_float32 mat[3][3] = {
        // {-7.24049501, 30.12009190, 2963.73020}, // ’x’ coefficients
        // {1.88882479, 83.56985830, 8572.522060}, // ’y’ coefficients
        // {0.00314804131, -0.0978822762, 1}, // ’offsets’
        // };
    
    
    
    //     vx_float32 mat2[3][3] = {
    //    {-7.24049501, 1.88882479, 0.00314804131}, // ’x’ coefficients
    //    {-30.12009190, 83.56985830, -0.0978822762}, // ’y’ coefficients
    //    {2963.73020, 8772.522060, 1}, // ’offsets’
    //    };
    
    
         vx_float32 mat3[9];
    
        mat3[0] = -7.24049501;
        mat3[1] = 1.88882479;
        mat3[2] = 0.00314804131;
        mat3[3] =-30.12009190;
        mat3[4] =-83.56985830;
        mat3[5] =-0.0978822762;
        mat3[6] = 2963.73020;
        mat3[7] = 8572.522060;
        mat3[8] = 1;
    
        // Create vx_matrix object
        vx_matrix matrix = vxCreateMatrix(context, VX_TYPE_FLOAT32,3,3);
    
        // Set pointer reference between vx_float32 data object and
        vxCopyMatrix(matrix, mat3, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
    
    
        // node[i] =  tivxVpacLdcNode(graph, ldc_in_config, matrix,
        //                 NULL, NULL,
        //                 NULL, NULL, in_image,
        //                 out_image, NULL);
    
    
        node[i] = vxWarpPerspectiveNode (graph, in_image, matrix, VX_INTERPOLATION_BILINEAR , out_image);
        
    
        vxSetReferenceName((vx_reference)node[i], "Perspective IMAGE");
    
    
        //vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
    
        i++;
    
        /**
         * - Create OpenVX node object.
         *
         * Creates an OpenVX Convert Depth node with grad_y input
         * and grad_y_image output. The conversion policy is Saturate
         * and the shift value is shift.
         *
         * \code
         */
    
    
    
        node[i] = vxConvertDepthNode(graph,
                        grad_y, grad_y_image,
                        VX_CONVERT_POLICY_SATURATE,
                        shift);
        vxSetReferenceName((vx_reference)node[i], "GRAD_Y_IMAGE");
    
        /**
         * - Set node target CPU.
         *
         * Sets target CPU for node[i] to DSP2
         * \code
         */
        if (vx_true_e == tivxIsTargetEnabled(TIVX_TARGET_DSP2))
        {
            vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP2);
        }
        else /* DSP2 is not present on some platforms, so changing target to DSP1 */
        {
            vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        }
        /** \endcode */
    
        i++;
    
    
        /** \endcode */
    
        // vxSetReferenceName((vx_reference)node[i], "Perspective Image");
    
        // if (vx_true_e == tivxIsTargetEnabled(TIVX_TARGET_DSP2))
        // {
        //     vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP2);
        // }
        // else /* DSP2 is not present on some platforms, so changing target to DSP1 */
        // {
        //     vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        // }
    
        // i++;
    
        /**
         * - Verify graph object.
         *
         * Verifies that all parameters of graph object are valid.
         *
         * \code
         */
        status = vxVerifyGraph(graph);
        /** \endcode */
    
        /** export graph to dot file, which can be coverted to jpg using dot tool
         * \code
         */
        tivxExportGraphToDot(graph, ".", "vx_tutorial_graph_image_gradients");
        /** \endcode */
    
        /**
         * - Show graph attributes.
         *
         * Follow the comments in show_graph_attributes() to see
         * how graph attributes are queried and displayed.
         * \code
         */
        show_graph_attributes(graph);
        /** \endcode */
    
        for(i=0; i<sizeof(node)/sizeof(node[0]); i++)
        {
            if(node[i])
            {
               /**
                 * - Show node attributes.
                 *
                 * Follow the comments in show_node_attributes() to see
                 * how node attributes are queried and displayed.
                 * \code
                 */
                show_node_attributes(node[i]);
                /** \endcode */
            }
        }
    
        if(status==VX_SUCCESS)
        {
            printf(" Executing graph ...\n");
    
            /**
             * - Schedule graph.
             *
             * Schedules graph for future execution. vxVerifyGraph must return VX_SUCCESS
             * before this function will pass.
             *
             * \code
             */
            vxScheduleGraph(graph);
            /** \endcode */
            /**
             * - Wait graph.
             *
             * Waits for graph to complete.
             *
             * \code
             */
            vxWaitGraph(graph);
            /** \endcode */
    
            printf(" Executing graph ... Done !!!\n");
    
           /**
             * - Show graph attributes.
             *
             * Follow the comments in show_graph_attributes() to see
             * how graph attributes are queried and displayed.
             * \code
             */
            show_graph_attributes(graph);
            /** \endcode */
            for(i=0; i<sizeof(node)/sizeof(node[0]); i++)
            {
                if(node[i])
                {
                   /**
                     * - Show node attributes.
                     *
                     * Follow the comments in show_node_attributes() to see
                     * how node attributes are queried and displayed.
                     * \code
                     */
                    show_node_attributes(node[i]);
                    /** \endcode */
                }
            }
    
            printf(" Saving to file %s ...\n", PHASE_FILE_NAME);
            /**
             * - Save image object to bitmap file \ref OUT_FILE_NAME.
             *
             * Follow the comments in save_image_to_file() to see
             * how data in vx_image object is accessed to store pixel values from the image object to
             * BMP file \ref OUT_FILE_NAME
             * \code
             */
            save_image_to_file(PHASE_FILE_NAME, phase);
            /** \endcode */
    
            printf(" Saving to file %s ...\n", MAGNITUDE_FILE_NAME);
            /**
             * - Save image object to bitmap file \ref OUT_FILE_NAME.
             *
             * Follow the comments in save_image_to_file() to see
             * how data in vx_image object is accessed to store pixel values from the image object to
             * BMP file \ref OUT_FILE_NAME
             * \code
             */
            save_image_to_file(MAGNITUDE_FILE_NAME, magnitude_image);
            /** \endcode */
    
            printf(" Saving to file %s ...\n", GRAD_X_FILE_NAME);
            /**
             * - Save image object to bitmap file \ref OUT_FILE_NAME.
             *
             * Follow the comments in save_image_to_file() to see
             * how data in vx_image object is accessed to store pixel values from the image object to
             * BMP file \ref OUT_FILE_NAME
             * \code
             */
            save_image_to_file(GRAD_X_FILE_NAME, grad_x_image);
            /** \endcode */
    
            printf(" Saving to file %s ...\n", GRAD_Y_FILE_NAME);
            /**
             * - Save image object to bitmap file \ref OUT_FILE_NAME.
             *
             * Follow the comments in save_image_to_file() to see
             * how data in vx_image object is accessed to store pixel values from the image object to
             * BMP file \ref OUT_FILE_NAME
             * \code
             */
            save_image_to_file(GRAD_Y_FILE_NAME, grad_y_image);
    
    
            save_image_to_file("output_perspective.bmp", out_image);
            /** \endcode */
        }
    
        /**
         * - Release image object.
         *
         * Since we are done with using this image object, release it
         * \code
         */
        // vxReleaseUserDataObject(&ldc_in_config);
        vxReleaseImage(&in_image);
        vxReleaseImage(&grad_x);
        vxReleaseImage(&grad_y);
        vxReleaseImage(&grad_x_image);
        vxReleaseImage(&grad_y_image);
        vxReleaseImage(&out_image);
        vxReleaseImage(&phase);
        vxReleaseImage(&magnitude);
        vxReleaseImage(&magnitude_image);
        vxReleaseMatrix(&matrix);
        /** \endcode */
    
        /**
         * - Release scalar object.
         *
         * Since we are done with using this scalar object, release it
         * \code
         */
        vxReleaseScalar(&shift);
        /** \endcode */
    
        for(i=0; i<sizeof(node)/sizeof(node[0]); i++)
        {
            if(node[i])
            {
               /**
                 * - Release node object.
                 *
                 * Since we are done with using this node object, release it
                 * \code
                 */
                vxReleaseNode(&node[i]);
                /** \endcode */
            }
        }
    
        /**
         * - Release graph object.
         *
         * Since we are done with using this graph object, release it
         * \code
         */
        vxReleaseGraph(&graph);
        /** \endcode */
    
        /**
         * - Release context object.
         *
         * Since we are done using OpenVX context, release it.
         * No further OpenVX API calls should be done, until a context is again created using
         * vxCreateContext()
         * \code
         */
        // tivxHwaUnLoadKernels(context);
    
        vxReleaseContext(&context);
        /** \endcode */
    
        printf(" vx_tutorial_graph_image_gradients: Tutorial Done !!! \n");
        printf(" \n");
    }
    

    tivxVpacLdcNode
  • Hello,

    I see that you have added the tivxHwaLoadKernels and tivxVpacLdcNode correctly.  I see that these have been commented out, but I assume that this was uncommented when you ran it.

    Please note that the tivxRegisterHwaTargetVpacLdcKernels must be called during R5 initialization.  If you are using the default vision apps remote core build, this is included in apps/basic_demos/app_tirtos/common/app_init.c.  Could you please confirm that this is the case?

    If this is the case, could you please send the full log of the failure?

    Regards,

    Lucas

  • Hi Lucas,

    I have followed the guidelines but I am keep on receiving this wrong output without any error. I have checked the code which seems to have no problem. Here is the log:

    vx_tutorial_graph_image_gradients: Tutorial Started !!!
    Loading file convert1.bmp ...
    VX_TYPE_IMAGE: INPUT, 640 x 480, 1 plane(s), 307200 B, VX_DF_IMAGE_U8 VX_COLOR_SPACE_NONE VX_CHANNEL_RANGE_FULL VX_MEMORY_TYPE_NONE, 1 refs
    VX_TYPE_IMAGE: output image, 640 x 480, 1 plane(s), 307200 B, VX_DF_IMAGE_U8 VX_COLOR_SPACE_NONE VX_CHANNEL_RANGE_FULL VX_MEMORY_TYPE_NONE, 1 refs
    VX_TYPE_IMAGE: output image, 640 x 480, 1 plane(s), 307200 B, VX_DF_IMAGE_U8 VX_COLOR_SPACE_NONE VX_CHANNEL_RANGE_FULL VX_MEMORY_TYPE_NONE, 1 refs
    VX_TYPE_IMAGE: GRAD_X, 640 x 480, 1 plane(s), 614400 B, VX_DF_IMAGE_S16 VX_COLOR_SPACE_NONE VX_CHANNEL_RANGE_FULL VX_MEMORY_TYPE_NONE, 1 refs
    VX_TYPE_IMAGE: GRAD_Y, 640 x 480, 1 plane(s), 614400 B, VX_DF_IMAGE_S16 VX_COLOR_SPACE_NONE VX_CHANNEL_RANGE_FULL VX_MEMORY_TYPE_NONE, 1 refs
    VX_TYPE_IMAGE: MAGNITUDE, 640 x 480, 1 plane(s), 614400 B, VX_DF_IMAGE_S16 VX_COLOR_SPACE_NONE VX_CHANNEL_RANGE_FULL VX_MEMORY_TYPE_NONE, 1 refs
    VX_TYPE_IMAGE: MAGNITUDE_IMAGE, 640 x 480, 1 plane(s), 307200 B, VX_DF_IMAGE_U8 VX_COLOR_SPACE_NONE VX_CHANNEL_RANGE_FULL VX_MEMORY_TYPE_NONE, 1 refs
    VX_TYPE_IMAGE: GRAD_X_IMAGE, 640 x 480, 1 plane(s), 307200 B, VX_DF_IMAGE_U8 VX_COLOR_SPACE_NONE VX_CHANNEL_RANGE_FULL VX_MEMORY_TYPE_NONE, 1 refs
    VX_TYPE_IMAGE: GRAD_Y_IMAGE, 640 x 480, 1 plane(s), 307200 B, VX_DF_IMAGE_U8 VX_COLOR_SPACE_NONE VX_CHANNEL_RANGE_FULL VX_MEMORY_TYPE_NONE, 1 refs
    VX_TYPE_IMAGE: PHASE, 640 x 480, 1 plane(s), 307200 B, VX_DF_IMAGE_U8 VX_COLOR_SPACE_NONE VX_CHANNEL_RANGE_FULL VX_MEMORY_TYPE_NONE, 1 refs
    VX_TYPE_GRAPH: graph_93, 7 nodes, VX_GRAPH_STATE_VERIFIED, avg perf 0.000000s, 0 parameters, 1 refs
    VX_TYPE_NODE: SOBEL3x3, 3 params, avg perf 0.000000s, VX_SUCCESS, 1 refs
    VX_TYPE_NODE: MAGNITUDE, 3 params, avg perf 0.000000s, VX_SUCCESS, 1 refs
    VX_TYPE_NODE: PHASE, 3 params, avg perf 0.000000s, VX_SUCCESS, 1 refs
    VX_TYPE_NODE: MAGNITUDE_IMAGE, 4 params, avg perf 0.000000s, VX_SUCCESS, 1 refs
    VX_TYPE_NODE: GRAD_X_IMAGE, 4 params, avg perf 0.000000s, VX_SUCCESS, 1 refs
    VX_TYPE_NODE: Perspective IMAGE, 9 params, avg perf 0.000000s, VX_SUCCESS, 1 refs
    VX_TYPE_NODE: GRAD_Y_IMAGE, 4 params, avg perf 0.000000s, VX_SUCCESS, 1 refs
    Executing graph ...
    Executing graph ... Done !!!
    VX_TYPE_GRAPH: graph_93, 7 nodes, VX_GRAPH_STATE_COMPLETED, avg perf 0.150405s, 0 parameters, 1 refs
    VX_TYPE_NODE: SOBEL3x3, 3 params, avg perf 0.083646s, VX_SUCCESS, 1 refs
    VX_TYPE_NODE: MAGNITUDE, 3 params, avg perf 0.017525s, VX_SUCCESS, 1 refs
    VX_TYPE_NODE: PHASE, 3 params, avg perf 0.015486s, VX_SUCCESS, 1 refs
    VX_TYPE_NODE: MAGNITUDE_IMAGE, 4 params, avg perf 0.002557s, VX_SUCCESS, 1 refs
    VX_TYPE_NODE: GRAD_X_IMAGE, 4 params, avg perf 0.027081s, VX_SUCCESS, 1 refs
    VX_TYPE_NODE: Perspective IMAGE, 9 params, avg perf 0.095664s, VX_SUCCESS, 1 refs
    VX_TYPE_NODE: GRAD_Y_IMAGE, 4 params, avg perf 0.004067s, VX_SUCCESS, 1 refs
    Saving to file vx_tutorial_graph_image_gradients_phase_out.bmp ...
    Saving to file vx_tutorial_graph_image_gradients_magnitude_out.bmp ...
    Saving to file vx_tutorial_graph_image_gradients_grad_x_out.bmp ...
    Saving to file vx_tutorial_graph_image_gradients_grad_y_out.bmp ...
    vx_tutorial_graph_image_gradients: Tutorial Done !!!

    the current running code: 

    /*
    *
    * Copyright (c) 2017 Texas Instruments Incorporated
    *
    * All rights reserved not granted herein.
    *
    * Limited License.
    *
    * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
    * license under copyrights and patents it now or hereafter owns or controls to make,
    * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
    * terms herein.  With respect to the foregoing patent license, such license is granted
    * solely to the extent that any such patent is necessary to Utilize the software alone.
    * The patent license shall not apply to any combinations which include this software,
    * other than combinations with devices manufactured by or for TI ("TI Devices").
    * No hardware patent is licensed hereunder.
    *
    * Redistributions must preserve existing copyright notices and reproduce this license
    * (including the above copyright notice and the disclaimer and (if applicable) source
    * code license limitations below) in the documentation and/or other materials provided
    * with the distribution
    *
    * Redistribution and use in binary form, without modification, are permitted provided
    * that the following conditions are met:
    *
    * *       No reverse engineering, decompilation, or disassembly of this software is
    * permitted with respect to any software provided in binary form.
    *
    * *       any redistribution and use are licensed by TI for use only with TI Devices.
    *
    * *       Nothing shall obligate TI to provide you with source code for the software
    * licensed and provided to you in object code.
    *
    * If software source code is provided to you, modification and redistribution of the
    * source code are permitted provided that the following conditions are met:
    *
    * *       any redistribution and use of the source code, including any resulting derivative
    * works, are licensed by TI for use only with TI Devices.
    *
    * *       any redistribution and use of any object code compiled from the source code
    * and any resulting derivative works, are licensed by TI for use only with TI Devices.
    *
    * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
    *
    * may be used to endorse or promote products derived from this software without
    * specific prior written permission.
    *
    * DISCLAIMER.
    *
    * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
    * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
    * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    * OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */
    
    
    
    /**
     * \file vx_tutorial_graph_image_gradients.c Performs a Sobel filter followed by a magnitude node
     * and phase node on the X and Y outputs of the Sobel filter.
     *
     * In this tutorial we learn the below concepts,
     *
     * - How to create OpenVX context, OpenVX image data object and OpenVX virtual image data object
     * - How to read a BMP file and load the pixel values into the image data object
     * - How to query the image data object for attributes like width, height
     * - How to create OpenVX node and associate it with previously created graph
     * - How to choose a CPU core for an OpenVX to execute on
     * - How to schedule OpenVX graph for execution then execute the graph
     * - How to query the node data object for attributes like width, height
     * - How to query the graph data object for attributes like number of nodes and parameters
     * - How to read pixel values from an image data object and save it as a BMP file
     * - How to cleanup all created resources and exit the OpenVX application
     *
     * To include OpenVX interfaces include below file
     * \code
     * #include <VX/vx.h>
     * \endcode
     *
     * Follow the comments in the function vx_tutorial_graph_image_gradients()
     * to understand this tutorial
     *
     */
    
    
    #include <stdio.h>
    #include <VX/vx.h>
    #include <TI/tivx.h>
    #include <utility.h>
    #include <TI/j7_kernels.h>
    #include <TI/tivx_target_kernel.h>
    #include <TI/j7.h>
    
    
    
    
    /** \brief Input file name */
    #define IN_FILE_NAME         "convert1.bmp"
    
    /** \brief Phase file name */
    #define PHASE_FILE_NAME      "vx_tutorial_graph_image_gradients_phase_out.bmp"
    
    /** \brief Magnitude file name */
    #define MAGNITUDE_FILE_NAME  "vx_tutorial_graph_image_gradients_magnitude_out.bmp"
    
    /** \brief Gradient X file name */
    #define GRAD_X_FILE_NAME     "vx_tutorial_graph_image_gradients_grad_x_out.bmp"
    
    /** \brief Gradient Y file name */
    #define GRAD_Y_FILE_NAME     "vx_tutorial_graph_image_gradients_grad_y_out.bmp"
    
    #define NUM_NODES    (7u)
    
    /**
     * \brief Tutorial Entry Point
     */
    void vx_warp_test()
    {
        /**
         * - Define objects that we wish to create in the OpenVX application.
         *
         * A vx_context object is defined which is used as input parameter for all subesquent
         * OpenVX object create APIs
         * \code
         */
        vx_context context;
        vx_image in_image = NULL;
        vx_image grad_x = NULL;
        vx_image grad_y = NULL;
        vx_image magnitude = NULL;
        vx_image phase = NULL;
        vx_image magnitude_image = NULL;
        vx_image grad_x_image = NULL;
        vx_image grad_y_image = NULL;
        vx_graph graph = NULL;
        vx_scalar shift = NULL;
        vx_node node[NUM_NODES] = {NULL};
        
        
        
        /** \endcode */
        int32_t shift_value = 0;
        vx_uint32 width, height;
        vx_status status;
        uint32_t i;
    
        vx_image out_image = NULL;
    
        vx_user_data_object ldc_in_config;
        tivx_vpac_ldc_params_t  ldcPrms;
    
        ldcPrms.luma_interpolation_type = 1; //BILINEAR
        ldcPrms.input_align_12bit = 0;
        ldcPrms.yc_mode = 0;
        ldcPrms.init_x = 0;
        ldcPrms.init_y = 0;
    
        //tivxRegisterHwaTargetVpacLdcKernels();
    
        printf(" vx_tutorial_graph_image_gradients: Tutorial Started !!! \n");
    
        /**
         * - Create OpenVX context.
         *
         * This MUST be done first before any OpenVX API call.
         * The context that is returned is used as input for subsequent OpenVX APIs
         * \code
         */
    
        context = vxCreateContext();
        /** \endcode */
    
        printf(" Loading file %s ...\n", IN_FILE_NAME);
    
        tivxHwaLoadKernels(context);
    
        ldc_in_config = vxCreateUserDataObject(context, "tivx_vpac_ldc_params_t", sizeof(tivx_vpac_ldc_params_t), &ldcPrms);
    
        /**
         * - Create image object.
         *
         * Follow the comments in create_image_from_file() to see
         * how a vx_image object is created and filled with RGB data from BMP file \ref IN_FILE_NAME
         * \code
         */
        in_image = create_image_from_file(context, IN_FILE_NAME, vx_true_e);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)in_image, "INPUT");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(in_image);
        /** \endcode */
    
        //ldc_in_config = vxCreateUserDataObject(context, "tivx_vpac_ldc_params_t", sizeof(tivx_vpac_ldc_params_t), &ldcPrms);
        //APP_ASSERT_VALID_REF(ldc_in_config);
    
        // vxSetReferenceName((vx_reference)ldc_in_config, "LDC_Config");
    
        vxQueryImage(in_image, VX_IMAGE_WIDTH, &width, sizeof(vx_uint32));
        vxQueryImage(in_image, VX_IMAGE_HEIGHT, &height, sizeof(vx_uint32));
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
    
        out_image = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)out_image, "output image");
         
        show_image_attributes(out_image);
    
        grad_x = vxCreateImage(context, width, height, VX_DF_IMAGE_S16);
        /** \endcode */
        vxSetReferenceName((vx_reference)grad_x, "GRAD_X");
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(out_image);
        show_image_attributes(grad_x);
        /** \endcode */
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
        grad_y = vxCreateImage(context, width, height, VX_DF_IMAGE_S16);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)grad_y, "GRAD_Y");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(grad_y);
        /** \endcode */
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
        magnitude = vxCreateImage(context, width, height, VX_DF_IMAGE_S16);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)magnitude, "MAGNITUDE");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(magnitude);
        /** \endcode */
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
        magnitude_image = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)magnitude_image, "MAGNITUDE_IMAGE");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(magnitude_image);
        /** \endcode */
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
    
        grad_x_image = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
        
        /** \endcode */
    
        vxSetReferenceName((vx_reference)grad_x_image, "GRAD_X_IMAGE");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        
        show_image_attributes(grad_x_image);
        
        /** \endcode */
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
    
        grad_y_image = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)grad_y_image, "GRAD_Y_IMAGE");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(grad_y_image);
    
    
    
        /** \endcode */
    
        shift = vxCreateScalar(context, VX_TYPE_INT32, &shift_value);
    
        /**
         * - Create OpenVX image object.
         *
         * Creates an OpenVX image object of 'width' x 'height' and having
         * data format 'df'.
         * \code
         */
        phase = vxCreateImage(context, width, height, VX_DF_IMAGE_U8);
        /** \endcode */
        vxSetReferenceName((vx_reference)phase, "PHASE");
    
        /**
         * - Show image attributes.
         *
         * Follow the comments in show_image_attributes() to see
         * how image attributes are queried and displayed.
         * \code
         */
        show_image_attributes(phase);
        /** \endcode */
    
        /**
         * - Create OpenVX graph.
         *
         * \code
         */
        graph = vxCreateGraph(context);
        /** \endcode */
        i = 0;
    
        /**
         * - Create OpenVX node object.
         *
         * Creates an OpenVX Sobel 3x3 node with in_image input
         * and grad_x and grad_y output.
         *
         * \code
         */
        node[i] = vxSobel3x3Node(graph, in_image, grad_x, grad_y);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)node[i], "SOBEL3x3");
    
        /**
         * - Set node target CPU.
         *
         * Sets target CPU for node[i] to DSP1
         * \code
         */
        vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        /** \endcode */
        i++;
    
        /**
         * - Create OpenVX node object.
         *
         * Creates an OpenVX Magnitude node with grad_x and grad_y input
         * and magnitude output.
         *
         * \code
         */
        node[i] = vxMagnitudeNode(graph, grad_x, grad_y, magnitude);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)node[i], "MAGNITUDE");
    
        /**
         * - Set node target CPU.
         *
         * Sets target CPU for node[i] to DSP1
         * \code
         */
        vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        /** \endcode */
        i++;
    
        /**
         * - Create OpenVX node object.
         *
         * Creates an OpenVX Phase node with grad_x and grad_y input
         * and phase output.
         *
         * \code
         */
        node[i] = vxPhaseNode(graph, grad_x, grad_y, phase);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)node[i], "PHASE");
        /**
         * - Set node target CPU.
         *
         * Sets target CPU for node[i] to DSP2
         * \code
         */
        if (vx_true_e == tivxIsTargetEnabled(TIVX_TARGET_DSP2))
        {
            vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP2);
        }
        else /* DSP2 is not present on some platforms, so changing target to DSP1 */
        {
            vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        }
        /** \endcode */
        i++;
    
        /**
         * - Create OpenVX node object.
         *
         * Creates an OpenVX Convert Depth node with magnitude input
         * and magnitude_image output. The conversion policy is Saturate
         * and the shift value is shift.
         *
         * \code
         */
        node[i] = vxConvertDepthNode(graph,
                        magnitude, magnitude_image,
                        VX_CONVERT_POLICY_SATURATE,
                        shift);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)node[i], "MAGNITUDE_IMAGE");
    
        /**
         * - Set node target CPU.
         *
         * Sets target CPU for node[i] to DSP1
         * \code
         */
        vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        /** \endcode */
    
        i++;
    
        /**
         * - Create OpenVX node object.
         *
         * Creates an OpenVX Convert Depth node with grad_x input
         * and grad_x_image output. The conversion policy is Saturate
         * and the shift value is shift.
         *
         * \code
         */
        node[i] = vxConvertDepthNode(graph,
                        grad_x, grad_x_image,
                        VX_CONVERT_POLICY_SATURATE,
                        shift);
        /** \endcode */
    
        vxSetReferenceName((vx_reference)node[i], "GRAD_X_IMAGE");
    
        /**
         * - Set node target CPU.
         *
         * Sets target CPU for node[i] to DSP1
         * \code
         */
        vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        /** \endcode */
    
        i++;
    
    
    
        // vx_float32 mat[3][3] = {
        // {-7.24049501, 30.12009190, 2963.73020}, // ’x’ coefficients
        // {1.88882479, 83.56985830, 8572.522060}, // ’y’ coefficients
        // {0.00314804131, -0.0978822762, 1}, // ’offsets’
        // };
    
    
    
    //     vx_float32 mat2[3][3] = {
    //    {-7.24049501, 1.88882479, 0.00314804131}, // ’x’ coefficients
    //    {-30.12009190, 83.56985830, -0.0978822762}, // ’y’ coefficients
    //    {2963.73020, 8772.522060, 1}, // ’offsets’
    //    };
    
    
        //  vx_float32 mat3[9];
    
        // mat3[0] = -7.24049501;
        // mat3[1] = 1.88882479;
        // mat3[2] = 0.00314804131;
        // mat3[3] =-30.12009190;
        // mat3[4] =-83.56985830;
        // mat3[5] =-0.0978822762;
        // mat3[6] = 2963.73020;
        // mat3[7] = 8572.522060;
        // mat3[8] = 1;
    
    
        vx_float32 mat4[9];
        mat4[0] = 1.17089046e+00;
        mat4[1]=  3.88644474e-02; 
        mat4[2]=  1.18129019e-04;
        mat4[3]= -3.92726471e-01;
        mat4[4] = -2.50316810e-02;  
        mat4[5]= -1.21383876e-03;
        mat4[6]= -2.50017978e+01; 
        mat4[7] = 1.04407238e+02;  
        mat4[8] = 1.00000000e+00;
    
        // vx_scalar type;
        // vx_reference parameters[2];
        // vx_enum type_scalar_type;
        // vx_enum type_scalar_val;
        // type = (vx_scalar)parameters[2];
    
        
    
        //vx_float32 *mat4 = (vx_float32 *)malloc(3*3*sizeof(vx_float32));
        //mat4[0][0] = -7.24049501;
        
      
    
        // Create vx_matrix object
        vx_matrix matrix = vxCreateMatrix(context, VX_TYPE_FLOAT32,3,3);
        // vx_enum matrix_type;
        // Set pointer reference between vx_float32 data object and
        vxCopyMatrix(matrix, mat4, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
    
    
    
            //    vx_int32 j2, i2;
            //         for (j2 = 0; j2 < (vx_int32)3; j2++)
            //         {for (i2 = 0; i2 < (vx_int32)3; i2++)
            //           {  printf("matrix value %d \n ", matrix[j2]);
            //          // printf("matrix value %d \n ", matrix[j2*3 + i2]);
            //           }
    
            //         }
    
        node[i] =  tivxVpacLdcNode(graph, ldc_in_config, matrix,
                        NULL, NULL,
                        NULL, NULL, in_image,
                        out_image, NULL);
    
       //node[i] = vxWarpPerspectiveNode (graph, in_image, matrix, VX_INTERPOLATION_BILINEAR , out_image);
    
        vxSetReferenceName((vx_reference)node[i], "Perspective IMAGE");
    
        // vxQueryMatrix 	(matrix,VX_MATRIX_ORIGIN ,&matrix_type,sizeof(matrix_type)); 
        // vxQueryScalar(type, VX_SCALAR_TYPE, &type_scalar_type, sizeof(type_scalar_type));
        //  vxCopyScalar(type, &type_scalar_val, VX_READ_ONLY, VX_MEMORY_TYPE_HOST);
    
    
        //vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
    
        i++;
    
        /**
         * - Create OpenVX node object.
         *
         * Creates an OpenVX Convert Depth node with grad_y input
         * and grad_y_image output. The conversion policy is Saturate
         * and the shift value is shift.
         *
         * \code
         */
    
    
    
        node[i] = vxConvertDepthNode(graph,
                        grad_y, grad_y_image,
                        VX_CONVERT_POLICY_SATURATE,
                        shift);
        vxSetReferenceName((vx_reference)node[i], "GRAD_Y_IMAGE");
    
        /**
         * - Set node target CPU.
         *
         * Sets target CPU for node[i] to DSP2
         * \code
         */
        if (vx_true_e == tivxIsTargetEnabled(TIVX_TARGET_DSP2))
        {
            vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP2);
        }
        else /* DSP2 is not present on some platforms, so changing target to DSP1 */
        {
            vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        }
        /** \endcode */
    
        i++;
    
    
        /** \endcode */
    
        // vxSetReferenceName((vx_reference)node[i], "Perspective Image");
    
        // if (vx_true_e == tivxIsTargetEnabled(TIVX_TARGET_DSP2))
        // {
        //     vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP2);
        // }
        // else /* DSP2 is not present on some platforms, so changing target to DSP1 */
        // {
        //     vxSetNodeTarget(node[i], VX_TARGET_STRING, TIVX_TARGET_DSP1);
        // }
    
        // i++;
    
        /**
         * - Verify graph object.
         *
         * Verifies that all parameters of graph object are valid.
         *
         * \code
         */
        status = vxVerifyGraph(graph);
        /** \endcode */
    
        /** export graph to dot file, which can be coverted to jpg using dot tool
         * \code
         */
        tivxExportGraphToDot(graph, ".", "vx_tutorial_graph_image_gradients");
        /** \endcode */
    
        /**
         * - Show graph attributes.
         *
         * Follow the comments in show_graph_attributes() to see
         * how graph attributes are queried and displayed.
         * \code
         */
        show_graph_attributes(graph);
        /** \endcode */
    
        for(i=0; i<sizeof(node)/sizeof(node[0]); i++)
        {
            if(node[i])
            {
               /**
                 * - Show node attributes.
                 *
                 * Follow the comments in show_node_attributes() to see
                 * how node attributes are queried and displayed.
                 * \code
                 */
                show_node_attributes(node[i]);
                /** \endcode */
            }
        }
    
        if(status==VX_SUCCESS)
        {
            printf(" Executing graph ...\n");
    
            /**
             * - Schedule graph.
             *
             * Schedules graph for future execution. vxVerifyGraph must return VX_SUCCESS
             * before this function will pass.
             *
             * \code
             */
            vxScheduleGraph(graph);
            /** \endcode */
            /**
             * - Wait graph.
             *
             * Waits for graph to complete.
             *
             * \code
             */
            vxWaitGraph(graph);
            /** \endcode */
    
            printf(" Executing graph ... Done !!!\n");
    
           /**
             * - Show graph attributes.
             *
             * Follow the comments in show_graph_attributes() to see
             * how graph attributes are queried and displayed.
             * \code
             */
            show_graph_attributes(graph);
            /** \endcode */
            for(i=0; i<sizeof(node)/sizeof(node[0]); i++)
            {
                if(node[i])
                {
                   /**
                     * - Show node attributes.
                     *
                     * Follow the comments in show_node_attributes() to see
                     * how node attributes are queried and displayed.
                     * \code
                     */
                    show_node_attributes(node[i]);
                    /** \endcode */
                }
            }
    
            printf(" Saving to file %s ...\n", PHASE_FILE_NAME);
            /**
             * - Save image object to bitmap file \ref OUT_FILE_NAME.
             *
             * Follow the comments in save_image_to_file() to see
             * how data in vx_image object is accessed to store pixel values from the image object to
             * BMP file \ref OUT_FILE_NAME
             * \code
             */
            save_image_to_file(PHASE_FILE_NAME, phase);
            /** \endcode */
    
            printf(" Saving to file %s ...\n", MAGNITUDE_FILE_NAME);
            /**
             * - Save image object to bitmap file \ref OUT_FILE_NAME.
             *
             * Follow the comments in save_image_to_file() to see
             * how data in vx_image object is accessed to store pixel values from the image object to
             * BMP file \ref OUT_FILE_NAME
             * \code
             */
            save_image_to_file(MAGNITUDE_FILE_NAME, magnitude_image);
            /** \endcode */
    
            printf(" Saving to file %s ...\n", GRAD_X_FILE_NAME);
            /**
             * - Save image object to bitmap file \ref OUT_FILE_NAME.
             *
             * Follow the comments in save_image_to_file() to see
             * how data in vx_image object is accessed to store pixel values from the image object to
             * BMP file \ref OUT_FILE_NAME
             * \code
             */
            save_image_to_file(GRAD_X_FILE_NAME, grad_x_image);
            /** \endcode */
    
            printf(" Saving to file %s ...\n", GRAD_Y_FILE_NAME);
            /**
             * - Save image object to bitmap file \ref OUT_FILE_NAME.
             *
             * Follow the comments in save_image_to_file() to see
             * how data in vx_image object is accessed to store pixel values from the image object to
             * BMP file \ref OUT_FILE_NAME
             * \code
             */
            save_image_to_file(GRAD_Y_FILE_NAME, grad_y_image);
    
    
            save_image_to_file("output_perspective.bmp", out_image);
            /** \endcode */
        }
    
        /**
         * - Release image object.
         *
         * Since we are done with using this image object, release it
         * \code
         */
        
        vxReleaseUserDataObject(&ldc_in_config);
        vxReleaseImage(&in_image);
        vxReleaseImage(&grad_x);
        vxReleaseImage(&grad_y);
        vxReleaseImage(&grad_x_image);
        vxReleaseImage(&grad_y_image);
        vxReleaseImage(&out_image);
        vxReleaseImage(&phase);
        vxReleaseImage(&magnitude);
        vxReleaseImage(&magnitude_image);
        vxReleaseMatrix(&matrix);
        /** \endcode */
    
        /**
         * - Release scalar object.
         *
         * Since we are done with using this scalar object, release it
         * \code
         */
        vxReleaseScalar(&shift);
        /** \endcode */
    
        for(i=0; i<sizeof(node)/sizeof(node[0]); i++)
        {
            if(node[i])
            {
               /**
                 * - Release node object.
                 *
                 * Since we are done with using this node object, release it
                 * \code
                 */
                vxReleaseNode(&node[i]);
                /** \endcode */
            }
        }
    
        /**
         * - Release graph object.
         *
         * Since we are done with using this graph object, release it
         * \code
         */
        vxReleaseGraph(&graph);
        /** \endcode */
    
        /**
         * - Release context object.
         *
         * Since we are done using OpenVX context, release it.
         * No further OpenVX API calls should be done, until a context is again created using
         * vxCreateContext()
         * \code
         */
       tivxHwaUnLoadKernels(context);
    
        vxReleaseContext(&context);
        /** \endcode */
    
        printf(" vx_tutorial_graph_image_gradients: Tutorial Done !!! \n");
        printf(" \n");
    }
    

    With best regards,

    H.M. Owais

  • Hello,

    Could you please describe the graph that you are trying to create?  If you can create a diagram of the graph that you want to create that would be helpful.

    And when you say that you are receiving a wrong output, are you meaning that the resulting output image is not what you expected?

    If you only want to use the LDC node, I would recommend starting with the psdk_rtos_auto_j7_06_01_00_15/tiovx/kernels_j7/hwa/test/test_vpac_ldc.c as it has many test cases exercising various inputs and outputs to LDC.

    Regards,

    Lucas

  • Hi lucas, Thank you for your reply. I would like to expound your questions, my purpose is to get the perspective view which should be the same as I am getting from warp perspective openvx API. Since, the warp perspective is slow for real time deployment so I was suggested to use it for better performance. Moreover, as I am newbie in OpenVX so the first thing I did was to make use of the existing tutorial and test my required APIs on it before integrating it with my desired usecase. In order to do, I used existing image image_graph_gradient tutorial and added tivxVpacLDC node in a same way as I tested the warp perspective. I will also look further into the details tomorrow which you have mentioned in your above comment. Thank you.