Pixy USB .NET library
I put together the Pixy USB .NET library to make it easier to communicate with the PixyCam over USB.
More on pixy cam: http://charmedlabs.com/default/pixy-cmucam5/
I included a sample application to show usage. I don't have much experience in C/C++, so I've hacked my way through it. Please excuse poor C/C++ code/style. I was hoping to add additional commands as well as write code to retrieve images from the camera... don't think that's gonna happen.
Feel free to fork and submit PRs for it. I'd love to hear what others can do with this. Enjoy
Pablo D. Aizpiri Reference blog post: http://pabloaizpiri.com/2015/10/25/net-pixycam-library/
A few notes:
Regarding use with PixyCam:
- 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.
- 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.
Getting this project to run:
I've gotten multiple questions from people with a .NET background but not much C/C++ experience having difficulty getting this to run. I feel your pain. So I've put together a simple set-by-step guide here. To compile everything you'll need the BOOST libraries (http://www.boost.org). Note that the
pixyusblib project in the solution uses the chrono library in BOOST which must be built separately to your target platform & toolset (http://www.boost.org/doc/libs/1_66_0/more/getting_started/windows.html#header-only-libraries). You'll need to set the configuration of the project to point to the correct boost install locations as well. So, if you are on Windows and unfamiliar with boost/C/C++, I recommend you do the following to keep it simple:
- Download boost installer with the target platform libraries/binaries you need. You can do this from the 3rd party website boost links on their download page: https://dl.bintray.com/boostorg/release/1.66.0/binaries/ .
- Choose the correct target platform and architecture. For the code in this repository I am targeting v141/32-bit so download "boost_1_66_0-msvc-14.1-32.exe" to match project.
- Update your
pixyusblibproject configuration to reflect the changes. For this project, I put mine in
- Right-click on
pixyusblibproject in the solution and choose "Properties"
Configuration Properties/Generalcheck that the platform toolset you are targetting matches the boost binaries. This should work out of the box if you followed instructions above for downloading BOOST binaries and stuck with the target platform/architecture I used.
Configuration Properties/VC++ Directories, make sure your
Include Directoriesincludes the path to your boost install. For example,
Configuration Properties/Libraries, make sure your
Library Directoriesincludes the path to your boost binaries. For example,
Configuration Properties/C/C++/General, your "Additional Include Directories" should be pointing to your root boost install dir (e.g.
- Right-click on
pixyusblib builds. Same with
PixyUSB.NET. If those are good, SampleApplication will run for you. Make sure it's set as the start-up project (right click on it to do this), hit debug, and if you have your pixy cam connected it should all run and show you a cool little demo!
Obviously, I expect you already have PixyCam connected to your computer and using the PixyMon software ( http://cmucam.org/projects/cmucam5/wiki/Install_PixyMon_on_Windows_Vista_7_8 ) can interact with it with no problems- if you can't do that, reference PixyCam's support and make sure that is working first (since my library is really just a glorified .NET wrapper).
Additional notes on project:
- Note that the projects for
pixyusblibhave a post-build event copying the DLLs to the
PixyUSB.NEToutput folder locations. This is because the
libusb-1.0DLLs in the same directory and thus the
PixyUSB.NETproject needs both of them in the same directory as well. So to use in your own application you would have your .EXE and then the PixyUSB.NET, pixyusblib, and libUSB DLLs in there as well.
libusb-1.0project is included because I had to make some minor changes to LibUSB for it to compile run on Windows, and
pixyusblibbecause I'm making changes to the source there as well. Finally, keep in mind the library is a work in progress and does not contain all the features yet.