opencv计算两点间的距离
时间: 2023-11-07 17:53:18 浏览: 417
计算两点之间距离.
要计算两点之间的距离,可以使用以下代码片段:
```c++
#include <opencv2/opencv.hpp>
#include <cmath>
double getDistance(cv::Point pointO, cv::Point pointA) {
double distance;
distance = pow((pointO.x - pointA.x), 2) + pow((pointO.y - pointA.y), 2);
distance = sqrt(distance);
return distance;
}
int main() {
cv::Point pointO(0, 0); // 起点坐标
cv::Point pointA(3, 4); // 终点坐标
double distance = getDistance(pointO, pointA);
std::cout << "两点之间的距离为: " << distance << std::endl;
return 0;
}
```
阅读全文