Amazing-Python-Scripts
118 строк · 2.6 Кб
1{
2"nbformat": 4,
3"nbformat_minor": 0,
4"metadata": {
5"colab": {
6"provenance": []
7},
8"kernelspec": {
9"name": "python3",
10"display_name": "Python 3"
11},
12"language_info": {
13"name": "python"
14}
15},
16"cells": [
17{
18"cell_type": "code",
19"source": [],
20"metadata": {
21"id": "WxIDrhMMXq26"
22},
23"execution_count": null,
24"outputs": []
25},
26{
27"cell_type": "code",
28"source": [],
29"metadata": {
30"id": "Z1a10hWnYoLa"
31},
32"execution_count": null,
33"outputs": []
34},
35{
36"cell_type": "code",
37"source": [
38"import glob\n",
39"import cv2\n",
40"import pandas as pd\n",
41"import pathlib"
42],
43"metadata": {
44"id": "C02b4jGfYoN3"
45},
46"execution_count": 9,
47"outputs": []
48},
49{
50"cell_type": "code",
51"source": [
52"def read_qr_code(filename):\n",
53" \"\"\"Read an image and read the QR code.\n",
54"\n",
55" Args:\n",
56" filename (string): Path to file\n",
57"\n",
58" Returns:\n",
59" qr (string): Value from QR code\n",
60" \"\"\"\n",
61"\n",
62" try:\n",
63" img = cv2.imread(filename)\n",
64" detect = cv2.QRCodeDetector()\n",
65" value, points, straight_qrcode = detect.detectAndDecode(img)\n",
66" return value\n",
67" except:\n",
68" return"
69],
70"metadata": {
71"id": "9WBkKxI_YoP7"
72},
73"execution_count": 10,
74"outputs": []
75},
76{
77"cell_type": "code",
78"source": [
79"value = read_qr_code('/content/drive/MyDrive/download.png')"
80],
81"metadata": {
82"id": "WOwG1cGfYoSA"
83},
84"execution_count": 11,
85"outputs": []
86},
87{
88"cell_type": "code",
89"source": [
90"value"
91],
92"metadata": {
93"colab": {
94"base_uri": "https://localhost:8080/",
95"height": 35
96},
97"id": "DSeW4gTTYoUU",
98"outputId": "6f300523-60fa-4cae-d708-83dad8354c23"
99},
100"execution_count": 12,
101"outputs": [
102{
103"output_type": "execute_result",
104"data": {
105"text/plain": [
106"'http://en.m.wikipedia.org'"
107],
108"application/vnd.google.colaboratory.intrinsic+json": {
109"type": "string"
110}
111},
112"metadata": {},
113"execution_count": 12
114}
115]
116}
117]
118}