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 Lucas Kanade optic flow for tracking target in the TMS320C6748

Other Parts Discussed in Thread: TMS320C6748

Hi,.

How to Lucas Kanade optic flow for tracking target in the TMS320C6748,

 I use correctly the "VLIB_trackFeaturesLucasKanade_7x7" function,

But can not achieve the target tracking.

 I have some problems with VLIB Lucas Kanade ,Can you please send me the VLIB Lucas Kanade demo code?

Thanks&Regards

 

  • Hi Wang,

    I've requested internal team for that demo code and will get back to you.
  • We can not provide the exact demo code that you are referring to because of TI proprietary licensing issues. The best thing we can offer at this point is the VLIB test code, VLIB_trackFeaturesLucasKanade_7x7_d.c. We just released the latest version of the VLIB late last week, which includes a number of bug-fixes and enhancements, though I'm not sure if this function was touched. Please download here:

    software-dl.ti.com/.../index_FDS.html

    If you are unable to run this test, then let us know.

    Regards,

    Travis
  • Thank you for your help


    I trying to use "VLIB_trackFeaturesLucasKanade_7x7"and dispay window tracking a target,but it didn't dispay window tracking .


    my code as follow:


    while(1)
    {



    GetImage(RGBimage);

    //GreyTran(RGBimage, GREYimage);
    //GreyImageDraw(&g_sContext, GREYimage, 0, 0);
    if(input_feild!=NULL)
    {
    //VLIB_imagePyramid8(input_feild,piramidSizeX, piramidSizeY,calculatedOutData_Pyramid8);
    GreyTran(RGBimage, GREYimage);
    //Initially point to the end of pyramids
    piramidSizeX=100;
    piramidSizeY=60;

    pCalculatedOutData_Pyramid = calculatedOutData_Pyramid8+(400*240+200*120+100*60);
    pCalculatedOutData_Pyramid_previous= pCalculatedOutData_Pyramid_previous+(400*240+200*120+100*60);
    //We will start form the smallest image (deepest level) in pyramid ,and go towards original resolution
    GetImage(pCalculatedOutData_Pyramid);
    // GetImage(pCalculatedOutData_Pyramid_previous);

    //x,y will have feature co-ordinates of input_field_previous.mX,mY are to have feature co-ordinates of input_feild.
    //Since we are starting with deepest level in pyramid , the initial estimates of mX, mY are same as the features of level 3
    //image of input_feild previous These will be updated on first call to VLIB_trackFeatureLucaskanade_7*7
    for (i=0;i<nTrackedPoints;i++){
    mX[i]=X[i]>>3;
    mY[i]=Y[i]>>3;

    }
    //Three iterations starting from level 3 of pyramid up to level 1
    for (i=01;i<3;i--){
    for (j=0;j<nTrackedPoints;j++){
    X_pyramid[j]=X[j]>>i;
    Y_pyramid[j]=Y[j]>>i;

    }
    //Move pointers to beginning of level i image of the pyramid
    pCalculatedOutData_Pyramid =pCalculatedOutData_Pyramid -(piramidSizeX*piramidSizeY);
    pCalculatedOutData_Pyramid_previous=pCalculatedOutData_Pyramid_previous-(piramidSizeX*piramidSizeY);
    //GreyImageDraw(&g_sContext, GREYimage, 0, 0);
    GetImage(pCalculatedOutData_Pyramid);
    GetImage(pCalculatedOutData_Pyramid_previous);
    //Estimates mX,mY are updated at level i image of the pyramid .Input features are X_pyramid,Y_pyramid
    VLIB_xyGradientsAndMagnitude(pCalculatedOutData_Pyramid,GRADX+piramidSizeX+1,GRADY+piramidSizeY+1,GRADMAG+piramidSizeX+1,
    piramidSizeX,piramidSizeY-1);
    VLIB_trackFeaturesLucasKanade_7x7(pCalculatedOutData_Pyramid_previous,pCalculatedOutData_Pyramid,GRADX,GRADY,piramidSizeX,
    piramidSizeY,nTrackedPoints,X_pyramid, Y_pyramid,mX,mY,10,BUFFER);
    GetImage(pCalculatedOutData_Pyramid_previous);
    //updated pyramid image size for next iteration
    piramidSizeX=piramidSizeX<<1;
    piramidSizeY=piramidSizeY<<1;
    //GreyImageDraw(&g_sContext, GREYimage, 0, 0);
    //mX,mY refined at this level i are scaled to become estimates for next iteration
    for ( j=0;j<nTrackedPoints;j++){
    mX[j]=mX[j]<<i;
    mY[j]=mY[j]<<i;


    }

    }
    //Refine mX,mY Fourth time for original resolution for fine tuning
    VLIB_xyGradientsAndMagnitude(input_field_previous,GRADX+piramidSizeX+1,GRADY+piramidSizeY+1,GRADMAG+piramidSizeX+1,
    piramidSizeX,piramidSizeY-1);
    VLIB_trackFeaturesLucasKanade_7x7(input_field_previous,input_feild,GRADX,GRADY,piramidSizeX,
    piramidSizeY,nTrackedPoints,X, Y,mX,mY,10,BUFFER);
    //mX,mY will now have features input_field
    GetImage(pCalculatedOutData_Pyramid_previous);
    //current frame and its feature become previous
    pCalculatedOutData_Pyramid_previous=pCalculatedOutData_Pyramid;
    input_field_previous[800*480] = input_feild[800*480];
    for (i=0;i<nTrackedPoints;i++){
    X[i]=mX[i];
    Y[i]=mY[i];


    }
    GetImage(input_field_previous);

    //void VLIB_normalFlow_16(
    //input_feild-input_field_previous,

    }
    else{
    UARTPuts("Tronlong Image Process Application......\r\n", -1);
    }

    }
    }
  • How come no one reply?

  • Wang,

    Did you get a chance to try out the test code that is available in the release? VLIB  3_2_0_2 is the latest release and you can download it from here:

    The test code is: packages\ti\vlib\src\VLIB_trackFeaturesLucasKanade_7x7\VLIB_trackFeaturesLucasKanade_7x7_d.c


    Also, we have included a code snippet on how to perform Lucas Kanade based tracking in the VLIB documentation which will be of help to you.

    From your code, I have the following suggestions:

    1. The for loop to perform tracking three times should actually be this:

    for (i = 3; i > 0; i--)

    This is different from your for (i=01;i<3;i--) which will provide incorrect results.

    2. Please use VLIB_xyGradients() to calculate gradients instead of VLIB_xyGradientsAndMagnitude() as the test code uses VLIB_xyGradients() before calling the tracker function.


    Thank you.


    Sincerely,

    Sudhakar Ayyasamy