plik

BIN
utils/zbar/zbar.jpg


+ 40 - 0
utils/zbar/zbar.py

@@ -0,0 +1,40 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from PIL import Image, ImageEnhance
4
+from pyzbar import pyzbar
5
+
6
+
7
+# The zbar DLLs are included with the Windows Python wheels.
8
+# On other operating systems, you will need to install the zbar shared library.
9
+#
10
+# Mac OS X:
11
+# brew install zbar
12
+#
13
+# Linux:
14
+# sudo apt-get install libzbar0
15
+#
16
+# Install this Python wrapper; use the second form to install dependencies of the command-line scripts:
17
+# pip install pyzbar
18
+
19
+
20
+def zbar(path):
21
+    img = Image.open(path)
22
+
23
+    # img = ImageEnhance.Brightness(img).enhance(2.0)  # 增加亮度
24
+    # img = ImageEnhance.Sharpness(img).enhance(17.0)  # 锐利化
25
+    # img = ImageEnhance.Contrast(img).enhance(4.0)  # 增加对比度
26
+    # img = img.convert('L')  # 灰度化
27
+
28
+    # img.show()
29
+
30
+    barcodes = pyzbar.decode(img)
31
+
32
+    # for barcode in barcodes:
33
+    #     barcodeData = barcode.data.decode("utf-8")
34
+    #     print(barcodeData)
35
+
36
+    return [bar.data.decode('utf-8') for bar in barcodes]
37
+
38
+
39
+if __name__ == '__main__':
40
+    print zbar('zbar.jpg')

kodo - Gogs: Go Git Service

Brak opisu

huangqimin001: a0214a61bf :bug: Fixed Bug: LensmanContributionActivityIncomeExpensesInfo has no field named 's' 2 lat temu
..
migrations eb1f19f209 add # -*- coding: utf-8 -*- 2 lat temu
__init__.py 2fdf901626 新增摄影师合同相关接口 2 lat temu
admin.py a0214a61bf :bug: Fixed Bug: LensmanContributionActivityIncomeExpensesInfo has no field named 's' 2 lat temu
apps.py eb1f19f209 add # -*- coding: utf-8 -*- 2 lat temu
models.py b580e80550 :art: iSort & iCheck 2 lat temu
tests.py b580e80550 :art: iSort & iCheck 2 lat temu
views.py b580e80550 :art: iSort & iCheck 2 lat temu