def __init__(self): print("Starting Repository") check = CheckOffender() offender = check.check(1) if offender: print "Bienvenu !" else: print "T'as rien a foutre ici conard !"
def loopDetect(self): qrReader = ScanQr.ScanQr("scanner") print("Getting first Image") # Get first image image1, buffer1 = self.captureTestImage() # Reset last capture time lastCapture = time.time() while True: # Get comparison image image2, buffer2 = self.captureTestImage() # Count changed pixels changedPixels = 0 for x in xrange(0, 100): for y in xrange(0, 75): # Just check green channel as it's the highest quality channel pixdiff = abs(buffer1[x,y][1] - buffer2[x,y][1]) if pixdiff > self.threshold: changedPixels += 1 # Check force capture if self.forceCapture: if time.time() - lastCapture > forceCaptureTime: changedPixels = sensitivity + 1 # Save an image if pixels changed if changedPixels > self.sensitivity: print ("Cop has detected Motion.") lastCapture = time.time() image = self.bufferImage() data = qrReader.detectQR(image) if data == 0: print("Qr was not detected.") else: print("QR Detected! Value is:") print(data) # Here we take the id with the qrcode check = CheckOffender() if check.check(data): print "Access granted" MotionDetection.led.blinkOK() else: print "Access denied" MotionDetection.led.blinkKO() else: print("Not changed") # Swap comparison buffers image1 = image2 buffer1 = buffer2