yangakw yangakw

opencv python读取视频

in 记录read (149) 文章转载请注明来源!
import cv2
import numpy as np

 

cap = cv2.VideoCapture(0)
while(1):
    # get a frame
    ret, frame = cap.read() 
    gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)  
    gray = cv2.GaussianBlur(gray, (21, 21), 0)
    
    edge = cv2.Canny(gray.copy(), 1000, 2000, apertureSize=5)
    _,contours, hierarchy = cv2.findContours(edge.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) 
    for i in contours:
        x, y, w, h = cv2.boundingRect(i)
        print x,y
 
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break 
cap.release()
cv2.destroyAllWindows() 

opencv包

import cv2
摄像头对象,0是第一个摄像头
cap = cv2.VideoCapture(0)
读取
ret, frame = cap.read()

jrotty WeChat Pay

微信打赏

jrotty Alipay

支付宝打赏

文章二维码

扫描二维码,在手机上阅读!

发表新评论
博客已运行
© 2017 yangakw
PREVIOUS NEXT
雷姆
拉姆