OpenCV tracking using optical flow

前端 未结 2 1372
忘掉有多难
忘掉有多难 2020-11-29 22:56

I use this to functions as a base of my tracking algorithm.

    //1. detect the features
    cv::goodFeaturesToTrack(gray_prev, // the image 
    features,           


        
2条回答
  •  孤街浪徒
    2020-11-29 23:08

    cv::calcOpticalFlowPyrLK(..) function uses arguments :

    cv::calcOpticalFlowPyrLK(prev_gray, curr_gray, features_prev, features_next, status, err);

    cv::Mat prev_gray, curr_gray;
    std::vector features_prev, features_next;
    std::vector status;
    std::vector err;
    

    simplest(partial) code to find pixel in next frame :

    features_prev.push_back(cv::Point(4, 5));
    cv::calcOpticalFlowPyrLK(prev_gray, curr_gray, features_prev, features_next, status, err);
    

    If pixel was successfully found status[0] == 1 and features_next[0] will show coordinates of pixel in next frame. Value information can be found in this example: OpenCV/samples/cpp/lkdemo.cpp

提交回复
热议问题