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.

TDA4VM: PSDKRA/vision_apps - unable to obtain valid Draw2D handle

Part Number: TDA4VM

Hello,

I am working on PSDK 6.1.

My objective is to draw some strings on TIDL output.

To that end, I am attempting to use the Draw2D API in a source file inside $PSDKRA_PATH/vision_apps/kernels/img_proc.

The calling code is as follows.

    Draw2D_Handle *pHandle = NULL;
    Draw2D_BufInfo *pBufInfo = NULL;
    Draw2D_FontPrm sDist;
    static int vNum = 0;

    retStatus = Draw2D_create(pHandle);
    if(pHandle != NULL)
    {
        pBufInfo->bufAddr[0] = data_ptr_1;
        ...        
retStatus = Draw2D_setBufInfo(pHandle, pBufInfo); sprintf(temp, "%u", vNum); sDist.fontIdx = 3; retStatus = Draw2D_drawString(pHandle, xmin+5, ymax+5, temp, &sDist); retStatus = Draw2D_delete(pHandle); vNum++; } else { printf("\nReceived NULL Draw2D handle ...\n"); }

After some difficulty, I managed to build vision_apps.

But when I ran the TIDL application, the code drops into the 'else' condition above, and I end up receiving a NULL handle.

On further debugging, I found that the Draw2D object is getting created properly inside draw2d.c, but somehow, that reference is not passed to the calling code above.

How can I resolve this issue?

Thank you.

  • Hi Sagar,

    can you try to change the code in the following way and see if it works:

    Draw2D_Handle pHandle;
    Draw2D_BufInfo *pBufInfo = NULL;
    Draw2D_FontPrm sDist;
    static int vNum = 0;
    
     
    retStatus = Draw2D_create(&pHandle);
    if(pHandle != NULL) /* or check retStatus here */
    {
        pBufInfo->bufAddr[0] = data_ptr_1;
        ...                retStatus = Draw2D_setBufInfo(pHandle, pBufInfo);
        sprintf(temp, "%u", vNum);
        sDist.fontIdx = 3;
        retStatus = Draw2D_drawString(pHandle, xmin+5, ymax+5, temp, &sDist);
        retStatus = Draw2D_delete(pHandle);
        vNum++;
    }
    else
    {
        printf("\nReceived NULL Draw2D handle ...\n");
    }

    (note that Draw2D_Handle is already a pointer (typedef void *Draw2D_Handle; in vision_apps/utils/draw2d/include/draw2d.h))

    Regards,

    Yordan

  • Hi Sagar,

    one more thing: you may need to change also Draw2D_BufInfo to a local struct and initialize it, please check function app_init() in vision_apps/apps/dl_demos/app_tidl/main.c for example how Draw2D_XXX functions are used.

    Regards,

    Yordan

  • Hello Yordan,

    You are correct.

    I need to allocate memory for these objects in the calling function before passing them on to Draw2D.

    I should have caught these mistakes myself...

    Thank you for your help.