1 | initial version |
First calculate your rectangles and save them in a vector.
std::vector<cv::Rect> rectangles;
calculate your Rectangles and add them in the vector with rectangles.push_back(cv::Rect(x,y, width, height))
Then draw the rectangles on your image:
for(int i = 0; i < rectangles.size(); i++){
cv::rectangle(img, rectangles[i], color, 1, 8, 0);
}
rectangles.clear();
This should definitely not take long. Also, switch to the new c++ style with cv::Mat and not the old IplImage
2 | No.2 Revision |
First calculate your rectangles and save them in a vector.
std::vector<cv::Rect> rectangles;
calculate your Rectangles and add them in the vector with rectangles.push_back(cv::Rect(x,y, width, height))
Then draw the rectangles on your image:
for(int i = 0; i < rectangles.size(); i++){
cv::rectangle(img, rectangles[i], color, 1, thickness, 8, 0);
}
rectangles.clear();
This should definitely not take long. Also, switch to the new c++ style with cv::Mat and not the old IplImage
3 | switched to c with arrays |
First calculate your rectangles and save them in a vector.Array (since its c only)
Since you want to use opencv 1.0, you need to save 2 opposite points for every rectangle (upper left and lower right for example)
std::vector<cv::Rect> rectangles;
CvPoint points1[9];
CvPoint points2[9];
calculate your Rectangles points and add them in to the vector arrays with rectangles.push_back(cv::Rect(x,y, width, height))
points1[i] = cvPoint(x,y) (upper left) and point2[i] = cvPoint(x,y) (lower right).
Make sure you have an iterator variable i.
Then draw the rectangles on your image:
for(int i j = 0; i j < rectangles.size(); i++){
i; j++){
cv::rectangle(img, rectangles[i], cvRectangle(img, points1[j], points2[j], color, thickness, 8, 0);
}
rectangles.clear();
This should definitely not take long. Also, switch to the new c++ style with cv::Mat and not the old IplImage