# coding:utf-8

import cv2
import pyzbar.pyzbar as pyzbar
import json
import datetime

import Adafruit_GPIO.SPI as SPI
import Adafruit_SSD1306
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import importlib,sys
importlib.reload(sys)
def detect():
    camera = cv2.VideoCapture(0)
    while True:
        ret, frame = camera.read()
 
        barcodes = pyzbar.decode(frame)  # 解析摄像头捕获到的所有二维码
 
        data = ''
        for barcode in barcodes:
            data = json.loads(barcode.data.decode('utf-8')) # 对数据进行转码
            name = data['name']
            gender = data['gender']
            age = int((datetime.datetime.today() - datetime.datetime.strptime(data['birthDate'],"%Y/%m/%d")).days/365*12)
            status = data['list']
        if data != '':
    
            print(name)
        
            print(gender)
            print(age)
            print(status)
            RST=17
            DC=22
            SPI_PORT=0
            SPI_DEVICE=0
            disp=Adafruit_SSD1306.SSD1306_128_64(rst=RST,dc=DC,spi=SPI.SpiDev(SPI_PORT,SPI_DEVICE,max_speed_hz=8000000))

            disp.begin()
            disp.clear()
            disp.display() #清屏

            width=disp.width
            height=disp.height
            image1=Image.new('1',(width,height))
            draw1=ImageDraw.Draw(image1)
            # font1=ImageFont.load_default()
            font1=ImageFont.truetype('/home/pi/simhei.ttf',15)
            draw1.text((28,0),u'姓名:'+str(name),font=font1,fill=1)
            if (gender==1):
                draw1.text((28,21),u'性别:男',font=font1,fill=1)
            else:
                draw1.text((28,21),u'性别:女',font=font1,fill=1)
            draw1.text((28,45),u'年龄:'+str(age),font=font1,fill=1)
            disp.image(image1)
            disp.display() 
            
        if cv2.waitKey(1)& 0xFF == ord('q'):
            break
        cv2.imshow('camera', frame)
        
                 
#    camera.release()
#    cv2.destroyAllWindows()

if __name__ == '__main__':
    detect()

7455ec938b69d9c51d38f2c3b37a11a9ab2876de
<mask token>

<mask token>


def detect():
    camera = cv2.VideoCapture(0)
    while True:
        ret, frame = camera.read()
        barcodes = pyzbar.decode(frame)
        data = ''
        for barcode in barcodes:
            data = json.loads(barcode.data.decode('utf-8'))
            name = data['name']
            gender = data['gender']
            age = int((datetime.datetime.today() - datetime.datetime.
                strptime(data['birthDate'], '%Y/%m/%d')).days / 365 * 12)
            status = data['list']
        if data != '':
            print(name)
            print(gender)
            print(age)
            print(status)
            RST = 17
            DC = 22
            SPI_PORT = 0
            SPI_DEVICE = 0
            disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, dc=DC, spi=SPI.
                SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000))
            disp.begin()
            disp.clear()
            disp.display()
            width = disp.width
            height = disp.height
            image1 = Image.new('1', (width, height))
            draw1 = ImageDraw.Draw(image1)
            font1 = ImageFont.truetype('/home/pi/simhei.ttf', 15)
            draw1.text((28, 0), u'姓名:' + str(name), font=font1, fill=1)
            if gender == 1:
                draw1.text((28, 21), u'性别:男', font=font1, fill=1)
            else:
                draw1.text((28, 21), u'性别:女', font=font1, fill=1)
            draw1.text((28, 45), u'年龄:' + str(age), font=font1, fill=1)
            disp.image(image1)
            disp.display()
        if cv2.waitKey(1) & 255 == ord('q'):
            break
        cv2.imshow('camera', frame)


<mask token>

<mask token>
importlib.reload(sys)


def detect():
    camera = cv2.VideoCapture(0)
    while True:
        ret, frame = camera.read()
        barcodes = pyzbar.decode(frame)
        data = ''
        for barcode in barcodes:
            data = json.loads(barcode.data.decode('utf-8'))
            name = data['name']
            gender = data['gender']
            age = int((datetime.datetime.today() - datetime.datetime.
                strptime(data['birthDate'], '%Y/%m/%d')).days / 365 * 12)
            status = data['list']
        if data != '':
            print(name)
            print(gender)
            print(age)
            print(status)
            RST = 17
            DC = 22
            SPI_PORT = 0
            SPI_DEVICE = 0
            disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, dc=DC, spi=SPI.
                SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000))
            disp.begin()
            disp.clear()
            disp.display()
            width = disp.width
            height = disp.height
            image1 = Image.new('1', (width, height))
            draw1 = ImageDraw.Draw(image1)
            font1 = ImageFont.truetype('/home/pi/simhei.ttf', 15)
            draw1.text((28, 0), u'姓名:' + str(name), font=font1, fill=1)
            if gender == 1:
                draw1.text((28, 21), u'性别:男', font=font1, fill=1)
            else:
                draw1.text((28, 21), u'性别:女', font=font1, fill=1)
            draw1.text((28, 45), u'年龄:' + str(age), font=font1, fill=1)
            disp.image(image1)
            disp.display()
        if cv2.waitKey(1) & 255 == ord('q'):
            break
        cv2.imshow('camera', frame)


