diy:projets:qrdeciphering
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| diy:projets:qrdeciphering [2018/05/23 09:30] – créée ycaminade | diy:projets:qrdeciphering [2018/05/23 13:56] (Version actuelle) – [Required Libraries] ycaminade | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ===== Introduction ===== | + | ====== Introduction |
| The goal of this program is to detect and decipher one or several QR codes in a picture. | The goal of this program is to detect and decipher one or several QR codes in a picture. | ||
| - | ===== Required Libraries ===== | + | ====== Required Libraries |
| - | In order to decipher QR codes, we will use the QRLight | + | In order to decipher QR codes, we will use the zbarlight |
| '' | '' | ||
| '' | '' | ||
| Ligne 30: | Ligne 30: | ||
| </ | </ | ||
| - | **Work | + | If the right argument was given, we can remote into the pi to take a picture. To do so, we use subprocess.Popen() to run the following command with the given ip:\\ |
| + | '' | ||
| + | To avoid conflict with an already existing picture, we put the date and time in the new picture' | ||
| + | |||
| + | <code python> | ||
| + | if (len(sys.argv) == 2 and isValidIPV4(sys.argv[1])): | ||
| + | filename = ' | ||
| + | |||
| + | print(" | ||
| + | command = [' | ||
| + | x = Popen(command, | ||
| + | stderr = x.stderr.read() | ||
| + | print stderr | ||
| + | </ | ||
| + | |||
| + | We then import the resulting image over ssh using the '' | ||
| + | |||
| + | <code python> | ||
| + | print(" | ||
| + | command = [' | ||
| + | x = Popen(command, | ||
| + | stderr = x.stderr.read() | ||
| + | print stderr | ||
| + | </ | ||
| + | |||
| + | We now simply use zbarlight to decode any and all QR codes fully visible on the picture. We only need to open and load the image, before applying the scan_codes function. | ||
| + | |||
| + | <code python> | ||
| + | file_path = ' | ||
| + | with open(file_path, | ||
| + | image = Image.open(image_file) | ||
| + | image.load() | ||
| + | |||
| + | code = zbarlight.scan_codes(' | ||
| + | print(' | ||
| + | </ | ||
| + | |||
| + | The program outputs a full list of all deciphered QR codes. | ||
diy/projets/qrdeciphering.1527067825.txt.gz · Dernière modification : de ycaminade
