QoM.py 文件源码

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

项目:PyKinectTk 作者: Qirky 项目源码 文件源码
def MotionImage(self, threshold=200):
        """ Returns the image from the sum of the next window
        """

        # Initialise image

        img = np.zeros((self.w, self.h), dtype=np.uint8)

        # Get first frame of the window

        A = cv2.cvtColor(self.window[0], cv2.COLOR_BGR2GRAY)

        # Iterate over the rest of the window

        for i in range(1, self.length):

            # Load next frame

            B = cv2.cvtColor(self.window[i], cv2.COLOR_BGR2GRAY)

            # Image subtraction

            dif = cv2.absdiff(B, A)

            # Add to Motion Image

            img = cv2.add(img, dif)

            # Store the last grayscale frame

            A = B

        r, img = cv2.threshold(img, threshold, 255, cv2.THRESH_BINARY)

        # Try and get the next video frame

        try:

            self.window.append(self.read())
            self.window.popleft()

        except:

            self.hasData = False

        return img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号