读取一个pts文件到一个vector<Point2f>里面。

其中pts文件如下:

version:
n_points:
{ }
#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <fstream>
#include<iostream>
#include <sstream>
#include <vector>
#include <string>
#include <fstream>
#include <iostream> #ifdef __APPLE__
#include <sys/uio.h>
#else
#include <sys/io.h>
#endif using namespace cv;
using namespace std; vector<Point2f> readpts(){
ifstream myfile("1.pts");
string temp;
if (!myfile.is_open())
{
cout << "未成功打开文件" << endl;
}
vector<Point2f> vp2f;
int index=;
while(getline(myfile,temp)) {
if((index>=)&&(index<)){
Point2f p1;
int a[]={};
istringstream iss;//istringstream提供读 string 的功能
iss.str(temp);//将 string 类型的 test 复制给 iss,返回 void
string s;
int i=;
while (iss >> s){
int x = stoi(s);
// cout << x << endl;//按空格读取string
a[i]=x;
i++;
}
p1.x=a[];
p1.y=a[];
vp2f.push_back(p1);
}
index++; } return vp2f;
} int main(){ Mat img=imread("1.jpg"); vector<Point2f> landmark= readpts(); for (int idx = ; idx < landmark.size(); idx++) {
cv::circle(img, landmark[idx], , cv::Scalar(, , ), -);
}
imshow("img",img);
cvWaitKey();
return ;
}

最新文章

  1. 【ZJOI2008】 树的统计 count
  2. w3svc服务启动 不了,错误 1068:依赖服务或组件无法启动
  3. 原创QQ影音DLL劫持漏洞+动画实战教程
  4. UVa 7146 Defeat the Enemy(贪心)
  5. splice 很好用
  6. paip.信用卡账单处理分类bug o21
  7. CentOS上安装Node.js
  8. CentOS 6.5 网络配置(转载)
  9. CodeForces 705B Spider Man (水题)
  10. createjs 使用记录
  11. Java实现简单版SVM
  12. I - Navigation Nightmare-poj 1984
  13. 在IIS集成管道中使用OWIN Middleware
  14. Struts2-整理笔记(五)拦截器、拦截器配置
  15. redis4.0 集群,jedis客户端连接配置
  16. bootstrapt 使用遇到问题
  17. 00SQL表字段说明
  18. 【IDE】我的花里胡哨VS
  19. 【洛谷】【搜索+剪枝】P1731 [NOI1999]生日蛋糕
  20. Android应用更新-自动检测版本及自动升级

热门文章

  1. (面试)Statement和PrepareStatement有什么区别
  2. Android开发中的神坑和知识点记录
  3. office2010激活 错误代码0X8007000D,KMS激活0x8007000D错误解决办法,亲测成功激活
  4. Android Logcat信息级别解读
  5. GitHub 上值得推荐的开源电子书
  6. 腾讯企业邮箱SMTP-邮件发送失败异常:“ SMTPSendFailedException:501 &#207;&#181;&#205;&#179;&#210;&#209;&#199;&#191;&#214;&#198;&#191;&#170;&#198;&#244;&#213;&#202;&#186;&#197;&#201;&#253;&#188;&#182;&#201;&#232;&#214;&#195;&#163;&#172;&#199;&#235;&#181;&#199;&#194;&#188;e
  7. private static final long serialVersionUID = 1L;
  8. Android App开发技能图谱(转载)
  9. 【Unity】6.5 Time类、Mathf类、Coroutine类
  10. iOS7.0中UILabel高度调整注意事项