Here's the code I use to create new image, draw a circle onto it and show it:
import numpy as np
import cv2
# create 50x50 image, filled with white
img = np.ones((50,50))
# draw a circle onto the image
cv2.circle(img, (25,25), 10, 0, 2, lineType=cv2.LINE_AA)
# show the image on the screen
cv2.imshow("i", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
However, no antialiasing seems to be applied (I upscaled the image x10):
What am I doing wrong?
If the image depth is not CV_8U
, the line_type
is automatically set to 8
.
From opencv/modules/imgproc/src/drawing.cpp
:
if( line_type == CV_AA && img.depth() != CV_8U )
line_type = 8;
Since the type of numpy.ones
defaults to numpy.float64
, you're losing the antialiased line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With