python - OpenCV cv2.VideoCapture(0) is not working well with webcam -


i trying use usb webcam computer vision project on raspberry pi outputs diminations of moving object. installed opencv , tried python code worked perfect on pc, when ran in raspberry pi b+ , output unexpected took video output cv2.imshow("video output", frame) see whats going on , saw thing strange. video flickering part red , part blue.


view porblem

although code worked perfect in pc maybe can help, here code:

import argparse import datetime import imutils import time import cv2 import numpy np  ap = argparse.argumentparser() ap.add_argument("-v", "--video", help="path video") ap.add_argument("-a", "--min-area", type=int, default = 200, help="min area") args=vars(ap.parse_args())  if args.get("video", none) none:     camera = cv2.videocapture(0)     camera.set(cv2.cv.cv_cap_prop_fps,2)     camera.set(cv2.cv.cv_cap_prop_frame_width,640)     camera.set(cv2.cv.cv_cap_prop_frame_height,480)     time.sleep(2.5) else:     camera = cv2.videocapture(args["video"])  while true:     (grabbed, frame) = camera.read()     if not grabbed:         break     frame = imutils.resize(frame, width=500)     cv2.imshow("testing",frame)     key = cv2.waitkey(1) & 0xff     if key == ord("q"):         break  camera.release() cv2.destroyallwindows() 

it turns out problem video source. webcam not compatible opencv although worked other computer video input package well


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -