motionDetect.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:Image-Processing-and-Steganogrphy 作者: motkeg 项目源码 文件源码
def Q2():
    cap = cv2.VideoCapture(0)

    while(cap.isOpened() ):
        ret = cap.set(3,320)
        ret = cap.set(4,240)
        ret, frame = cap.read()

        if ret==True:
            gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
            x,thresh = cv2.threshold(gray,137,255,1)
            contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
            cv2.drawContours(frame, contours,-1, (0,255,0), 3)
            cv2.imshow('Image with contours',frame)    
            if cv2.waitKey(1) & 0xFF == ord('q'):
                break
        else:
            break

    cap.release()
    cv2.destroyAllWindows()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号