mypivideostream.py 文件源码

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

项目:hardware_demo 作者: llSourcell 项目源码 文件源码
def update(self):
        # keep looping infinitely until the thread is stopped
        for f in self.stream:
            # grab the frame from the stream and clear the stream in
            # preparation for the next frame
            self.frame = f.array
            self.rawCapture.truncate(0)

            # convert the image to grayscale, load the face cascade detector,
            # and detect faces in the image
            # Using data trained from here:
            #   http://www.pyimagesearch.com/2015/05/11/creating-a-face-detection-api-with-python-and-opencv-in-just-5-minutes/
            image = cv2.cvtColor(self.frame, cv2.COLOR_BGR2GRAY)
            detector = cv2.CascadeClassifier(FACE_DETECTOR_PATH)
            rects = detector.detectMultiScale(image, scaleFactor=1.1, minNeighbors=5,minSize=(30, 30), flags=cv2.cv.CV_HAAR_SCALE_IMAGE)

            # construct a list of bounding boxes from the detection
            self.rects = [(int(x), int(y), int(x + w), int(y + h)) for (x, y, w, h) in rects]

            # if the thread indicator variable is set, stop the thread
            # and resource camera resources
            if self.stopped:
                self.stream.close()
                self.rawCapture.close()
                self.camera.close()
                return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号