when I am running this simple code in my notebook with opencv-python version v4.3.0. Then my screen is filled with windows as shown in image.
# importing the required modules
import cv2
import numpy as np
# capturing from the first camera attached
cap = cv2.VideoCapture(0)
# will continue to capture until 'q' key is pressed
while True:
ret, frame = cap.read()
# Capturing in grayscale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame', frame)
cv2.imshow('gray', gray)
# Program will terminate when 'q' key is pressed
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Releasing all the resources
cap.release()
cv2.destroyAllWindows()
I had the same problem with OpenCV 4.3.0. How I solved it:
1/ Uninstall the previous version:
$ pip uninstall opencv-contrib-python
2/ Install a previous version:
$ pip install opencv-contrib-python==4.2.0.34
It should work now.
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