OpenCV:vector数据类型转换

1.vector<Point2f> 和 vector<Point2i>之间相互转换

  1. vector<Point2f>===> vector<Point2i>

    cv::Mat(vector<Point2f>).convertTo(vector<Point2i>,CV_32SC1);
    //这种方式转换会将2.4转换为2;3.5转换为4;-3.4转换为-3,-3.5转换为-4;其他依次类推。类似于cvRound()

    1. vector<Point2i>===> vector<Point2f>

    cv::Mat(vector<Point2i>).convertTo(vector>Point2f>,CV_32FC1);


3.其他3f,3i之类的类似;基本思想:f表示float,4字节(32位),那么等同于32F;

2.Mat —> vector<Point2f> or vector<Point3f> :

用“Mat_<Point2f>“ 和“Mat_<Point3f>”

Mat m;
vector<Point3f> p;
p = Mat_<Point3f>(m);//说明:从Mat的首个元素开始,按照顺序,3个一组作为向量,因此P.size()为:m.cols*m.rows/3;
// 需要注意的是,m的类型。在我的项目中m均采用CV_32FC1类型,F是因为Point3f中的点集为float类型

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值