Esempio n. 1
0
        self.diff = cv2.bitwise_and(d1, d2)

    def feed_image(self, image):
        self._index = (self._index + 1) % (2 * self._N)
        self._frame[self._index] = image
        self.diff_img()
        

        
if __name__ == '__main__':

    winName = "cam test"
    cv2.namedWindow(winName, cv2.CV_WINDOW_AUTOSIZE)
    # Read three images first:

    cam = MyCam()
    md = MotionDetector(N=2, shape=cam.read().shape)

    while True:
        
        md.feed_image(cam.read())
        cv2.imshow(winName, md.diff)
        
        key = cv2.waitKey(10)
        if key == 27 or key == 32:
            cam.release()
            cv2.destroyWindow(winName)
            break

    print "Goodbye"
Esempio n. 2
0
        d2 = cv2.absdiff(f2, f1)
        self.diff = cv2.bitwise_and(d1, d2)

    def feed_image(self, image):
        self._index = (self._index + 1) % (2 * self._N)
        self._frame[self._index] = image
        self.diff_img()


if __name__ == '__main__':

    winName = "cam test"
    cv2.namedWindow(winName, cv2.CV_WINDOW_AUTOSIZE)
    # Read three images first:

    cam = MyCam()
    md = MotionDetector(N=2, shape=cam.read().shape)

    while True:

        md.feed_image(cam.read())
        cv2.imshow(winName, md.diff)

        key = cv2.waitKey(10)
        if key == 27 or key == 32:
            cam.release()
            cv2.destroyWindow(winName)
            break

    print "Goodbye"