3 метода рисования точки с помощью OpenCV: круг, маркер и линия

Чтобы нарисовать точку с помощью OpenCV, вы можете использовать следующие методы:

  1. Метод 1: использование функции cv2.circle

    import 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. Метод 2: использование функции cv2.drawMarker

    import 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. Метод 3: использование функции cv2.line

    import 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()