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.

DM6437 Vlib2.1 Hough Transform

Hi ,

   When I use the function VLIB_houghLineFromList() in vlib for Hough Transform, I have a question: 

   First, I do not konwn what are  the parameters " ping pong pang peng" mean?

  Second, when I get the parameter "pOutHoughSpace" from  VLIB_houghLineFromList() , and I get the biggest pixels index in "pOutHoughSpace", for example 200, and I suppose the thetaRange is 180,  rhoMaxLength is 267.  How can i get the true Theta and Rho?  Theta = 200 / rhoMaxLength ,  Rho = 200 % rhoMaxLength ? What is the relation between the input parameter rhoMaxLength and the Rho/Theta?

  Thanks a lot.

  • Hello, our expert is looking into this and will get back to you soon.

  •  

    Hello XianSheng,

    I am currently writing an application note and developing a simple project using VLIB Hough transform for line detection in an image.

    Please provide me your email id so that I can send you this project which would help you clarify all the details.

    Your second question is the reason why I am doing the above as there are multiple ways to implement the Hough transform.

    ping, pong, pang and peng are temporary buffers used to optimization.

    Please refer to the documentation and the VLIB_testhough file for more details.

    Regards

    Senthil

  • Hello Senthil ,

       Thanks very much for your reply.

       My email id is liuqingben511@163.com or dsp.support@zlgmcu.com

  • Hello XianSheng and Senthil,

    I also want to know how to retrieve actual theta and rho value.

    Would you share the document for me?

    My email is junsu.jang@lge.com

    Thank you very much.

  •  

    Hello Junsu,

    I emailed you an example project.

    Please let me know if you need anything more.

    Regards

    Senthil

     

  • I got the example project. Thank you very much.

    I am trying to exchange simulink hough transform block to VLIB_houghLineFromList block.

    Is rhoMaxLength always the same as thetaRange?

    The calculatedOutHoughSpace seems wrong, when rhoMaxLength changes to bigger number.

    In my  understanding of hough transform, when input image is 320*240, then rho range is -400 ~ +400 (sqrt(320^2 + 240^2)).

    It seems the rho range is different in the draw_line.c. 

    Would you explain what following codes means?

    diameter = SQRTof2_Q8*max(W,H);

      normLength = 267 << 16;
      normLength /= diameter;  
      normLength /= 2;  

    I tested simulink hough block with 1deg resolution of theta and 1pixel resolution of rho, but I don't know how to set the resolutions and the range for theta and rho in VLIB_houghLineFromList block. Can I get 'trigs.m' that generates sin, cos table?

    Best regards,

    -Junsu

  •  

    Junsu,

    Two years back, I worked with Mathworks to replace the Simulink Hough transform block to VLIB_hough transform block for their Lane Departure Demo.

    I remember doing a few hacks to get it working as the line represenations were different in Matlab and VLIB and also had to compensate for the rho and theta transformations.

    Answering your questions below:

      // Diameter of Hough Space which is max abs value of r  = sqrt(W^2 + H^2 ) [this  is approximated by the value below]
      diameter = SQRTof2_Q8 * max(W, H);

      // Scale factor for r to rho conversion
      normLength = 267<< 16;
      normLength /= diameter;  
      normLength /= 2;         

    The actual 'r' is quantized to a new variable with rhoMaxLength as the number of bins for quantization.

    For example, 'r' can take any floating point value from -r_max to + r_max. This range is mapped to discrete bins 0,1,2 ... rhoMaxLength which will act as the indexes in the Hough Space. From the bin index, you need to extract the actual 'r' by doing the inverse of quantization which is what is illustrated in the sample project I sent you.

    So in your example, 400 is actually r_max and not rhomaxLength and it can be different from thetaRange. This range of values -400 to 400 is mapped to discrete indices 0,1,2....267.

    VLIB_testHough.c provided in VLIB contains the VLIB_InitializeTrigLUTs function which generates the sin and cos tables.

    Please feel free to ask for more clarification if required.

    Regards

    Senthil

  • Senthil,

    I tested VLIB_hough transform with different rhoMaxLength.

    Is there any maximum value for rhoMaxLength?

    When I set high value for rhoMaxLength, HoughOut was not correct.

    ex) for 360*120 images, rhoMaxLength = 380 works well

    but rhoMaxLength = 600 does not work properly. I observed overlapping voting count appear in HoughOut.

    If the range -r_max ~ +r_max is divided into rhoMaxLength bins equally, different rhoMaxLength generates only scaled pattern of HoughOut.

    I will send you a picture showing overlapping pattern of HoughOut since I cannnot attach picture here.

    Thanks,

    Junsu

     

  • Hello Senthil,

    Can you also send me the example project for Hough transform using VLIB.

    My email Id is a_pradyumna<at>yahoo<dot>com 

     Also I suggest upload the example project so that others can easily find it.

     

    Thank you,

    Regards.

    Ayyala

  •  

    Ayyala,

    I emailed you the example project.

    We are planning to clean it up and release it with VLIB.

    Regards

    Senthil

  • Hello senthil,

               I unfortunately erase the flash program while doing some programs , But i burn the flash program in the cd (dm6437_demo.hex) i have also burn it in the flash using flash utility but it was not working properly....

    So please give some solution to get my board to the Default state......

    regards

  • Hello,I need the vlib ,where can I download the vlib? do you have it?   email:hyunfei19862008@163.com     sorry,my English is very poor!!!!!

  •  

    Hello YunFei,

    Please use the following link and fill the form for approval of VLIB - www.ti.com/vlibrequest

    Regards,

    Senthil

     

  •  

    Shan,

    I dont know how to fix this issue.

    I will try to find out and let you know.

    Regards,

    Senthil

  • Hello XianSheng and Senthil and Junsu,

    I also want to know how to retrieve actual theta and rho value.

    Would you share the document for me?

    My email is iopp50@gmail.com

    Thank you very much.

  • Hello senthil:

     I also want to use Hough Transform for Lines of VLIB. Would you please email the demo project to me? My email address is as below~ amtb1968@gmail.com

    regards,

  • Dear Senthil:

     

    The image frame is 720x480 and captured from camera YCbCr422 format, we want to find the edge by using canny VLIB and show the result of edge. Because the image size is large, we put it on the heap section by using malloc() and mapping to DDR2(0x80000000), the demo code is as below:

     

    =======================================

        Uint8 *yuvimage_in, *yuvimage_out;
        //parameter for canny edge detection
        Int32 i;
        Uint8* scratchData;
        Int16* gradX; //grad of x direction
        Int16* gradY; //grad of y direction
        Int16* gradM; //grad of magnitude
        Uint8* nonMax; //non maximun value
        Uint8* outData; //output data of edge
        Int32* numItems;
        Uint32* listptr;
        Int32 pixelNums;
        //5x5 gaussian core, convert to 7x7 gaussian core for format compatible
        const char gaussian_7x7[49] =
        {
        0, 0, 0, 0, 0, 0, 0,
        0, 1, 4, 6, 4, 1, 0,
        0, 4, 16, 24, 16, 4, 0,
        0, 6, 24, 36, 24, 6, 0,
        0, 4, 16, 24, 16, 4, 0,
        0, 1, 4, 6, 4, 1, 0,
        0, 0, 0, 0, 0, 0, 0
        };
        Uint8 hi = 20; //high threshold
        Uint8 lo = 2; //low threshold

        pixelNums=height*width; //480x720

        if((yuvimage_in=(Uint8*)malloc(height*width*2))==NULL)
        {
          printf("Fail to malloc yuvimage_in\n");
        }
        if((grayimage=(Uint8*)malloc(height*width))==NULL)
        {
          printf("Fail to malloc grayimage\n");
        }
        if((yuvimage_out=(Uint8*)malloc(height*width*2))==NULL)
        {
          printf("Fail to malloc yuvimage_out\n");
        }

        if((scratchData=(Uint8*)malloc(pixelNums))==NULL)
        {
          printf("Fail to malloc scratchData\n");
        }
        if((gradX=(Int16*)malloc(pixelNums))==NULL)
        {
          printf("Fail to gradX\n");
        }
        if((gradY=(Int16*)malloc(pixelNums))==NULL)
        {
          printf("Fail to malloc gradY\n");
        }
        if((gradM=(Int16*)malloc(pixelNums))==NULL)
        {
          printf("Fail to malloc gradM\n");
        }
        if((nonMax=(Uint8*)malloc(pixelNums))==NULL)
        {
          printf("Fail to malloc nonMax\n");
        }
        if((outData=(Uint8*)malloc(pixelNums))==NULL)
        {
          printf("Fail to malloc outData\n");
        }
        if((numItems=(Int32*)malloc(1))==NULL)
        {
          printf("Fail to malloc numItems\n");
        }
        if((listptr=(Uint32*)malloc(pixelNums))==NULL)
        {
          printf("Fail to malloc listptr\n");
        }


            VLIB_extractLumaFromUYUV((char*)yuvimage_in, (Uint16)width, (Uint16)width, (Uint16)height, (char*)grayimage);

            pixelNums = (height - 6)*width - 6;
    #if 1  // refer to IMG v2.01 LIB
            IMG_conv_7x7_i8_c8s(grayimage,scratchData,width,width*2,gaussian_7x7,8); //pitch=width*2
    #else // refer to canny demo
            IMG_conv_7x7_i8_c8s(grayimage,scratchData,pixelNums,width,gaussian_7x7,8); //pixelNums=width*height
    #endif
            pixelNums = (height - 8)*width;
            VLIB_xyGradientsAndMagnitude(scratchData,gradX+width*4+4,gradY+width*4+4,gradM+width*4+4,width,height-8);

            for (i=0; i < width*5; i++)
            {
                nonMax[i] = 0;
            }
            for (i=0; i < width*5; i++)
            {
                nonMax[width*(height - 5) + i] = 0;
            }

            pixelNums = width*(height - 10);
            VLIB_nonMaximumSuppressionCanny(gradM+width*4+4,gradX+width*5+5,gradY+width*5+5,nonMax+width*5+5,width-10,width,height-8);
            VLIB_doublethresholding(gradM+width*5+5,nonMax+width*5+5,listptr,numItems,width-10,width,height-10,lo,hi);
            VLIB_edgeRelaxation(nonMax+width*5+5,listptr,numItems,width);
            for (i = 0; i < width*height; i++)
            {
                *(outData + i) = (*(nonMax + i) >> 7)*255;
            }
            gray2ycbcr(outData , width, height, yuvimage_out);
            display(yuvimage_out);

     

     

    The problem is:

     We found the performance on canny_edge_detection of VLIB is not good (it needs 4 sec to process one frame of 720x480) when using on our test. After we search some documents on web of TI, we know the bottleneck is the latency on moving the image data of one frame from DDR2, and processed by CPU and then move back to DDR2. We have some questions for canny edge detection function~

    • Because our project is without DSP/BIOS, we just use a while() loop to do three tasks: (1)query frame from VPFE, (2)process the image date like edge detection, hough transfer,..., (3)output the image after process. The image query and output is using EMDA3, it is ok and no lag during the two step. Although we know the EDMA3 is good and help to speed up the data moving between DDR2 and CPU, we reference to the document as below, but we do not how to optimize the process step and how to utilize the cache memory by slicing the frame.

              http://processors.wiki.ti.com/index.php/C64x%2B_iUniversal_Codec_Creation_-_from_memcpy_to_Canny_Edge_Detector

    • Just as we know, the EDMA3_LLD and ACPY3 LIB need to co-operate with BIOS or CE, how can we do without DSP/BIOS or CE framework.
    • Hope you can give us some suggestion.

     

  •  

    Hello Alan Yi,

    The EDMA3_LLD driver requires an OS and DSP/BIOS is the simplest and most efficient OS to use.

    You can try to program the EDMA without using the LLD using instructions below. This does not mandate an OS.

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

     

    Regards,

    Senthil

  • Hello Senthil:

     Thanks for your reply. We have used EDMA/QDMA to move image data between external memory and internal memory, however, we do not how to use IDMA(L1<->L2) and EDMA3 to improve the efficiency on canny_edge_detection VLIB and HoughT_line_detection VLIB in low level control. Have any sample code for user to understand the detail about low level control method on IDMA?

    Regards,

    Alan

  •  

    Alan,

    Sorry, I havent used IDMA. Typically we directly access the data from L2.

    Have you benchmarked L2 direct access?

    Regards,

    Senthil

     

  • Hello Senthil:

    (1)   You mean you just move image data from DDR2 to L2RAM by using EMDA? How do you configure the L1/L2 memory?

    (2)   Without DSP/BIOS, how do you benchmark L1/L2/DDR2 direct access?

    Regards,

    Alan

     

  • Hi Senthil:

    We have some questions about your demo project for Hough line function on VLIB:

     

    (1)How to assign the rhoLength and tetaRange value by a W x H image? For example, if the width and height of the image are W and H, what are the values for rhoLength and tetaRange? Do we need to dynamic adjust the values for rhoLength and tetaRange depend on image size, or we can just fix the value to 267 as your demo project? Because we see some document use rhoLength=(W+H)x2+1 and tetaRange=180, which relative to the image size.

    (2)The extended question for (1) is that the tables for Sine and Cosine are generated in advance or used VLIB_InitializeTrigLUTs() to generate depend on the image size? We though it would be better to generate in advance for saving computation time if the image size is fixed, is that right? Have any impact?

    (3)On your hough_wrapper.c, you find the maximum value in calculatedOutHoughSpace[] and record the index, is it based on one single line? Do we have to modified this code segment if we want to find many line in a hough space?

    (4) The extended question for (3) is that the draw_line() function is based on we have found one line in advance, is that right?

     

    Regards,

    Alan

  • Hello Senthil,

    I got confused about  the relation between rhoMaxLength and rhomax,

    how can I calculate the real rho with rhoMaxLength.

    Can you provide me an example project, My e-mail : fangjiaquan@yahoo.com.cn

    Regards

    Fang

  • Hello Senthil,

    Also  I am confused when I get the index for the maximun member in pOutHoughSpace[ ] .

    I donnot know how to get the exact rho and theta from the index.

    I have read some related posts , some are really helpful.

    Would you please send me an example project ?

    My email  is : xieyifengle@163.com

    Regards

    Xie

  • Alan, I have the same performance problem, have you found a solution?  Really appreciate if you can let me know.

    Ben

  • Dear Ben:

    Do you see below web link for reference? You will know there are two way to do canny: frame-based and slice-based.

    http://processors.wiki.ti.com/index.php/C64x%2B_iUniversal_Codec_Creation_-_from_memcpy_to_Canny_Edge_Detector

     

    We use frame-based to do canny and hough because it is easier to implement than slice-based. And then try to resize the image frame from 720x480 to 640x480 or 320x240 for efficiency issue.

     

    You need to think about what you want and to consider whether the efficiency of VLIB can meet your requirement.

     

    regards,

    Alan

  • Thanks a lot, Alan. I'm using frame based also. Will try slice based and downsize the frame.

    Regards,

    Ben

  • Hello.

    I have EVMDM6437 and I am I've been developing some projects to do EdgeDetection with IMGLIB, with very good results. I also have VLIB, and I would like probe hough trasnform to do lane departure detection. Could you send me any project or example?

    I have one question: I've just started to probe some projects in simulink to generate code for CCS 3.3. I send from host by TCP/ip one video, that it's recived and processed to detect edges in DM6437 (using a model generated by simulink, and Sobel block, with C6000 toolbox, Video processing toolbox, Workshop Real time, etc and downloaded in EVM6437), but performance is very slow (I see the result in one screen)

    I would like using simlink to do complex algorithms (like Traffic Signal Recognition), but I don't know if using this techniques (Matlab/simulink and toolboxes related) I don't have good performances... What do you thing?

    Thank you very much.

  • hi

     I have the same  problem for Inverse mapping...

    Can anyone provide me some information?

    My mail: csl5@autorad.com.tw

    Thanks

    BY Alice