Stav Bodik
Stav Bodik

Reputation: 2134

C++ OpenCV get Bounding Box From Vector Of Points

I have vector of points i drawed by my self :

std::vector<CvPoint> shape1 = paintshape(0);

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

Now i need to get a bounding box object (points) around this shape ,

i have searched the web for answeres but every topic is talking about recognizing the edge of some object inside whol image file and then making the bounding box.

in my case its different ,

Thanks !

Upvotes: 5

Views: 12668

Answers (1)

berak
berak

Reputation: 39796

get the boundingRect for your points:

#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);

Upvotes: 9

Related Questions