benjamin deworsop
benjamin deworsop

Reputation: 416

python opencv blocked image icon showing when reading image

Result of running simple opencv script

I have a small OpenCV script that works with my windows laptop camera but doesn't work when I plug in an external Logitech C922 Pro HD stream webcam.

I have changed the numbers around in cap = cv2.VideoCapture(xxxNUMBERxxx) to open the camera with no luck. I have also installed the Logitech drivers with no luck. The rest of the internet seems to think it's a permissions issue, but I can't find any specific permission settings so I'm not sure that's the issue. I just want to be able to get a video stream from the camera.

The script is below:

import numpy as np
import cv2

cap = cv2.VideoCapture(2, cv2.CAP_DSHOW)

while(True):
# Capture frame-by-frame
ret, frame = cap.read()

# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

# Display the resulting frame
cv2.imshow('frame',gray)

if cv2.waitKey(1) & 0xFF == ord('q'):
    break
    

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

Upvotes: 1

Views: 590

Answers (2)

animaonline
animaonline

Reputation: 3794

The solution is to completely uninstall the Logi Capture application.

Upvotes: 1

benjamin deworsop
benjamin deworsop

Reputation: 416

Turns out to be a strange and silly solution. After downloading the 'Logi Capture' app, I had to keep the app running with the video streaming through this app whilst opening up the OpenCV app. Seems like a workaround instead of a solution but it works for me.

Upvotes: 1

Related Questions