This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
bdev:2dreader [2020/11/12 23:54] richard created |
bdev:2dreader [2021/08/16 22:22] (current) |
||
---|---|---|---|
Line 2: | Line 2: | ||
+ | {{ : | ||
+ | {{ : | ||
+ | {{ : | ||
+ | {{ : | ||
+ | {{ : | ||
---- | ---- | ||
+ | When running the camera for 2D matix code reading and (likely dealing with different types of plates in general), depending on the environment and type of plate, you should be prepared to adjust the variable to assure the image is still in focus and there is sufficient lightly. There are at least 3 variables to consider in order to get good quality images for 2D matrix code reading: | ||
+ | |||
+ | - Correct lighting - the LEDs underneath the plate are run by 12V power supply, there is a voltage controller that adjusts the voltage from 11.5V to 12V. Its not much of a range but the LEDs turn off below 11.5V. There are 3 settings if you are in a bright room you probably need the lowest setting but this also depends on how bright you want the camera to be which leads to the next setting. | ||
+ | - Brightness - the camera is run by the picamera library - https:// | ||
+ | - Focus - This is controlled by the Arducam, | ||
- | {{ :bdev: | + | So how this works is that you have a “Driver” computer that sends commands to the 2 RaspberryPi computers “Client”, |
+ | The example optimization python script, called optimizer.py looks like this: | ||
+ | |||
+ | < | ||
+ | import os,sys,time | ||
+ | |||
+ | #The plate identifier | ||
+ | plate = sys.argv[1] | ||
+ | #Your focus settings | ||
+ | ff = [' | ||
+ | #Your brightness settings | ||
+ | bb = [' | ||
+ | |||
+ | for f in f: | ||
+ | for b in leftb: | ||
+ | cmd = " | ||
+ | os.system(cmd) | ||
+ | time.sleep(1) | ||
+ | cmd = " | ||
+ | os.system(cmd) | ||
+ | time.sleep(2) | ||
+ | cmd = 'scp pi@192.168.1.110:/ | ||
+ | os.system(cmd) | ||
+ | time.sleep(2) | ||
+ | cmd = 'scp pi@192.168.1.120:/ | ||
+ | os.system(cmd) | ||
+ | time.sleep(2) | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | The client subscriber script looks like this: | ||
+ | |||
+ | < | ||
+ | import os | ||
+ | import time | ||
+ | import sys | ||
+ | import threading | ||
+ | import pygame,sys | ||
+ | import picamera | ||
+ | from pygame.locals import * | ||
+ | from time import ctime, sleep | ||
+ | import re | ||
+ | import paho.mqtt.client as mqtt | ||
+ | |||
+ | |||
+ | #Establish a connection to MQTT | ||
+ | def establishconnection(): | ||
+ | ### mqtt ### | ||
+ | broker_address=" | ||
+ | print(" | ||
+ | client = mqtt.Client(" | ||
+ | client.on_message=on_message #attach function to callback | ||
+ | print(" | ||
+ | client.connect(broker_address) #connect to broker | ||
+ | print(" | ||
+ | client.subscribe(" | ||
+ | print(" | ||
+ | # Continue the network loop | ||
+ | client.loop_forever() | ||
+ | return client | ||
+ | |||
+ | |||
+ | def runFocus(plate, | ||
+ | | ||
+ | value = (temp_val<< | ||
+ | dat1 = (value>> | ||
+ | dat2 = value & 0xf0 | ||
+ | | ||
+ | # | ||
+ | | ||
+ | | ||
+ | cmd = '/ | ||
+ | | ||
+ | |||
+ | |||
+ | ## mqtt message handler ## | ||
+ | def on_message(client, | ||
+ | print(" | ||
+ | cmd = str(message.payload.decode(" | ||
+ | if re.match(" | ||
+ | aa = re.match(" | ||
+ | (plate, | ||
+ | print(ff) | ||
+ | runFocus(plate, | ||
+ | |||
+ | |||
+ | pygame.init() | ||
+ | camera = picamera.PiCamera() | ||
+ | client = establishconnection() | ||
+ | </ | ||
---- | ---- | ||
- | |{{ :bdev:2dcode_reader.png?400 |}}|{{ :bdev:2dcode_reader.stl |}}| | + | |{{ :bdev:arducam_rotate_case.png?200 |}}|{{ :bdev:arducam_rotate_case.stl |}}| |
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : | ||
+ | |{{ : |