<< return to Pixycam.com

Pixy on Raspberry Pi

I have had some success with using the Pixy on the Raspberry Pi and I thought I would share.

You can get the “PixyMon software”:https://github.com/charmedlabs/pixy compiled by following the instructions in the host/linux/README.linux file. You may need to remove -mno-ms-bitfields from the flags in the Makefile that is generated before successfully compiling.

I also have made C++ and Python code, adapted from the Arduino code to talk to get the Pixy information over SPI. It is available here: https://github.com/omwah/pixy_rpi

It requires either Wiring Pi or WiringPi2-Python. More information is in the readme at Github.

Hi Omwah,

This is great! Thanks for sharing! If you’re interested, you could consider collaborating with us and help with supporting Pixy for the Raspberry Pi. See “this”:http://cmucam.org/boards/9/topics/3430 post for more details.

Scott

I would be glad to help.

Omwah, have you actually run pixymon on the pi? I got it to compile, but when I try to launch pixymon in xwindows, it immediately crashes reporting a Seg Fault.

Also, during the build it did squawk about “Unknown QT Widgets,” but I think that is pretty normal.

I did get it working. But that was with an older version of the code. They have made some significant code refactoring since then. This definitely looks like a bug. You should look at the version of the QT libraries used on the Pi versus a x86 version of Debian or Ubunutu. Maybe using a different QT version would help. If I search the code for where that createElement gets called I come back with one file:


So its probably not a bug introduced by their code changes. Like I said before I bet its due to an assumption on the version of QT they expect versus what the Pi has.

From the screenshot here:
http://cmucam.org/projects/cmucam5/wiki/Installing_PixyMon_on_Linux
Looks like they tested with 4.8.5

You should also recompile with debug flags enabled. Just googling quickly I think this might be how:

Then when you run GDB you can get a stack trace to better pinpoint the problem. If changing QT libraries doesn’t help then coupled with a stack trace and maybe some output of variables around the segfault you’d have enough to either figure it out or post an issue to the Github.

I have mostly used the SPI interface with my Pi. I didn’t do any extended use with PixyMon. I would connect it to my laptop for that. But that was due to my use case. One thing I should add to my page is that you really need a logic level converter if your connecting the Pixy to the Pi due to the 5V vs 3.3V issue. I hadn’t thought of that till after I wrote the page. But I recently broke my Pixy somehow and haven’t gotten a replacement yet.

Best of luck!

Hi Omwah,
Thanks for sharing your notes!

We found that the call to new QDomDocument in paramfile.cpp returns NULL which results in a segfault (is that what you found?) but this was on beaglebone.

It’s odd for new to return NULL without an exception… we need to investigate more. Maybe we’re missing a shared object for Qt.

I think that is what I am running in to. This is what I get when I run with gdb:

Program received signal SIGSEGV, Segmentation fault
0xb6f831f4 in QDomDocument::createElement(Qstring const&) () from /usr/lib/arm-linux-gnueabihf/libQtXml.so.4

Is it crashing in the new QDomDocument call?

I honestly don’t know yet, Rich. The gdb backtrace was not very helpful as you can see below. I am going to recompile and run in debug mode per Omwah’s instructions.

Edit: I checked and I am running version 4.8.2 of Qt.

