My experiences and thoughts on [mostly] technology.

.NET PixyCam Library

UPDATE 12-22-2017: I’ve gotten requests for help on getting this project building from multiple readers. I have updated the project to support newer target platform and provided a more comprehensive build guide here: https://github.com/JhottMaster/PixyUSBdotNET/blob/master/README.md

Not too long ago I saw a Charmed Lab’s PixyCam project on Kickstarter, and I decided to contribute.

PixyCam

My PixyCam assembled with Pan/Tilt Mechanism

I was really excited about all the possibilities vision can bring to the maker community. I later received the camera, and I have to admit it’s pretty cool. The PixyCam is basically a camera with a micro controller that can be used to tag and recognize colored objects. It can then send this “digested” data back to a micro controller that normally wouldn’t have the processing power to do object recognition. For example, certain colors can be tagged- “signatures”- and the camera can send back through an I2C connection the coordinates and size of one or more rectangles matching this “signature”. And at 50 FPS, there’s some pretty nifty stuff you could do with it, like a robot that follows a ball.

The camera also has two ports to connect two servos that you can control through the I2C connection as well. This makes it easy to quickly get up and going. After assembling mine with a pan/tilt mechanism, I played around with the standard demo program and had fun seeing it “look around” at whatever I had tagged for it to view. Next, I wanted to use it to try out some other ideas, but I wasn’t ready to use it with a micro controller and work on all the programming that goes along with that. Instead, I wanted to quickly use .NET to play around with it. Much to my dismay, I could not find an easy way to do this. Ironically, my desire for an “easy” route led me to build a .NET library. I wanted one and figured others could use it as well.

I’m still working on it but I put together a Visual Studio solution that includes my C# .NET PixyCam library, and the required C++/C projects (only required to generate the DLLs the .NET library uses).

I also included a sample .NET application that uses the library so that it can be easy to get started. The solution and source code can be found on GitHub: https://github.com/JhottMaster/PixyUSBdotNET/tree/master

A couple notes:

1.) Make sure you set a signature if you want the sample application to work. Just fire up PixyMon and tag a color to use as a signature.

2.) Make sure you are using a cable that works (most recommended is under 3 feet) or sends enough power to the servos. I deal with this a lot and it was super frustrating, until I got a cable that could transmit more power over further distances.

3.) The library is a work in progress, keep that in mind. Read the README file for more info.

 

 

8 Comments

  1. Jan

    Hi Pablo,
    I’m interested in this too. Did you get it going ?
    I’ll need the code in c or c++, but I could do that if it works.
    Wonder why nobody did this before ?
    Best,
    jan

    • Pablo

      Hey Jan,

      Sorry I took so long to reply. The pixy team already has this code in C/C++; in fact, it’s what I used to piece together my .NET version, although I wasn’t able to go back to working on it.

  2. Parsa

    Hi Pablo,
    Thanks for the post and for sharing your c# .net solution for Pixy camera. I have got some questions for you and I would appreciate you if you can advice me on them.
    I am looking for a good camera to embed in my robot’s eye to do some vision (image processing) with that. I need to recognize a few colored objects with and get the pixel address of them and keep track of the items in a room. Please can you tell me how Pixy is efficient in that? what is the detection range (in meter) that it is able to recognize colors? what is its FOV angles?
    Do you think if it is a right option to be integrated in a humanoid robot? or do you have any other suggestion for me?

    In future I will need to do face tracking… does it provide a Bitmap of the image frame to allow me to apply Opencv of for example Aforge?

    Currently I am developing my system under C .Net framework visual studio 2013.
    Thanks in advance.
    Parsa

    • Pablo

      Parsa,

      Pixy isn’t going to be good fit for advanced robot vision. It’s good for simple on board processing in detecting certain hues. I would use a regular webcam for your project.

      Good Luck!
      Pablo

  3. Simplo

    Hi Pablo, thanks for sharing this code.
    I just purchased my PIxy and would like to interface it with my favourite framework: TouchDesigner. I can read data from the USB via Arduino, but it is a slow solution so I would like to use something like your C++ application, just beacause TouchDesigner can include DLLs.
    I’m not very good in C++, but I’d like to try, so I downloaded your solution and tried to compile it with Visual Studio 2017 Community,
    Unfortunately I have 3 issues.
    A warning says:
    ‘libusb-1.0 (dll)’. The specified element is not a .NET assembly
    and 2 errors says:
    ‘build\cmakefiles\feature_tests.cxx’: No such file or directory
    ‘build\cmakefiles\3.2.3\compileridcxx\CMakeCXXCompilerId.cpp’: No such file or directory pixyusblib

    Can you please help me?
    Thank you

  4. Simplo

    Hi Pablo, sorry for the late reply. I recompiled the libusb and it works. But as soon as I try to build PixyUSB.NET, pixyusblit I get again those errors. I followed your new instructions and retargeted the solution, but no way. I’m using Windows SDK 8,1, Platform Toolset Visual Studio 2017 (v141), Target Framework .NET framework 4.5.2 and Boost boost_1_66_0-msvc-14.1-32.exe
    Thank you for your time.

    • Simplo

      Hi Pablo, I’m working agaib on Pixy porting to VS.
      Can you please tell me wich versione of VS you used and wich SDK?
      Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *

© 2023 Pablo Aizpiri

Theme by Anders NorenUp ↑