Oğuzhan Borlak
Published

Remote Photo Comparison with Sixfab CORE

Here, I will do photo comparing on a remote Raspberry Pi connected over a cellular module.

BeginnerFull instructions provided118
Remote Photo Comparison with Sixfab CORE

Things used in this project

Story

Read more

Code

Code

Python
from PIL import Image
from PIL import ImageChops
from picamera import PiCamera
from time import sleep

def main():
    
    print("1-)BaseHat\n2-)Cellular IoT\n3-)Power Hat\n4-)New product")
   
    while True:
        tip = int(input("What is the product type? "))
        try:
            val = int(tip)
            if val<5:
                break;
        except ValueError:
            print("This is not a number. Please enter a valid number")
    
    
    im1,im2 = tipcheck(tip)
    
    checkdiff(tip,im1,im2)
    


def tipcheck(tip):
    
    if tip == 1:
        im1 = Image.open("Basehat.jpg")
        im2 = Image.open(takeimg("Basehatpi.jpg"))
    elif tip == 2:
        im1 = Image.open("CellularIoT.jpg")
        im2 = Image.open(takeimg("CellularIoTpi.jpg"))
    elif tip == 3:
        im1 = Image.open("PowerHat.jpg")
        im2 = Image.open(takeimg("PowerHatpi.jpg"))
        
    elif tip ==4:
        camera = PiCamera()
        newfile = input("What is the name of product? ")
        #print("Please")
        camera.capture(str(newfile)+".jpg", use_video_port=True)
        im1 = Image.open(str(newfile)+".jpg")
        im1.show("photo1")
        contin = int(input("if is that ok press 1: "))
        if contin == 1:
            camera.capture(str(newfile)+"2.jpg", use_video_port=True)
            im2 = Image.open(str(newfile)+"2.jpg")
            im2.show()
    
        
        
    camera.close()
        
    
    return im1,im2
    
def takeimg(a):
    
    camera = PiCamera()
    camera.capture(a, use_video_port=True)
    camera.close()
    return a
    
    
    
def checkdiff(tip,im1,im2):
    diff = ImageChops.difference(im2, im1)
    if diff.getbbox():
        diff.show()
    diff.save('diff.png')
    

if __name__ == "__main__":
    main()

Credits

Oğuzhan Borlak
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.