In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the raspberry pie how to achieve ultrasonic license plate recognition system, the article is very detailed, has a certain reference value, interested friends must read it!
Raspberry pie license plate recognition system
This system uses raspberry pie 4B
#! / usr/bin/env python#-*-coding: utf-8-*-from luma.core.interface.serial import i2C, spifrom luma.core.render import canvasfrom luma.oled.device import ssd1306, ssd1325, ssd1331 Sh2106from luma.core.virtual import terminalimport osimport timefrom PIL import ImageFontfrom aip import AipOcrfrom picamera import PiCamerafrom time import sleep# import GPIO library import RPi.GPIO as GPIOimport time # set GPIO mode to BCMGPIO.setmode (GPIO.BCM) # define GPIO pin GPIO_TRIGGER = 27GPIO_ECHO = 17 # set GPIO operation (IN / OUT) GPIO.setwarnings (False) GPIO.setup (GPIO_TRIGGER, GPIO.OUT) GPIO.setup (GPIO_ECHO, GPIO.IN) serial = i2C (port=1 Address=0x3C) device = sh2106 (serial) APP_ID = 'XXX'API_KEY =' YYY'SECRET_KEY = 'ZZZ'client = AipOcr (APP_ID, API_KEY, SECRET_KEY) def make_font (name, size): font_path = os.path.abspath (os.path.join (os.path.dirname (_ file__),' fonts', name) return ImageFont.truetype (font_path, size) Encoding= "utf-8") font = make_font ("/ home/pi/Python/1602/msyh.ttc", 20) def distance (): # send a high level signal to the Trig pin GPIO.output (GPIO_TRIGGER, True) # for 10 us time.sleep (0.00001) GPIO.output (GPIO_TRIGGER False) start_time = time.time () stop_time = time.time () # record the time when the ultrasound was sent 1 while GPIO.input (GPIO_ECHO) = = 0: start_time = time.time () # record the time when the ultrasound was received 2 while GPIO.input (GPIO_ECHO) = = 1: stop_time = time.time () # calculation exceeds Round trip time of sound waves = time 2-time 1 time_elapsed = stop_time-start_time # the velocity of sound waves is 343m/s Convert to 34300cm/s. Distance = (time_elapsed * 34300) / 2 print ("distance = {: .2f} cm" .format (distance)) return distancedef i2c_12864_print: with canvas (device) as draw: draw.text ((xPowery), text, fill= "white", font=font) def get_file_content (filePath): with open (filePath) 'rb') as fp: return fp.read () while True: print ("measure length") csblength = distance () if csblength < 200: print ("Program starts" Take a picture ") camera = PiCamera () camera.resolution = (1024) camera.start_preview () camera.capture ('/ home/pi/Python/1602/image.jpg') camera.stop_preview () print (" end of shooting ") image = get_file_content ('image.jpg') result = client.licensePlate (image) Print (result); carNumber = result ["words_result"] ["number"] i2c_12864_print break sleep (1) above are all the contents of the article "how to implement ultrasonic license plate recognition system for raspberry pie". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
The method introduced in this paper is simple, fast and practical.
© 2024 shulou.com SLNews company. All rights reserved.