2

I'm using python 2.7 on DragonBoard 410c with Debian OS to capture webcam Logitech C920 by opencv but get a white sceen result.

Here is my whole code.

import cv2

cap = cv2.VideoCapture(0)
cap.set(3,1280)
cap.set(4,720)

while(cap.isOpened()):
  ret, frame = cap.read()
  gray = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA)
  cv2.imshow('frame', gray)
  if cv2.waitKey(1) & 0xFF == ord('q'):
    break

cap.release()
cv2.destroyAllWindows()

It worked well without the code "cap.set(3,1280)" and "cap.set(4,720)". I can get the frame with 640x480.

but if I added the code to change the resolution, the window would change but the frame is white.

https://i.stack.imgur.com/HDBgR.jpg

By the way, if I set the resolution to 800x600, the frame will flash between white sceen and camera view.

How can I solve this problem?

Richard Chambers
  • 16,643
  • 4
  • 81
  • 106
  • Please do not post pictures of code. use the markdown editor to add code. https://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks – Shawn Mathew Aug 14 '19 at 16:55
  • I'm unable to replicate your error. the only thing i would recommend is added a check to see if the frame was returned correctly using `ret, frame = cap.read(); if ret== True` – Shawn Mathew Aug 14 '19 at 17:12
  • @ShawnMathew Sorry, had added the code, and yeah,the ret returned true. – 桜庭想瑠 Aug 15 '19 at 01:25

0 Answers0