How to use apexcv::LKPyramidOpticalFlow

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use apexcv::LKPyramidOpticalFlow

213 Views
user123
Contributor I

According to The APEX-CV Library document, apexcv::LKPyramidOpticalFlow::Initialize has following arguments: aSrc0Desc, aSrc1Desc, aCoor0Desc, aCoor1Desc, aCoor1Desc_O.
I want to know meaning of aCoor0Desc, aCoor1Desc, and aCoor1Desc_O.

The arguments of apexcv::LKPyramidOpticalFlow is not corresponding to OpenCV function (cv::calcOpticalFlowPyrLK).

I think aCoor0Desc and aCoor1Desc are input point list which is tracking feature of aSrc0Desc and aSrc1Desc, and aCoor1Desc_O is output point list which is detected flow.

However, on my code, X/Y coordinate of aCoor1Desc_O becomes always (0,0) even if "reverve" field in output "Feature32S" is 1.

 

my code:

// Prepare buffer

const int CORNERS_MAX = 400;
uint8_t features_cur_[sizeof(icp::Feature32S) * CORNERS_MAX] = {0};
uint8_t features_prev_[sizeof(icp::Feature32S) * CORNERS_MAX] = {0};
uint8_t features_out_[sizeof(icp::Feature32S) * CORNERS_MAX] = {0};
icp::Feature32SDescriptor features_cur((void *)features_cur_, (void *)features_cur_, CORNERS_MAX);
icp::Feature32SDescriptor features_prev((void *)features_prev_, (void *)features_prev_, CORNERS_MAX);
icp::Feature32SDescriptor features_out((void *)features_out_, (void *)features_out_, CORNERS_MAX);
{
    std::vector<cv::Point2f> features_cur_v;
    std::vector<cv::Point2f> features_prev_v;
    cv::goodFeaturesToTrack((cv::UMat)frame_prev, features_prev_v, CORNERS_MAX, 0.01, 3.0, cv::Mat(), 7, true, 0.08); // use OpenCV GFTT
    cv::goodFeaturesToTrack((cv::UMat)frame_cur, features_cur_v, CORNERS_MAX, 0.01, 3.0, cv::Mat(), 7, true, 0.08);
    for(cv::Point2f feature_cur : features_cur_v)
    {
        features_cur.Add(((int)feature_cur.x) << 8, ((int)feature_cur.y) << 8);
        features_out.Add(((int)feature_cur.x) << 8, ((int)feature_cur.y) << 8); // apexcv::LKPyramidOpticalFlow requires features_out.getCount() >= features_cur.getCount()
    }
    for(cv::Point2f feature_prev : features_prev_v)
    {
        features_prev.Add(((int)feature_prev.x) << 8, ((int)feature_prev.y) << 8);
    }
}

// Execute ApexCV
apexcv::LKPyramidOpticalFlow apex_processor;
apex_processor.Initialize(
    /*aSrc0Desc*/ frame_prev,
    /*aSrc1Desc*/ frame_cur,
    /*aCoor0Desc*/ features_prev,
    /*aCoor1Desc*/ features_cur,
    /*aCoor1Desc_O*/ features_out,
    /*aMaxCorners*/ CORNERS_MAX,
    /*aW*/ frame_cur.cols, /*aH*/ frame_cur.rows, /*aPyrLayers*/ 4, /*aBoxSize*/ 7, /*aNumIter*/ 10, /*aReqPadding*/1
);
apex_processor.Process();

Labels (2)
0 Kudos
1 Reply

154 Views
bpe
NXP TechSupport
NXP TechSupport

Please be aware, that support to S32V234 Vision subsystem modules is done only via tickets. This Community is not appropriate for questions of this kind. I will contact you by e-Mail with respect to this issue, for future requests, please

use only tickets.

 

 


Have a great day,
Platon

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos