我被困在我的“小”项目条码识别。我是python和所有编程方面的新手。 所以我从网上借了一半的代码,现在我正试着适应我的需要。 它应该做的基本工作:
听起来很简单,但对我来说不是。。我被困了大约一个星期,寻找各种各样的教程和在这个网站,直到我决定在这里注册,问这个解决方案或一些指导,我做错事了。这就是我在向列表中添加结果时的代码和期望。(无,无,无….) P、 我使用的是python3.6,windows7(有时是10,不要问为什么…)在
from __future__ import print_function
from os import listdir
from os.path import isfile, join
import pandas as pd
import pyzbar.pyzbar as pyzbar
import numpy as np
import cv2
import glob
import os
import xlwt
from tempfile import TemporaryFile
folder = "C:\\Users\\dava8001\\AppData\\Local\\Programs\\Python\\Python36- 32\\bar-code-project\\2018-08-07_Eurovaitine,Salma\\"
barcode = []
def decode(im) :
# Find barcodes and QR codes
decodedObjects = pyzbar.decode(im)
# Print results
for obj in decodedObjects:
onlyfiles = [f for f in listdir(folder) if isfile(join(folder, f))]
print('Type : ', obj.type)
code = print('Number : ', obj.data,'\n')
barcode.append(code)
return decodedObjects
# Display barcode and QR code location
def display(im, decodedObjects):
# Loop over all decoded objects
for decodedObject in decodedObjects:
points = decodedObject.polygon
# If the points do not form a quad, find convex hull
if len(points) > 4 :
hull = cv2.convexHull(np.array([point for point in points], dtype=np.float32))
hull = list(map(tuple, np.squeeze(hull)))
else :
hull = points;
# Number of points in the convex hull
n = len(hull)
# Draw the convext hull
for j in range(0,n):
cv2.line(im, hull[j], hull[ (j+1) % n], (255,0,0), 3)
# Display results
#cv2.imshow("Results", im);
#cv2.waitKey(0);
# Main
if __name__ == '__main__':
# Read image
#im = [i for i in glob.glob(folder + "*.jpg") if isfile(join(folder, i))]
for img in glob.glob(folder + "*.jpg"):
im = cv2.imread(img)
decodedObjects = decode(im)
display(im, decodedObjects)
#print(barcode)
我的衣服是这样的。。在
^{pr2}$Type : EAN13 Number : b'9000100960342'
Type : EAN13 Number : b'9000100961172'
Type : EAN13 Number : b'5060283070508'
Type : EAN13 Number : b'5201279037109'
Type : EAN13 Number : b'5201279037109'
Type : CODE128 Number : b'1000002125861'
Type : EAN13 Number : b'3574660244182'
Type : EAN13 Number : b'4026600682800'
Type : EAN13 Number : b'3282770104783'
Type : EAN13 Number : b'7070866024680'
Type : EAN13 Number : b'7070866024680'
Type : EAN13 Number : b'5903104370008'
Type : EAN13 Number : b'5902114231880'
Type : EAN13 Number : b'2355106901552'
Type : EAN13 Number : b'4770511211030'
Type : EAN13 Number : b'4770577797066'
Type : EAN13 Number : b'4170511791066'
Type : EAN13 Number : b'4770511191066'
Type : EAN13 Number : b'4170511197066'
Type : EAN13 Number : b'5060195750451'
Type : EAN13 Number : b'4771138392669'
Type : EAN13 Number : b'4771138392669'
不是你!在
目前没有回答
相关问题 更多 >
编程相关推荐