Different result of ocl::HOGDescriptor and cv::HOGDescriptor on OpenCV2.4.9

asked 2014-07-11 10:18:33 -0500

Ruotian gravatar image

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));

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

    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));

    if (mode!=MODE_CPU){
        cv::ocl::oclMat temp_ocl_img,temp_ocl_dscrpt;
        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;

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.

edit retag flag offensive close merge delete