1 | initial version |
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);
}