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.

Using image library functions in Video_Preview file for image processing

Other Parts Discussed in Thread: CCSTUDIO

Hi ..

I am working on the Video_Preview example given in DM6437 and it is working fine. I am trying to use image library function in Video_preview for image prociing /modification. The program is running on the board but I am not getting the desired output.  All I am getting is the "colored Stipes" on the screen. I am not able to figure out whether it is a Cache problem or any other issue. I  also Tried Sobel Operator and and the result was the same.

we included following in the video_preview.c file.

#include "IMG_erode_bin.h"

/* Header file for the C function */
void IMG_erode_bin_c(const unsigned char * in_data, unsigned char * out_data, const char * mask, int cols);


const char  mask[9] =
{
    -1, 1, -1,
     1, 1,  1,
    -1, 1, -1
};

unsigned char  out_data_c[720*480*2];

and added following code where we we do the image processing.

 

IMG_erode_bin((void*)(frameBuffPtr->frame.frameBufferPtr),out_data_c,mask, 720);

 

 FVID_exchange(hGioVpbeVid0, &out_data_c);//&frameBuffPtr);

Also we tried to copy the data from out_data_c to (frameBuffPtr->frame.frameBufferPtr)

and tried to display the frame but we did not get correct results.

We appreciate the time and help.

Thank you,

Jalwinder and Shriram

  • There may be some other issue going on here that we can look at, but for starters the IMG_erode_bin function is expecting a binary image as input, i.e. containing only black and white, no greyscale, where each bit in a byte is a pixel (8 pixels per byte, one bit per pixel (1bpp)), whereas the the data buffer you are getting from the capture driver in the video_preview example is a color interleaved YCbCr 4:2:2 image, which has 2 bytes per pixel. This being said, using the binary erode function on an image formatted like this will likely get you some strange looking results because it will treat each bit in the luma and chroma values as a pixel, thus leading to strangely modified colors, probably not what you are really looking for.

    As a bit of a side note, if you are not already, you may want to start out with the video_preview from http://wiki.davincidsp.com/index.php?title=Accessing_pixels_in_a_frame_on_DM643x instead of the one that comes with the DVSDK, as this modified example is already setup to perform some operation on the frame buffer, though you would still need to convert the image into a 1bpp binary image before running it through the erode function from IMGLIB.

  • Hello Bernie,

    Thank you for the reply.

    I am trying to get edge detected image from the YCbCr 4:2:2 image. We are currently using the same Video_Preview example that is provided at  http://wiki.davincidsp.com/index.php?title=Accessing_pixels_in_a_frame_on_DM643x . I tried to use the image Library C64plus for Sobel operator. 

    I followed the instructions provided at http://focus.ti.com/lit/ug/sprueb9/sprueb9.pdf

    and function  

    void IMG_sobel(const unsigned char *in_data, unsigned char *out_data, short cols, short rows)                

     for Sobel Edge Detection (5-47)   and stored the output data at 

    unsigned char  out_data_c[720*480*2];

    then I wrote one function to copy that data to                        (frameBuffPtr->frame.frameBufferPtr)    from the array out_data_c       and tried to display the result but I got some garbage data(stripes) on the screen. I even tried to provide the address of out_data_c to the FVID_exchange to display the frame but no success. 

    Kindly guide us.

  • Hello Bernie,

    Thanks for your reply.

    I have two questions here:

    1. Refer to your previous/above answer, Is there any direct function available in IMG LIB to convert the YCbCr input to Binary output to be displayed?

    2. Also, I have used Sobel Edge Detection from Library function in my video preview example but it is not working correctly. It produces split screen output with above half shows sobel processed output with green background. Lower screen is displaying the same frame as the captured input.

    Also the above split screen output in Sobel is divided in 1/2  on screen.

    Can you please provide any solution to these problems?

    I Hope I did not confuse you with my questions.

    Thanks in advance

     

    Jalwinder Pingal

     

     

  • See document C:\CCStudio_v3.3\c64plus\imglib_v201\docs\SPRUF30A.pdf
    3.3.5 Image Threshold Function
    "
    Different forms of image thresholding operations are used for various reasons in image/video processing systems. For example, one form of thresholding may be used to convert grayscale image data to binary image data for input to binary morphological processing
    "

    Also, the source of the IMGLIB kernel is provided here: C:\CCStudio_v3.3\c64plus\imglib_v201\kernels\c\IMG_erode_bin_c.c.
    It may be easier to add the code to your project and single step through to see what may be causing the issues

    Gagan