我想在我的 C++ 项目中将 OpenCV 中的点 vector ( vector )转换为 C# 点列表(Collections::Generic::List)。
我写了一些如下代码,但没有用:
vector<Point2f> oldPoints;
Collections::Generic::List<Windows::Point>^ points;
for (int i = 0; i < oldPoints.rows; i++)
{
points -> Add(Windows::Point(oldPoints.at<Point2f>(i,0).x,oldPoints.at<Point2f>(i,0).y));
}
有人能帮帮我吗?我哪里做错了?
我找不到适合我的问题的答案;任何帮助或线索将不胜感激。
最佳答案
oldPoints
是 std::vector
,但您可以像使用 cv::Mat
一样使用它。正确的代码是:
vector<Point2f> oldPoints;
Collections::Generic::List<Windows::Point>^ points
= gcnew Collections::Generic::List<Windows::Point>();
for (size_t i = 0; i < oldPoints.size(); i++)
{
points->Add(Windows::Point(oldPoints[i].x, oldPoints[i].y));
}
关于c# - 将openCV的vector<Point2f>转换为C#的Collections::Generic::List<Windows::Point>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19543699/