OpenCV 点类型转换
OpenCV Point Type Conversion
OpenCV 文档指出在 Point class 中有一个成员函数可以在数据类型(int --> float 等)之间进行转换。文档为 "conversion to another data type".
宣传以下功能
cv::Point_< _Tp >::operator Point_< _Tp2 > () const
我无法让它工作。我尝试了以下方法。
cv::Point2i test(0,0);
cv::Point2f out;
test.Point <Point2f>;
或
cv::Point2i test(0,0);
cv::Point2f out;
test.operator Point<Point2f>;
有人用过这个功能吗?
这是 user-defined conversion function 的一个例子。您使用强制转换调用它。
#include <opencv2/opencv.hpp>
int main()
{
cv::Point2i foo(1, 2);
cv::Point2f bar;
bar = static_cast<cv::Point2f>(foo);
std::cout << foo << "\n" << bar << "\n";
return 0;
}
输出:
[1, 2]
[1, 2]
OpenCV 文档指出在 Point class 中有一个成员函数可以在数据类型(int --> float 等)之间进行转换。文档为 "conversion to another data type".
宣传以下功能cv::Point_< _Tp >::operator Point_< _Tp2 > () const
我无法让它工作。我尝试了以下方法。
cv::Point2i test(0,0);
cv::Point2f out;
test.Point <Point2f>;
或
cv::Point2i test(0,0);
cv::Point2f out;
test.operator Point<Point2f>;
有人用过这个功能吗?
这是 user-defined conversion function 的一个例子。您使用强制转换调用它。
#include <opencv2/opencv.hpp>
int main()
{
cv::Point2i foo(1, 2);
cv::Point2f bar;
bar = static_cast<cv::Point2f>(foo);
std::cout << foo << "\n" << bar << "\n";
return 0;
}
输出:
[1, 2]
[1, 2]