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.

Linux/AM5728: OpenCV optimization

Part Number: AM5728

Tool/software: Linux

Hi expert ,

My customer now optimizing the OpenCV function of ocl_goodFeaturesToTrack() using the method of http://processors.wiki.ti.com/index.php/OpenCV#OpenCL_kernel_dispatch_from_OpenCV_application.2C_using_standard_OpenCL_dispatch_with_access_to_OpenCV_data_objects

They find that there are differece in args between ocl_goodFeaturesToTrack() and the functions in gftt.cl.

In ocl_goodFeaturesToTrack(), the args of maxEigenVal is

k.args(eigarg, eig.cols, (int)eig.total(), dbarg);

but in maxEigenVal() in gftt.cl, the arg is

(__global const uchar * srcptr, int src_step, int src_offset, int cols,int total, __global uchar * dstptr)

So what is the relationship of eigarg and global const uchar * srcptr, int src_step, int src_offset,

Thanks!

  • The software team have been notified. They will respond here.
  • Thanks! and the ocl_goodFeaturesToTrack() function is in OpenCV/modules/imgproc/src/featureselect.cpp.
  • This is a OpenCV baseline code (nothing related to TI modifications). Here is code snippet from featureselect.cpp:

    ocl::KernelArg eigarg = ocl::KernelArg::ReadOnlyNoSize(eig),
    dbarg = ocl::KernelArg::PtrWriteOnly(maxEigenValue),
    maskarg = ocl::KernelArg::ReadOnlyNoSize(mask),
    cornersarg = ocl::KernelArg::PtrWriteOnly(corners_buffer);

    if (haveMask)
    k.args(eigarg, eig.cols, (int)eig.total(), dbarg, maskarg);
    else
    k.args(eigarg, eig.cols, (int)eig.total(), dbarg);

    size_t globalsize = dbsize * wgs;
    if (!k.run(1, &globalsize, &wgs, false))
    return false;

    OpenCV provides class KernelArg, in file ./modules/core/includes/opencv2/core/ocl.hpp
    There they can see that more than one argument is returned (w/ default values set, for extra two arguments if not explicitly set in above call).
    E.g.
    static KernelArg ReadOnlyNoSize(const UMat& m, int wscale=1, int iwscale=1)
    { return KernelArg(READ_ONLY+NO_SIZE, (UMat*)&m, wscale, iwscale); }
  • David,

    Thanks for your support!

  • Hi David,

    Customer recently ask a question that as OpenCV use data structure "UMat" and OpenCL use data structure "Buffer" for date transfer, since customer use OptionB, is there any function() can transfer "UMat" to "Buffer" that similar with the function of :

    void cv::ocl::convertFromBuffer  ( void *  cl_mem_buffer,  size_t  step,  int  rows,  int  cols,  int  type,  UMat &  dst )   

    Thanks!

  • Hi David,
    During the OpenCV-OpenCL optimization, there is many data transfer between MAT structure in OpenCV and UMAT structure in OpenCL, customer find this data transfer will lead to high CPU occupy that influnce on other operation, as UMAT and MAT are all in DDR, do we have any method to optimaze this data transfer?