<< return to Pixycam.com

Pixy Cam Python Barcode


#1

Hello,

we Need help with our Programm to detect Barcodes.
Can someone help us please?
Here is the code and a Screenshot with the Error:

from __future__ import print_function
import pixy
from ctypes import *
from pixy import *

# pixy2 Python SWIG get line features example #

print("Pixy2 Python SWIG Example -- Get Line Features")

pixy.init ()
pixy.change_prog ("line")

class Vector (Structure):
  _fields_ = [
    ("m_x0", c_uint),
    ("m_y0", c_uint),
    ("m_x1", c_uint),
    ("m_y1", c_uint),
    ("m_index", c_uint),
    ("m_flags", c_uint) ]

class IntersectionLine (Structure):
  _fields_ = [
    ("m_index", c_uint),
    ("m_reserved", c_uint),
    ("m_angle", c_uint) ]

class Barcode (Structure):
  _fields_ = [
    ("m_x", c_uint),
    ("m_y", c_uint),
    ("m_flags", c_uint),
    ("m_code", c_uint) ]


vectors = VectorArray(100)
intersections = IntersectionLineArray(100)
barcodes = BarcodeArray(100)
frame = 0

while 1:
  line_get_all_features ()
  i_count = line_get_intersections (100, intersections)
  v_count = line_get_vectors (100, vectors)
  b_count = line_get_barcodes (100, barcodes)

  if i_count > 0 or v_count > 0:
    print('frame %3d:' % (frame))
    frame = frame + 1
    for index in range (0, i_count):
      print('[INTERSECTION: INDEX=%d ANGLE=%d]' % (intersections[index].m_index, intersections[index].m_angle))
    for index in range (0, v_count):
      print('[VECTOR: INDEX=%d X0=%3d Y0=%3d X1=%3d Y1=%3d]' % (vectors[index].m_index, vectors[index].m_x0, vectors[index].m_y0, vectors[index].m_x1, vectors[index].m_y1))
    for index in range (0, b_count):
       print('[BARCODES: INDEX=%d x=%d Y0=%3d X1=%3d]' % (barcodes[index].m_x, barcodes[index].m_y, barcodes[index].m_flags, barcodes[index].m_code))

Best Regards


#2

Hello,
This is a bug that has just been fixed. (sorry!)

Please grab the latest code from git and rebuild the python demos. Let me know what you find.

Edward


#3

Hi edge, there are I think two errors:

The 1st one is: An NameError with the IntersectionArray, if I write an “#” before the Intersections Commands, there is the second error: If I hold an Barcode in front of the Pixy2 there is following error: see Screenshot!

Best regards


#4

Hello,
You need to get the latest code from git.

You might try to do a clone into a new directory to make sure you have the latest code

git clone https://github.com/charmedlabs/pixy2.git pixy2-2

You should also test with get_lines_python_demo.py. You are using get_lines_pytyon_demo1.py – I’m not sure what that is.

Edward