【发布时间】:2017-02-26 04:36:02
【问题描述】:
我想从我的图片中获取轮廓的坐标。我想将其保存为 .txt 文档。
首先我创建了:
vector<vector<cv:Pont> >extract<cv::Mat &binaryImage){
vector<vector<cv::Point> > coordinatesContours;
cv::findContours(binaryImage, coordinatesContours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
return coordinatesContours;
}
我在我的 Main 中调用该函数:
oTest.extract(binaryImage);
现在我想将坐标作为输出导出到 .txt
我的功能:
void Export(vector<vector<cv::Point> > coordinatesContours){
string json;
json = "{\n\t\t \"vertices\" : [\n\t\t\t\t";
for(int i=0; i< coordinatesContours.size; i++)
for(int j=0; i< coordinatesContours.size; j++)
cout << i << "(" << coordinatesContours[i][j].x << ", " << coordinatesContours[i][j].y << ")" << endl;
但是我怎样才能完成我的任务呢??
以及如何在我的 Main 中调用它??
请帮忙 谢谢
【问题讨论】:
-
为什么你的第一个函数不完整?如果您发布所有功能,无论您是否在课堂上使用它都会有所帮助
-
顺便说一句,在您发布的功能中,您在这里有一个拼写错误:
vector<vector<cv:Pont> >extract<cv::Mat &binaryImage){您需要将Pont更改为Point