Starting program: /home/pi/Projects/pixy/build/pixymon/bin/PixyMon
[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib/arm-linux-gnueabihf/libthread_db.so.1”.

Program received signal SIGSEGV, Segmentation fault.
0xb6f831f4 in QDomDocument::createElement(QString const&) () from /usr/lib/arm-linux-gnueabihf/libQtXml.so.4
(gdb) backtrace
#0 0xb6f831f4 in QDomDocument::createElement(QString const&) () from /usr/lib/arm-linux-gnueabihf/libQtXml.so.4
#1 0x00036800 in ?? ()
#2 0x000164f4 in ?? ()
#3 0x00016948 in ?? ()
#4 0x000173ec in ?? ()
#5 0x000140e8 in ?? ()
#6 0xb61a782c in __libc_start_main (main=0xbefff804, argc=-1238646784, ubp_av=0xb61a782c, init=, fini=0x38728, rtld_fini=0xb6fe85a4, stack_end=0xbefff804)
at libc-start.c:244
#7 0x000141a8 in ?? ()
Cannot access memory at address 0x0
#8 0x000141a8 in ?? ()
Cannot access memory at address 0x0
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Guys, I think I found the problem. sheepish grin At start-up, pixymon attempts to open config.xml in the Documents directory in the user’s home directory. I did not have a Documents directory in my home directory. After adding it, pixymon launched to the GUI.

Edit: I’m still not sure where the seg fault is coming from. The ref to the QDomDocument object is not null, at least not immediately after instantiation. I will try adding some debug statements around the createElement() invocations.

nice! thanks Joshua!

So I went ahead and fixed and merged all the stuff from the 2.0 branch into the master branch. When you run PixyMon it will complain that your firmware is out of date. You can find pre-built firmware in ~/src/device/video/spifi/pixy_firmware.hex.

Let us know how it goes!

I got the outdated firmware error on Saturday. After updating, everything worked perfectly. The Pi is up to the task of running pixymon, but only just. There is a fair amount of latency, but it gets the job done. I am really pleased with the pixy and with the software. Thanks for all of the help, guys!

Hi guys,

I just got my new Pixy. I was able to run Pixymon and test the camera on my Ubuntu. But it didn’t work on my Pi! I did the same thing but I receive an error when I run PixyMon on Pi: PixyMon: cannot connect to X server.

Do you guus know how can I solve this?

Omwah Oyeh wrote:

I have had some success with using the Pixy on the Raspberry Pi and I thought I would share.

You can get the “PixyMon software”:https://github.com/charmedlabs/pixy compiled by following the instructions in the host/linux/README.linux file. You may need to remove -mno-ms-bitfields from the flags in the Makefile that is generated before successfully compiling.

I also have made C++ and Python code, adapted from the Arduino code to talk to get the Pixy information over SPI. It is available here: https://github.com/omwah/pixy_rpi

It requires either Wiring Pi or WiringPi2-Python. More information is in the readme at Github.

Hi,
Sorry to disturb you. Is there any python script for communication between Pixy camera and Raspberry Pi through USB, so that Pixy detects the objects and send the information to R’Pi. Can we hook up a pixy to raspberry pi through python coding, because i have hooked up a pixy to raspberry pi by following the link

http://cmucam.org/projects/cmucam5/wiki/Hooking_up_Pixy_to_a_Raspberry_Pi

and i can see the tracking of camera on computer screen by installing pixymon by following the link

http://www.cmucam.org/projects/cmucam5/wiki/Installing_PixyMon_on_Linux.

But i need all the thing to be done by running one python code. would any one help me in what libraries and commands to be used.

Thank you.

Hello Ganesh,
This page has some good information on Python and Pixy:

http://cmucam.org/projects/cmucam5/wiki/Building_libpixyusb_as_a_Python_module_on_Linux

Edward

Hello Ganesh,
This page has some good information on Python and Pixy:

http://cmucam.org/projects/cmucam5/wiki/Building_libpixyusb_as_a_Python_module_on_Linux

Edward

Omwah Oyeh wrote:

I have had some success with using the Pixy on the Raspberry Pi and I thought I would share.

You can get the “PixyMon software”:https://github.com/charmedlabs/pixy compiled by following the instructions in the host/linux/README.linux file. You may need to remove -mno-ms-bitfields from the flags in the Makefile that is generated before successfully compiling.

I also have made C++ and Python code, adapted from the Arduino code to talk to get the Pixy information over SPI. It is available here: https://github.com/omwah/pixy_rpi

It requires either Wiring Pi or WiringPi2-Python. More information is in the readme at Github.

Hi guys,

I just got my new Pixy. I was able to run Pixymon and test the camera on my Ubuntu. But it didn’t work on my Pi! I did the same thing but I receive an error when I run PixyMon on Pi: PixyMon: cannot connect to X server.

Do you guus know how can I solve this?

Hi Omwah,
You need to be running the window manager — try running “startx”.

But regardless, the Raspberry Pi has trouble running PixyMon because PixyMon’s blending and rendering tends to overwhelm it’s software render driver. In other words, it will run, but it’s slow and it sometimes can’t respond to Pixy’s data fast enough, causing connect/reconnect.

Edward