0

Logitech c270 camera not taking pictures on linux(ubuntu) with open-cv python. I have also tried adding delays, installing drivers in the terminal, and almost everything but still takes a blacked-out picture. *also with index(0) it takes photo within like 1 sec but with index(3) i.e my logitech camera it takes the blacked-out photo in milliseconds!

import cv2

cap = cv2.VideoCapture(3)

if not cap.isOpened():
    print("Cannot open camera")
    exit()

# Read a frame from the camera
ret, frame = cap.read()

if ret:
    cv2.imwrite("photo.jpg", frame)

# Release the camera and close all windows
cap.release()
cv2.destroyAllWindows()
  • I tried an older camera same model like 2 months old code works there, I have bought two new ones but it occurs in both of them.
  • I tried on C920 logitech the code works there also.
  • I have 4 of them C270, opened two both had the fault, I think all of them would have it, so I can't risk opening all.
  • I have also tried adding delays, installing drivers in the terminal, and almost everything but still takes blacked-out picture.
  • *also with index (0) it takes a photo within like 1 sec but with index (3) i.e my logitech camera it takes the blacked-out photo in milliseconds!
Ajeet Verma
  • 2,938
  • 3
  • 13
  • 24
  • Does the camera work when you use linux webcam tools like cheese (cheese is usually pre-installed)? – Klops May 05 '23 at 09:17
  • You have 3 cameras. You can do this cap = cv2.VideoCapture(0) cap1 = cv2.VideoCapture(1) and so on. – toyota Supra May 05 '23 at 11:58
  • You have multiple cameras, so to minimize complexity and confusion, I highly recommend using unique paths in ``/dev/v4l/`` subdirectory (see my answer https://stackoverflow.com/a/76184335/1510289) instead of the enumerations you're using currently. – Velimir Mlaker May 05 '23 at 17:17

0 Answers0