class BarCode – BarCode object#

The barcode object is an attrtuple returned by Image.find_barcodes(). Each instance describes a decoded 1D barcode: its bounding box, decoded payload, symbology, in-image-plane rotation, a decode-quality score, and the four detected corners of the barcode.

Fields are accessible by attribute name (barcode.payload) or by index (barcode[0]). The object has no public constructor.

class image.barcode#

Please call Image.find_barcodes() to create this object.

Bounding box and corners#

x#

Bounding box top-left x coordinate, in pixels. Integer. Index [0].

y#

Bounding box top-left y coordinate, in pixels. Integer. Index [1].

w#

Bounding box width, in pixels. Integer. Index [2].

h#

Bounding box height, in pixels. Integer. Index [3].

corners#

4-tuple of (x, y) integer tuples for the four detected corners of the barcode, sorted clockwise starting from the top-left corner. Index [8].

rect#

(x, y, w, h) 4-tuple of the bounding box. Suitable for passing directly to drawing/cropping methods such as Image.draw_rectangle() or Image.crop(). Index [9].

Decoded payload#

payload#

Decoded payload string. Index [4].

type#

Symbology of the decoded barcode. One of:

Integer. Index [5].

rotation#

In-image-plane rotation of the barcode in radians. Float. Index [6].

quality#

Number of times the barcode was decoded across the image. The decoder runs across every scanline that crosses the barcode and increments this counter on each successful decode – higher values indicate a more confident result. Integer. Index [7].