Help us understand the problem. What is going on with this article?

M5StickVで2枚の画像の変化量を取る

boot.py
import sensor, image, utime, lcd
from Maix import GPIO
from fpioa_manager import fm
from board import board_info
from machine import I2C

i2c = I2C(I2C.I2C0, freq=400000, scl=28, sda=29)
lcd.init(freq=15000000)
i2c.writeto_mem(0x34, 0x91,b'\x70')  # バックライトを最低輝度
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE) #カメラ画像をグレースケールに設定
sensor.set_framesize(sensor.QQVGA)   # カメラ画像をQQVGAに設定
sensor.run(1)
sensor.skip_frames(time = 500)

fm.register(board_info.BUTTON_A, fm.fpioa.GPIO1)
button_a = GPIO(GPIO.GPIO1, GPIO.IN, GPIO.PULL_UP)

#extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.RGB565)

print("About to save background image...")
sensor.skip_frames(time = 500) #センサ待ち
baseImage = sensor.get_fb()
print("Saved background image - Now frame differencing!")
start = 0

while(True):
    img = sensor.snapshot()         #カメラ画像取得
    #lcd.display()                #LCDに表示
    sim = img.get_similarity(baseImage)
    th = sim.max()
    #print(th)
    if(th < 0.75):    #別画像と判定する閾値を設定
        print("something in")
        now = utime.ticks_ms()
        lapTime = now - start
        ms = lapTime % 1000
        s = (int)(lapTime / 1000)
        m = (int)(s / 60)
        s = s % 60
        print("%d'%d\"%d" %( m, s, ms))
        timeString = str(m) + '\'' + str(s) + '\"' + str(ms)
        simg = image.Image()
        simg.draw_string(10,30, timeString, scale=4)
        lcd.display(simg)
        i2c.writeto_mem(0x34, 0x91,b'\xA0')  #液晶輝度変更
        start = now
        utime.sleep(1)
        i2c.writeto_mem(0x34, 0x91,b'\x70')  #液晶輝度変更

    if button_a.value() == 0:
        print("A pushed ")
        baseImage = img.copy()
        utime.sleep(0.3)

https://docs.openmv.io/index.html
https://maixpy.sipeed.com/en/

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away