Pyramidal LK on GPU has Different Results than Its CPU Counterpart...

asked 2014-05-08 03:56:57 -0500

Hi All,

I've been trying to make use of GPU counterpart(i.e. the one running on CUDA) of Pyramidal LK method; however this method does not return approximately the same next-points as does its cpu counterpart. Here is how i implemented :

    lk                  = new PyrLKOpticalFlow();
    lk->useInitialFlow  = true;
    lk->winSize.width   = 4;
    lk->winSize.height  = 4;
    lk->iters           = 20;
    lk->maxLevel        = 5;
    cv::Mat status(1, num_points, CV_8UC1, (void*)out_lk_status);
    GpuMat dev_status;
    //For pts...
    cv::Mat prev_pts(1, num_points, CV_32FC2, (void*)pts_prev);
    cv::Mat cur_pts(1, num_points, CV_32FC2, (void*)out_pts_cur);
    cv::Mat i_cpu(310, 
                  470,
                  CV_8UC1,
                  (void*)(IMG[I]->imageData));
    cv::Mat j_cpu(310, 
                  470,
                  CV_8UC1,
                  (void*)(IMG[J]->imageData));
    GpuMat dev_prev_pts;
    GpuMat dev_cur_pts;
    GpuMat i_gpu(i_cpu);
    GpuMat j_gpu(j_cpu);

    dev_prev_pts.upload(prev_pts);
    dev_cur_pts.upload(cur_pts);
    lk->sparse(i_gpu,
               j_gpu,
               dev_prev_pts,
               dev_cur_pts,
               dev_status);
    dev_cur_pts.download(cur_pts);
    dev_status.download(status);

and this is the working copy of its cpu counterpart :

    cvCalcOpticalFlowPyrLK( IMG[I], IMG[J], PYR[I], PYR[J], points[0], points[1], nPts, cvSize(4,4), Level, status, 0, cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.03), CV_LKFLOW_INITIAL_GUESSES);

You can see the pixel results(for a particular pair of consecutive frames) in the following link.

prev_pts_gpu_pts_cpu_pts

What should i have suspicion of?

P.S. My OpenCV version is 2.4.8.2.

Kind Regards,
Ilker

edit retag flag offensive close merge delete