Pixy now has a Python wrapper for libpixyusb. For now, this is only available for Linux-based controllers (e.g. Raspberry Pi, BeagleBone). The libpixyusb library provides a software application programming interface (API) for communicating with Pixy over USB. The following procedure will outline the steps to build libpixyusb as a Python module.
This procedure assumes the following:
Instructions for updating the Pixy firmware are here: Uploading New Firmware
Start a terminal application.
In a terminal window type:
# sudo apt-get install swig
In the terminal window type:
sudo apt-get install libusb-1.0-0-dev
In the terminal window type:
sudo apt-get install g++
In the terminal window type:
sudo apt-get install libboost-all-dev
In the terminal window type:
git clone https://github.com/charmedlabs/pixy.git
In the terminal window type:
cd pixy/scripts
./build_libpixyusb_swig.sh
Make sure your Pixy is connected to a USB port on your computer. Then in the terminal window type:
cd ../build/libpixyusb_swig
python get_blocks.py
If all goes well, you should see blocks:
Pixy Python SWIG Example -- Get Blocks
[BLOCK_TYPE=0 SIG=1 X=220 Y= 17 WIDTH= 43 HEIGHT= 35]
[BLOCK_TYPE=0 SIG=1 X=220 Y= 23 WIDTH= 42 HEIGHT= 47]
[BLOCK_TYPE=0 SIG=1 X=220 Y= 23 WIDTH= 42 HEIGHT= 47]
[BLOCK_TYPE=0 SIG=1 X=220 Y= 23 WIDTH= 42 HEIGHT= 47]
[BLOCK_TYPE=0 SIG=1 X=220 Y= 23 WIDTH= 42 HEIGHT= 46]
[BLOCK_TYPE=0 SIG=1 X=220 Y= 23 WIDTH= 45 HEIGHT= 46]
[BLOCK_TYPE=0 SIG=1 X=219 Y= 23 WIDTH= 43 HEIGHT= 46]
If you don't see any block information, try running as superuser:
sudo python get_blocks.py