Hi everyone, I am trying to draw partial ellipses in a cv::Mat but I am running into an issue.
I want to draw a cake slice, 20° wide oriented toward the upper right corner.
For a cv::Mat 300x300, if the axis parameter is greater than 260, the slice is not filled but only the outline is drawn. Here is the code:
int main(int argc, char* argv[]) {
cv::Mat mat1(300, 300, CV_8UC1);
mat1.setTo(0);
cv::Mat mat2(300, 300, CV_8UC1);
mat2.setTo(0);
cv::Mat mat3(300, 300, CV_8UC1);
mat3.setTo(0);
cv::Mat mat4(300, 300, CV_8UC1);
mat4.setTo(0);
int axis = 270;
cv::ellipse(mat1, cv::Point2i(mat1.cols*0.5f, mat1.rows * 0.5f),
cv::Size(axis, axis), -45, +10, -10, cv::Scalar(255), -1);
cv::ellipse(mat2, cv::Point2i(mat2.cols*0.5f, mat2.rows * 0.5f),
cv::Size(axis, axis), -45, +20, -20, cv::Scalar(255), -1);
cv::ellipse(mat3, cv::Point2i(mat3.cols*0.5f, mat3.rows * 0.5f),
cv::Size(axis, axis), 45, +10, -10, cv::Scalar(255), -1);
axis = 260;
cv::ellipse(mat4, cv::Point2i(mat4.cols*0.5f, mat4.rows * 0.5f),
cv::Size(axis, axis), -45, +10, -10, cv::Scalar(255), -1);
cv::imshow("MAT1", mat1);
cv::imshow("mat2", mat2);
cv::imshow("mat3", mat3);
cv::imshow("mat4", mat4);
cv::waitKey(0);
return 0;
}
The mat1 show that the ellispe is not filled. Mat2 only opens the angular portion that is drawn from 20° to 40°. This image is filled. Mat3 is the same as mat1 but oriented towards 45° instead of -45°. Mat4 is similar to mat1 but with a lower axis length (260px instead of 270).
Looking at the cv::ellipse's doc, I haven't been able to understand what I was doing wrong.
Any idea what it can be?
Thanks in advance!
Ps: I tried with CV_32F1 images and the result is close, only the threshold changes.