本文整理汇总了C++中Motion::getVx方法的典型用法代码示例。如果您正苦于以下问题:C++ Motion::getVx方法的具体用法?C++ Motion::getVx怎么用?C++ Motion::getVx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Motion
的用法示例。
在下文中一共展示了Motion::getVx方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowMotion
void LKTracker::ShowMotion(cv::Mat& image)
{
MotionVector::iterator iter;
// TRUE- 1 is Right | FALSE- 0 is Left
int motionR, motionL, motionLast, motionLongestL, motionLongestR;
double motionSumL, motionSumR;
for(iter = this->regions.begin(); iter != this->regions.end(); ++iter)
{
Motion *motion = (*iter);
motionR = 0;
motionL = 0;
motionLast = 0;
motionLongestR = 0;
motionLongestL = 0;
motionSumL = 0;
motionSumR = 0;
cv::Rect origin = motion->getRect();
cv::rectangle(image, origin, CV_RGB(255, 0, 255), 2);
for(int i = 0; i < motion->getVx().rows; i++)
{
for(int j = 0; j < motion->getVx().cols; j++)
{
double x_component = motion->getVx().at<double>(i,j);
double y_component = motion->getVy().at<double>(i,j);
//std::cout << "vx " << x_component << " vy " << y_component << std::endl;
cv::Point p1 = cv::Point(j+origin.x, i+origin.y);
cv::Point p2 = cv::Point(j+x_component+origin.x, i + y_component+origin.y);
// distance ?????
// if(cv::norm(px1-px2) < magnitude_treshold || cv::norm(py1-py2) < magnitude_treshold)
if(cv::norm(p1-p2) >= magnitude_treshold)
{
// Draw the vector
cv::circle ( image , p1 , 4 , cv::Scalar(0,255,0) , 2 , 8 );
cv::line(image, p1, p2, CV_RGB(255, 0, 0), 2);
cv::circle ( image , p2 , 1 , cv::Scalar(0,255,0) , 2 , 8 );
}
if(cv::norm(p1-p2) < 5)
{
continue;
}
if(detectMotion(p1, p2) == 1) {
motionSumR += std::abs(x_component);
motionR++;
} else if(detectMotion(p1, p2) == 0) {
motionSumL += std::abs(x_component);
motionL++;
}
/*
// detect gestures
if(detectMotion(p1, p2) == 1 && motionLast == 1)
{
++motionR;
motionLast = 1;
}
else if (detectMotion(p1, p2) == 1 && motionLast == 0)
{
motionR = 1;
motionLast = 1;
// check if last sequence of LEFTS- 0 was longest one
if (motionLongestL < motionL)
{
motionLongestL = motionL;
}
}
else if(detectMotion(p1, p2) == 0 && motionLast == 0)
{
++motionL;
motionLast = 0;
}
else if(detectMotion(p1, p2) == 0 && motionLast == 1)
{
motionL = 1;
motionLast = 0;
// check if last sequence of RIGHTS- 1 was longest one
if (motionLongestR < motionR)
{
motionLongestR = motionR;
}
}
*/
}
}
// print detected motion
//.........这里部分代码省略.........