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.

Sobel on EVMDM642

Other Parts Discussed in Thread: CCSTUDIO

Hi,
I tried to use the Sobel function from the IMGLIB with my EVMDM642/camera/display. However, all I get is blank on the display. The relevant codes are as below (modified from example codes):
    while(1){
        /* copy data from capture buffer to array to display buffer */
        for(i = 0; i < numLines; i++) {
            DAT_copy(capFrameBuf->frame.iFrm.y1 + i * capLinePitch, Array1, disLinePitch);
            CACHE_wbInvAllL2(CACHE_WAIT);

            IMG_sobel_c(Array1, Array2, cols, rows);

            DAT_copy(Array2, disFrameBuf->frame.rpFrm.buf + i * disLinePitch, disLinePitch);
            CACHE_wbInvAllL2(CACHE_WAIT);
        }
        ...
}
I also defined these locally somewhere up in the function:
#define cols 640
#define rows 480
and globally:
unsigned char Array1[640 * 480];
unsigned char Array2[640 * 480]={0}; /*intitialize coz Sobel produce 640 x 438 */

Anyone knows why this happens?
Thanks.
Hanief

  • You may want to try:

       while(1){
            /* copy data from capture buffer to array to display buffer */
            for(i = 0; i < numLines; i++) {
                DAT_copy(capFrameBuf->frame.iFrm.y1 + i * capLinePitch, Array1, disLinePitch);
                CACHE_wbInvAllL2(CACHE_WAIT);

                IMG_sobel_c(Array1, Array2, cols, rows);

                CACHE_wbInvAllL2(CACHE_WAIT); <-- MOVED ABOVE
                DAT_copy(Array2, disFrameBuf->frame.rpFrm.buf + i * disLinePitch, disLinePitch);
            }

    If the above doesn't help, you may want  to replace the sobel call with a memcpy to see if you get the same output as input. This will help understand if the issue is in the sobel call or not

     

  • Hi Gagan Maur,
    Moving the cache invalidate call doesn't seem to do anything. And the issue is in the Sobel call as expected. memcpy verifies that. I suspect it's something to do with the fact that the output image is 'cols' pixels wide and 'rows - 2' pixels tall.
    Edited: I have also tried IMG_sobel instead of IMG_sobel_c. It produces 'striations' of vertical black lines on a white background (I'm imaging a black object on a white background). The shape of the object is quite visible to human eyes, but worthless for further processing.
    Hanief
  • You can include the C code in your build and single step to see what it is doing. You can get the source in the file: C:\CCStudio_v3.3\c6400\imglib\lib\img64x_c.src. Note it is a simple txt file. You can open it in any text editor and copy the sobel code.

    Regards,

    Gagan

     

  • Firstly, the declarations below is incompatible with the FVID structure, so I discarded them & declared them as 'unsigned char' instead. Otherwise I'll get about 100 errors & warnings like 'expected an identifier', 'expected a ";"' even when there is one, 'declaration is incompatible with "VPORTDIS_Params EVMDM642_vDisParamsChan"', ' function call is not allowed in a constant expression'.
    const unsigned char *restrict in,
    unsigned char *restrict out,
    After that, I managed to do as you suggested, build & load the program. Running it gives nothing (display is blank). When I try source-single step, the yellow arrow keeps going around in the for loop.

    I found in a book that this "streaking" phenomena is caused by image noise. It recommended smoothing the image before applying filters like Sobel. But then, when I tried img_conv_3x3 & img_median_3x3, they both also have those streaking lines. Hanief