C++ OpenCV从点向量获取边界框

Sta*_*dik 5 c++ opencv

我有自己画的点数:

std::vector<CvPoint> shape1 = paintshape(0);
Run Code Online (Sandbox Code Playgroud)

http://s29.postimg.org/brkfri6uv/box.jpg

现在我需要在这个形状周围得到一个边界框对象(点),

我在网上搜索了答案,但每个主题都在讨论识别whol图像文件中某些对象的边缘,然后制作边界框.

在我的情况下它是不同的,

谢谢 !

ber*_*rak 7

获取你的积分的boundingRect:

#include "opencv2/imgproc/imgproc.hpp"

// please use stuff from the cv:: namespace, not the outdated Cv*
std::vector<cv::Point> shape1 = paintshape(0); 
cv::Rect r = cv::boundingRect(shape1);
Run Code Online (Sandbox Code Playgroud)