示例#1
0
            
            if self.frames > 50 and len(self.bgs) < 10:
                self.bgs.append(snapshot)
        else:
            # Average them out to remove noise, and save as background
            self.background = pygame.transform.average_surfaces(self.bgs)
            self.calibrated = True
        self.frames += 1
        
    
    def threshold(self, snapshot):
        dest = snapshot.copy()
        dest.fill((255,255,255))    # Make a black background
        threshold_value = 10        # How close to the existing colour must each point be?
        pygame.transform.threshold(dest, snapshot, (0,0,0), [threshold_value]*3 ,(255,255,255),1, self.background)
        # Median filter would be good here to remove salt + pepper noise...  
        
        return dest #self.dest

    def process(self, snapshot):
        if not self.calibrated:
            return self.calibrate(snapshot)
        else:
            return self.threshold(snapshot)

if __name__ == "__main__":
    ds = VisionDS()
    
    vcp = VideoCapturePlayer(processFunction=ds.process)
    vcp.main()
示例#2
0
                self.bgs.append(snapshot)
        else:
            # Average them out to remove noise, and save as background
            self.background = pygame.transform.average_surfaces(self.bgs)
            self.calibrated = True
        self.frames += 1

    def threshold(self, snapshot):
        dest = snapshot.copy()
        dest.fill((255, 255, 255))  # Make a black background
        threshold_value = 10  # How close to the existing colour must each point be?
        pygame.transform.threshold(dest, snapshot, (0, 0, 0),
                                   [threshold_value] * 3, (255, 255, 255), 1,
                                   self.background)
        # Median filter would be good here to remove salt + pepper noise...

        return dest  #self.dest

    def process(self, snapshot):
        if not self.calibrated:
            return self.calibrate(snapshot)
        else:
            return self.threshold(snapshot)


if __name__ == "__main__":
    ds = VisionDS()

    vcp = VideoCapturePlayer(processFunction=ds.process)
    vcp.main()
示例#3
0
def main():
    vcp = VideoCapturePlayer(processFunction=locateFacesProcess)
    vcp.main()
    pygame.quit()
示例#4
0
def main():
    vcp = VideoCapturePlayer(processFunction=edgeDetectionProcess)
    vcp.main()
示例#5
0
def main():
    vcp = VideoCapturePlayer(processFunction=edgeDetectionProcess)
    vcp.main()
示例#6
0
def main():

    vcp = VideoCapturePlayer(processFunction=gaussianBlur)
    vcp.main()
示例#7
0
def main():

    vcp = VideoCapturePlayer(processFunction=gaussianBlur)
    vcp.main()
示例#8
0
def main():
    vcp = VideoCapturePlayer(processFunction=locateFacesProcess)
    vcp.main()
    pygame.quit()