c++ - 直接减去两个 vector<point2f>

标签 c++ opencv vector

我必须减去两个 Point2f 类型的 vector (两者大小相同)。我知道这可以通过提取每个索引处的值然后在循环中减去它们来完成,但是有直接的方法吗?有点像

Vector<Point2f> A[3];
A[2] = A[1] - A[0];

最佳答案

只是为了运动;)

std::vector<Point2f> A,B;
A.push_back(Point2f(1,2));
A.push_back(Point2f(3,4));
A.push_back(Point2f(5,6));
B.push_back(Point2f(5,2));
B.push_back(Point2f(4,4));
B.push_back(Point2f(3,6));

// Mat C; subtract(A,B,C);
Mat C = Mat(A) - Mat(B);
cout<< A << endl << B << endl <<C<<endl;



[1, 2;  3, 4;  5, 6]
[5, 2;  4, 4;  3, 6]
[-4, 0;  -1, 0;  2, 0]

关于c++ - 直接减去两个 vector<point2f>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22745417/

相关文章:

c++ - 咖啡转换图像集 : symbol lookup error

c++ - 如何最好地填充 vector (避免浪费内存以及不必要的分配和取消分配)?

c++ - 使用 CMake 获取预处理器定义值

c++ - 类模板中的静态成员变量

c++ - 痛饮 mysql : undefined symbol: mysql_init'

image-processing - opencv中Canny操作自动计算高低阈值

python - 如何从图像中提取表格数据?

c++ - 没有匹配的调用函数

c++ - C++ 中的 vector 问题

c++ - 在 QGraphicsView 中获取 QGraphicsScene 的可见区域