python cv2 how to update image 1

python cv2 how to update image

# Call imshow multiple times to update image.
# waitKey(milliseconds) waits a number of milliseconds before updating the image
while True:
    cv2.imshow('image', img)
    cv2.waitKey(1)

Here is what the above code is Doing:
1. Create a new image with a black background
2. Draw a red circle at the center of the image
3. Draw a green rectangle at the center of the image
4. Draw a blue line from the top left corner to the bottom right corner
5. Draw a yellow line from the bottom left corner to the top right corner
6. Display the image
7. Wait for a key press
8. Destroy the window

Similar Posts