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.

AM5728: Does AM5728 support opencv SVM feature?

Genius 13655 points
Part Number: AM5728

Hello Champs,

Customer used opencv 3.1.0 which supports ml module, but when calling haveSVM, it returns 0, how to enable the SVM function?

He also recompiled ti opencv3.1.0 and added opencl_svm, but it prompted svminit return error CL_INVALID_VALUE.

Does the c66x dsp core on AM5728 support SVM?

Thanks.
Rgds
Shine

  • HI Shine

    Expert assigned to this thread is out of office today - we will get back to you tomorrow or early next week. Sorry for the delay.

  • Hi, Shine,

    Does the customer use the OpenCV from the PLSDK release package or OpenCV 3.1.0 from open source? If using open source code, could customer try using PLSDK?

    Rex
  • I used the code from git://git.ti.com/opencv/tiopencv.git with version opencv 3.1.0

  • It's notice: "Error on line 2632 (ocl.cpp): CL_DEVICE_SVM_CAPABILITIES via clGetDeviceInfo failed: -30" when I run my test code.
  • Current OpenCL device:
    Type = TI_DSP
    Name = TI Multicore C66 DSP
    Version = OpenCL 1.1 TI => Is it support OPENCL_SVM ?
    Compute units = 2
  • Hi, Guotao,

    Have you tried with TI Linux Processor SDK? You mentioned your code is from git://git.ti.com/opencv/tiopencv.git with version opencv 3.1.0. I am not sure if you are using from tiopencvrelease_3.1 branch. You need to use tiopencvrelease_3.1 branch if your opencv 3.1.0 is not the same branch.

    If you haven't had a chance gone through PSDK OpenCV User Guide, here is the link which may help: software-dl.ti.com/.../Foundational_Components_OpenCV.html

    Rex
  • Dear Rex,
    Firstly , I did my work with software-dl.ti.com/.../Foundational_Components_OpenCV.html.
    I'm using TI Linux Processor SDK4.0.0 but the opencl_svm is closed defaultly(the function of "haveSVM()" return 0).

    Then I used tiopencvrelease_3.1 branch to compile opencv WITH_OPENCL_SVM option, but it compiled error.

    Lately I compiled tiopencv master branch to compile opencv WITH_OPENCL_SVM option successfuly. It was notice: "Error on line 2632 (ocl.cpp): CL_DEVICE_SVM_CAPABILITIES via clGetDeviceInfo failed: -30" and run on CPU when I tested svm->predict().
  • HI Rex,

    1. I modified OpenCVDetectOpenCL.cmake on tiopencvrelease_3.1 branch . Now it compiled succussfully with "#define HAVE_OPENCL_SVM" . 

    2. scp the lib to /usr/lib, reboot device. 

    3. run my test code , notice err.

    root@embest-am57xx:~/svm_test# ./TEST_SVM

    Error on line 2858 (ocl.cpp): CL_DEVICE_SVM_CAPABILITIES via clGetDeviceInfo failed: -30

  • Hi, Guotao,

    Lately I compiled tiopencv master branch to compile opencv WITH_OPENCL_SVM option successfuly

    The master branch won't work. Master branch is the baseline TI OpenCV release is based off the master branch.

    Your SDK 4.0 is old. Could you try running the OpenCV Unit Test as described in http://software-dl.ti.com/processor-sdk-linux/esd/docs/latest/linux/Foundational_Components_OpenCV.html#unit-tests using PLSDK 5.2 filesystem. 

    In the unit test, there are a few examples using SVM.

    To do OpenCL offload, please following instruction in software-dl.ti.com/.../Foundational_Components_OpenCV.html

    Rex

  • Hi Rex,

    I have used PLSDK 5.2 filesystem to test today, it was not OK stilly !

    test.cpp:

    #include <iostream>
    #include <opencv2/opencv.hpp>
    #include <opencv2/core/ocl.hpp>
    #include <unistd.h>
    using namespace std;
    using namespace cv;
    using namespace cv::ml;

    int main()
    {
    int result = 0;
    float response;
    UMat inMat;

    cout<<"haveOpenCL:";
    cout<<cv::ocl::haveOpenCL()<<endl;
    cout<<"useOpenCL:";
    cout<<cv::ocl::useOpenCL()<<endl;
    cout<<"haveSVM:";
    cout<<cv::ocl::haveSVM()<<endl;

    Ptr<SVM> svm = Algorithm::load<SVM>("model.xml");
    char buffer[40];
    for(int i=0;i<100;i++){
        memset(buffer,0,sizeof(buffer));
        sprintf(buffer,"./data/test_image/0/%d.jpg",i+400);
        imread(buffer).copyTo(inMat);
        UMat p = inMat.reshape(1, 1);
        p.convertTo(p, CV_32FC1);
    if(i==99){//while 1
        i=0;
        response = svm->predict(p);
    }
    if (response == 0)
    {
    result++;
    }
    }
    cout<<result<<endl;
    return 0;
    }

    root@am57xx-evm:/opt# ./TEST_SVM

    haveOpenCL:1

    useOpenCL:1

    haveSVM:0

    top to check cpu used:
    TEST_SVM used 94% CPU, it didn't used DSP by opencl.
    1144 root 20 0 267156 18644 15720 R 94.1 1.0 0:15.68 TEST_SVM

    I run the OpenCV Unit Test (test ./cpp-tutorial-non_linear_svms only with opencl opened), the cpu was fully running 100% without dsp run. I want the svm->predict running on dsp !
    root@am57xx-evm:/usr/share/OpenCV/samples/bin# ./cpp-tutorial-non_linear_svms
    1351 root 20 0 74192 16584 13556 R 100.0 0.9 0:15.13 cpp-tutori+

  • top to check cpu used:
    TEST_SVM used 94% CPU, it didn't used DSP by opencl.
    1144 root 20 0 267156 18644 15720 R 94.1 1.0 0:15.68 TEST_SVM
  • I run the OpenCV Unit Test (test ./cpp-tutorial-non_linear_svms only with opencl opened), the cpu was fully running 100% without dsp run. I want the svm->predict running on dsp !


    root@am57xx-evm:/usr/share/OpenCV/samples/bin# ./cpp-tutorial-non_linear_svms
    1351 root 20 0 74192 16584 13556 R 100.0 0.9 0:15.13 cpp-tutori+
  • Hi, Guotao,

    Are you compiling on AM5728 EVM natively? If not, could you try the following?

    Remove those "cout <<" lines and compile your test code natively on AM5728 EVM following the instruction in OpenCV User Guide with the compilation command:
    g++ -I/usr/local/include/opencv -I/usr/local/include/opencv2 -L/usr/local/lib/ -g -o test_SVM test.cpp -lrt -lopencv_core -lopencv_imgproc -lopencv_video -lopencv_features2d -lopencv_imgcodecs -lopencv_ml

    Then run your test using the following commands on AM5728 and check dsp usage.

    export TI_OCL_LOAD_KERNELS_ONCHIP=Y
    export TI_OCL_CACHE_KERNELS=Y
    export OPENCV_OPENCL_DEVICE='TI AM57:ACCELERATOR:TI Multicore C66 DSP'
    ./test_SVM

    This should be the way to do OpenCL offload per TI OpenCV User Guide. I am not familiar with OpenCV/SVM coding so I can't help much or the coding. If you look at the canny example in OpenCV User Guide, you should just code your application as usual, but with TI OpenCL offload commands by exporting those env variables. In canny example, BGR2GRAY, GaussianBlur, etc. are offloaded to DSP. Same offload method should be used when running unit test.

    Rex