<< return to Pixycam.com

User Tools

Site Tools


wiki:v2:building_the_libpixyusb_example_on_linux2

**This is an old revision of the document!**

1. Introduction

The libpixyusb library provides a software application programming interface (API) for communicating
with Pixy2 over USB. This allows you to write software that interfaces with Pixy2 like the PixyMon application.

The following procedure will outline the steps required for building the libpixyusb library and some example projects using the library. This procedure assumes the following:

  • Your system has Linux Mint-17 installed
  • Your system is connected to the internet

The Mint-17 distribution of Linux can be downloaded here: http://www.linuxmint.com

Instructions for updating the Pixy2 firmware are here: Uploading New Firmware

Although this procedure uses Linux Mint-17, it should work with any Linux distribution that uses the Debian package manager (e.g. Ubuntu).

2. Procedure

2.1. Install dependencies for building libpixyusb

Start the terminal application:

In the terminal window type:

sudo apt-get install git libusb-1.0-0-dev g++

2.2. Build and install libpixyusb

2.2.1 Download Pixy source code

In the terminal window type:

git clone https://github.com/charmedlabs/pixy.git

2.2.2. Build the library

In the terminal window type:

cd pixy/scripts
./build_libpixyusb.sh

2.2.3. Install the library

Installing the library files requires root privileges.

In the terminal window type:

sudo ./install_libpixyusb.sh

3. Example projects

Before trying the examples below, connect Pixy to your Linux system using a USB Mini cable:

e0e66b6f1b2c5231027c1d03c811e16207772021.jpg

3.1. hello_pixy: A Simple IO Example

The example does the following:

  • Connects to Pixy using USB
  • Displays firmware version installed on Pixy
  • Block information is displayed (as shown in the image above) if color signatures have been set and if the signatures are currently being detected by Pixy.

3.1.1. Build the 'hello_pixy' example

In the terminal window type:

/pixy/scripts/build_hello_pixy.sh

3.1.2. Start the example

To start the libpixyusb example, run 'hello_pixy' as root.

In the terminal window type:

cd /pixy/build/hello_pixy
sudo ./hello_pixy

Block data received from Pixy is displayed in stdout.

3.2. pan_tilt: An Object Tracking Example

This example does the following:

  • Connects to Pixy using USB
  • Pixy will track objects with color signature '0'

Before starting the tracking demo, make sure you've set color signature '0'. Look here: Teach_Pixy_an_Object_2

3.2.1. Build the 'pan_tilt' example

In the terminal window type:

/pixy/scripts/build_pantilt_c_demo.sh

3.2.2. Start the example

To start the pantilt demo, run 'pantilt' as root.

cd ../build/pantilt_in_c
sudo ./pantilt_c

ecd3c47f5b3959e279d1678becdfbbbc9854009c.jpg

Pixy should track objects that have color signature '0' programmed. If the tracking is not smooth try the following:

  • Use Pixymon to verify that Pixy is getting a good lock on the object.
  • Try making adjustments to the ambient lighting.

Note: If this example freezes, make sure that your version of libusb is at least 1.0.9.

3. Comments

We welcome your thoughts and feedback! Please let us know how we can improve.

wiki/v2/building_the_libpixyusb_example_on_linux2.1530247760.txt.gz · Last modified: 2018/06/29 04:49 by hohenheim