I was using opencv to open a camera stream and to take photos with it (Windows PC). The Webcam (NexiGo N660P 60FPS 1080P) can record videos with 1920x1080 pixels. So the code i used worked an i was getting sharp images:
cam = cv2.VideoCapture(0)
cam.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
cv2.namedWindow("Bild")
global img_counter
img_counter = 0
while True:
ret, frame = cam.read()
if not ret:
print("Fehler")
break
cv2.imshow("Bild", frame)
k = cv2.waitKey(1)
if k%256 == 27:
print("Kamerastream geschlossen")
break
elif k%256 == 32:
img_name = "Foto_{}.png".format(img_counter)
cv2.imwrite(img_name, frame)
print("{} gespeichert".format(img_name))
img_counter += 1
cam.release()
cv2.destroyWindow("Bild")
I have not changed anything and since a week now the camera does not focus anymore (Edit: it no longer focuses on the right level. So the autofocus still works, but not as before), when i run this code with python. When im running the code without setting the resolution, the autofocus works normally and i get sharp images again. When i record a video stream with the standard camera app on my pc, the autofocus works normally too, even at 1920x1080 pixels, just as it did before in the program.
Since I have not changed anything and have not made any updates, I wonder why it no longer works. I would be very happy for help :)
->I made a few restarts and also tried the code away from the original program (GUI application), but the result remained the same.