本文整理汇总了Python中SimpleCV.Image.findBarcode方法的典型用法代码示例。如果您正苦于以下问题:Python Image.findBarcode方法的具体用法?Python Image.findBarcode怎么用?Python Image.findBarcode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleCV.Image
的用法示例。
在下文中一共展示了Image.findBarcode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connectToServerAndHandleConnection
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBarcode [as 别名]
def connectToServerAndHandleConnection():
HOST = 'localhost'
PORT = 9898
while True:
try:
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.connect((HOST,PORT))
img_str = sock.recv(100000)
nparr = np.fromstring(img_str, np.uint8)
img_np = cv2.imdecode(nparr, cv2.CV_LOAD_IMAGE_COLOR) # cv2.IMREAD_COLOR in OpenCV 3.1
img_ipl = cv.CreateImageHeader((img_np.shape[1], img_np.shape[0]), cv.IPL_DEPTH_8U, 3)
cv.SetData(img_ipl, img_np.tostring(), img_np.dtype.itemsize * 3 * img_np.shape[1])
image = Image(img_ipl)
barcodes = image.findBarcode()
stringOut = '[]\n'
if barcodes != None:
stringOut = ''
for barcode in barcodes:
stringOut += str([barcode.x,barcode.y,int(barcode.length()), int(barcode.width()), barcode.data]) + ';'
stringOut = stringOut[:-1]
stringOut += '\n'
sock.send(stringOut)
except:
continue
示例2: Display
# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import findBarcode [as 别名]
#!/usr/bin/env python
from SimpleCV import Color,Display,Image
display = Display()
while(display.isNotDone()):
img = Image('example.jpg')
barcode = img.findBarcode() #finds barcode data from image
if(barcode is not None): #if there is some data processed
barcode = barcode[0]
result = str(barcode.data)
print result #prints result of barcode in python shell
barcode = [] #reset barcode data to empty set
img.save(display) #shows the image on the screen