Чтобы нарисовать точку с помощью OpenCV, вы можете использовать следующие методы:
-
Метод 1: использование функции
cv2.circleimport cv2 import numpy as np # Create a black image image = np.zeros((500, 500, 3), dtype=np.uint8) # Draw a point at (250, 250) with a radius of 3 and color (0, 0, 255) representing red cv2.circle(image, (250, 250), 3, (0, 0, 255), -1) # Display the image cv2.imshow("Image with point", image) cv2.waitKey(0) cv2.destroyAllWindows() -
Метод 2: использование функции
cv2.drawMarkerimport cv2 import numpy as np # Create a black image image = np.zeros((500, 500, 3), dtype=np.uint8) # Draw a point at (250, 250) with a marker type of cv2.MARKER_CROSS and size 10 cv2.drawMarker(image, (250, 250), (0, 0, 255), markerType=cv2.MARKER_CROSS, markerSize=10) # Display the image cv2.imshow("Image with point", image) cv2.waitKey(0) cv2.destroyAllWindows() -
Метод 3: использование функции
cv2.lineimport cv2 import numpy as np # Create a black image image = np.zeros((500, 500, 3), dtype=np.uint8) # Draw a line of length 1 pixel at (250, 250) with color (0, 0, 255) representing red cv2.line(image, (250, 250), (250, 250), (0, 0, 255), thickness=1) # Display the image cv2.imshow("Image with point", image) cv2.waitKey(0) cv2.destroyAllWindows()