Ask Your Question

Ruotian's profile - activity

2014-07-11 15:39:12 -0600 received badge  Student (source)
2014-07-11 10:18:33 -0600 asked a question Different result of ocl::HOGDescriptor and cv::HOGDescriptor on OpenCV2.4.9

I am trying to modify a previous cpu program to now gpu version.

However, in the previous program, we used cv::HOGDescriptor::compute to get the descriptor, and now I used ocl::HOGDescriptor::getDiscriptors to get the descriptor. However, I compare the two descriptors together, I found that the results are not the same. Actually some dimension are really similar or even equal, but many dimensions really differ a lot.

Here is the code.

    cv::Mat temp_img;
    resize(img, temp_img, cv::Size(img.cols*shrinkRatio, img.rows*shrinkRatio));

    //gpu
    cv::Mat temp_img4ocl;
    cvtColor(temp_img, temp_img4ocl, CV_BGR2BGRA);//for gpu

    //both
    int temp_winStride = winStride*shrinkRatio;

    if (mode!=MODE_GPU){
        vector<float> temp_dscrpt;
        HOG[i].compute(temp_img, temp_dscrpt, cv::Size(temp_winStride, temp_winStride), cv::Size(0,0));
        dscrpt[0].push_back(temp_dscrpt);
    }

    if (mode!=MODE_CPU){
        cv::ocl::oclMat temp_ocl_img,temp_ocl_dscrpt;
        temp_ocl_img.upload(temp_img4ocl);
        ocl_HOG[i].getDescriptors(temp_ocl_img,cv::Size(temp_winStride, temp_winStride),temp_ocl_dscrpt);
        cv::Mat temp_mat_dscrpt(temp_ocl_dscrpt);
        vector<float> temp_dscrpt4ocl;
        temp_dscrpt4ocl=temp_mat_dscrpt.reshape(1,1);
        dscrpt[1].push_back(temp_dscrpt4ocl);
    }

I don't know if it's the problem of algorithm of gpu HOG. Can anyone help me to figure out what's the problem.