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.

How to create an intermediary frame for image processing on EVM DM648 with preview-demo

Hello,

I have a DM648 EVM with the DVSDK and i success to compile and put the full demo provided with the kit.
I used this link for porting it to new CCS: http://processors.wiki.ti.com/index.php/Porting_DM648_DVSDK_demo_app_from_CCSv3.3_to_CCSv4 

I also success to run the video-preview example in "dvsdk_1_11_00_00_DM648\examples\video_preview".

And now i want to use the video preview example and add image processing between the capture and display.

I also success to modify a frame and display it with this link:

 http://processors.wiki.ti.com/index.php/Accessing_Pixels_in_a_Frame_on_the_DM643x

My problem is that if i modify the current frame and display it, it works fine:

  /* grab a fresh video input frame */
FVID_exchange(capChan, &frameBuffPtr);

/* Image processing */ (modify the frame)
process_image( (void*)(frameBuffPtr->frame.frameBufferPtr));

BCACHE_wbInv((void*)(frameBuffPtr->frame.frameBufferPtr), 576*720, 1);

/* display the video frame */
FVID_exchange(disChan, &frameBuffPtr);


But now i need to create a temporary frame because i need the current frame to process the new frame (median filter...),

How to create this intermediary frame?

I try some things but it doesn't work. I try to create a temporary buffer with a mem alloc:  

tempBuffer = MEM_alloc(DDR2, 576*720, 0);

and after my loop processing:

 /* grab a fresh video input frame */
FVID_exchange(capChan, &frameBuffPtr);

/* Image processing */(fill temp buffer)
process_image( (void*)(frameBuffPtr->frame.frameBufferPtr),(void*)(tempBuffer));

/* Now change the current frame pointer with new tempbuffer */
frameBuffPtr->frame.frameBufferPtr=tempBuffer;

BCACHE_wbInv((void*)(frameBuffPtr->frame.frameBufferPtr), 576*720, 1);

/* display the video frame */
FVID_exchange(disChan, &frameBuffPtr);

This seem to doesn't work, the output image is flashing...
I don't know if it's the right way to create a temporary frame.
Is the MEM_alloc bad?

I also try to use FVID_allocBuffer to allocate a new temporary frame buffer but the function need a channel parameter:

FVID_allocBuffer(capChan, &frameBuffPtr);

So i assume that the video port will use it and so when i create an intermediary frame on display channel:

FVID_Frame *tempFrameBuffPtr = NULL;

/*Create temporay frame*/
FVID_allocBuffer(disChan, &frameBuffPtr);

and don't add it to the channel queue (FVID_queue), the output image is bad (it seem jump frame or lag, bug).

So can you help me to create an intermediary frame and display it after processing.

Thank you.

Max

  • Now i can create a buffer with this example found in mini-demo project of dvsdk:

    static Int LOCAL_allocBuffer(Ptr ppFrame, Ptr pBuf)
    {
    FVID_Frame *newFrame = NULL;

    // Allocate memory for the new FVID_Frame object
    newFrame = MEM_calloc(DDR2,sizeof(FVID_Frame),VIDEO_BUFALIGN);
    if (!newFrame)
    {
    //LOG_printf(&trace, "Could not allocate frame.");
    return IOM_EALLOC;
    }

    // Allocate memory for the new data buffer
    if (!pBuf)
    {
    newFrame->frame.iFrm.y1 = MEM_valloc(DDR2,VIDEO_BUFSIZE,VIDEO_BUFALIGN,0x80);
    if (!newFrame->frame.iFrm.y1)
    {
    //LOG_printf(&trace, "Could not allocate data.");
    return IOM_EALLOC;
    }
    }
    else
    {
    newFrame->frame.iFrm.y1 = pBuf;
    }
    I allocate and freeing each time in my loop:
    
    
    while (status == 0) {

    LOCAL_freeBuffer(&tempFrameBuffPtr);
    /* allocate a temporary buffer for processing */
    LOCAL_allocBuffer(&tempFrameBuffPtr,NULL);

    /* grab a fresh video input frame */
    FVID_exchange(capChan, &frameBuffPtr);

    /* Image processing */
    do_median_filter((void*)(frameBuffPtr->frame.frameBufferPtr), (void*)(tempFrameBuffPtr->frame.frameBufferPtr), 576, 720);

    BCACHE_wbInv((void*)(tempFrameBuffPtr->frame.frameBufferPtr), 576*720, 1);

    /* display the video frame */
    FVID_exchange(disChan, &tempFrameBuffPtr);
    So i have an output on the screen but the picture seem to lag when something move in the field why?.
    More over can you explain why i get a small delay (about 0.5s) between the capture and display in the original preview example project? Is it normal?
    I read in the user guide that we need 3 frames per driver why?:
    /* Number frame buffers per driver */
    #define FRAME_BUFF_CNT 3
  • The driver needs 3 buffers because of the internal queue (ping/pong buffer) requirement as well as one for the application so that it could get time to process a frame when the driver is processing the other buffers.

    This is called priming.

    The lag from capture to display is latency and is because of this priming and the application latency to do the processing.

  • Hi,

    thank you for your answer. 

    I have some question about the TI demonstration demo.

    As i say in my first post, i success to compile and use the full demo application of EVM DM648 ("dvsdk_1_11_00_00_DM648\dm648_demo_0_92_04")

    With this recompiled project in video_preview mode (capture and display one channel) i have a very small delay between input and output so it's acceptable for me.
    But with the original program loaded factory in the board (which will be the same program i compile above i think) launch in preview mode i have a more important delay... About 0.5s between output and input. why?

    More over, with another project "dvsdk_1_11_00_00_DM648\examples\video_preview" which is a lite version, i have a delay between output and input  which is lesser than the factory demo but bigger than the full recompiled demo...

    Do you have some explication about that? I need a very small delay between input and output...

    Max