if __name__ == '__main__':
    detect()

import cv2
import pyzbar.pyzbar as pyzbar
import json
import datetime
import Adafruit_GPIO.SPI as SPI
import Adafruit_SSD1306
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import importlib, sys
importlib.reload(sys)


def detect():
    camera = cv2.VideoCapture(0)
    while True:
        ret, frame = camera.read()
        barcodes = pyzbar.decode(frame)
        data = ''
        for barcode in barcodes:
            data = json.loads(barcode.data.decode('utf-8'))
            name = data['name']
            gender = data['gender']
            age = int((datetime.datetime.today() - datetime.datetime.
                strptime(data['birthDate'], '%Y/%m/%d')).days / 365 * 12)
            status = data['list']
        if data != '':
            print(name)
            print(gender)
            print(age)
            print(status)
            RST = 17
            DC = 22
            SPI_PORT = 0
            SPI_DEVICE = 0
            disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, dc=DC, spi=SPI.
                SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=8000000))
            disp.begin()
            disp.clear()
            disp.display()
            width = disp.width
            height = disp.height
            image1 = Image.new('1', (width, height))
            draw1 = ImageDraw.Draw(image1)
            font1 = ImageFont.truetype('/home/pi/simhei.ttf', 15)
            draw1.text((28, 0), u'姓名:' + str(name), font=font1, fill=1)
            if gender == 1:
                draw1.text((28, 21), u'性别:男', font=font1, fill=1)
            else:
                draw1.text((28, 21), u'性别:女', font=font1, fill=1)
            draw1.text((28, 45), u'年龄:' + str(age), font=font1, fill=1)
            disp.image(image1)
            disp.display()
        if cv2.waitKey(1) & 255 == ord('q'):
            break
        cv2.imshow('camera', frame)


if __name__ == '__main__':
    detect()

# coding:utf-8

import cv2
import pyzbar.pyzbar as pyzbar
import json
import datetime

import Adafruit_GPIO.SPI as SPI
import Adafruit_SSD1306
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import importlib,sys
importlib.reload(sys)
def detect():
    camera = cv2.VideoCapture(0)
    while True:
        ret, frame = camera.read()
 
        barcodes = pyzbar.decode(frame)  # 解析摄像头捕获到的所有二维码
 
        data = ''
        for barcode in barcodes:
            data = json.loads(barcode.data.decode('utf-8')) # 对数据进行转码
            name = data['name']
            gender = data['gender']
            age = int((datetime.datetime.today() - datetime.datetime.strptime(data['birthDate'],"%Y/%m/%d")).days/365*12)
            status = data['list']
        if data != '':
    
            print(name)
        
            print(gender)
            print(age)
            print(status)
            RST=17
            DC=22
            SPI_PORT=0
            SPI_DEVICE=0
            disp=Adafruit_SSD1306.SSD1306_128_64(rst=RST,dc=DC,spi=SPI.SpiDev(SPI_PORT,SPI_DEVICE,max_speed_hz=8000000))

            disp.begin()
            disp.clear()
            disp.display() #清屏

            width=disp.width
            height=disp.height
            image1=Image.new('1',(width,height))
            draw1=ImageDraw.Draw(image1)
            # font1=ImageFont.load_default()
            font1=ImageFont.truetype('/home/pi/simhei.ttf',15)
            draw1.text((28,0),u'姓名:'+str(name),font=font1,fill=1)
            if (gender==1):
                draw1.text((28,21),u'性别:男',font=font1,fill=1)
            else:
                draw1.text((28,21),u'性别:女',font=font1,fill=1)
            draw1.text((28,45),u'年龄:'+str(age),font=font1,fill=1)
            disp.image(image1)
            disp.display() 
            
        if cv2.waitKey(1)& 0xFF == ord('q'):
            break
        cv2.imshow('camera', frame)
        
                 
#    camera.release()
#    cv2.destroyAllWindows()

if __name__ == '__main__':
    detect()
