Ask Your Question

ahundt's profile - activity

2013-10-08 15:53:52 -0600 received badge  Necromancer (source)
2013-10-07 14:54:38 -0600 answered a question Fill an image with the content of RotatedRect

fillConvexPoly() seems like the right solution. Here is the version I wrote based on Ben's answer:

 // default color is white
inline void drawRotatedRect(cv::Mat& image, cv::RotatedRect rRect, cv::Scalar color = cv::Scalar(255.0, 255.0, 255.0) ) {

   cv::Point2f vertices2f[4];
   cv::Point vertices[4];
   rRect.points(vertices2f);
   for(int i = 0; i < 4; ++i){
     vertices[i] = vertices2f[i];
   }
   cv::fillConvexPoly(image,
                      vertices,
                      4,
                      color);
}


// default color is white
inline void drawRectangle(cv::Mat& image, cv::Point center, cv::Size rectSizePixels, double rotDeg, cv::Scalar color = cv::Scalar(255.0, 255.0, 255.0) ) {

   cv::RotatedRect rRect(center, rectSizePixels, rotDeg); // opencv expects degrees
   drawRotatedRect(image,rRect);

}
2013-10-07 13:43:43 -0600 received badge  Supporter (source)