<< return to Pixycam.com

Help/Tutorial with C++ and Pixy program

Hello,
I was wondering if there were any good tutorials or if I could get some help in writing a C++ program using the Pixy (specifically the libpixyusb API)?

I am on Linux Mint 17 and was trying to develop in the Netbeans IDE (g++ as my compiler) although I am not limited to that. I was confused as to what libraries I need to include at the beginning in order to make it work as well as how to add the proper libraries to my program.

After messing around with it I believe I got the proper libraries added (although probably not in the best way) but then I continued to get an error saying “sprintf not declared in this scope”. I do have #include <stdio.h> at the beginning of my program.

I was not trying to do anything complex at the moment, mainly just trying to see if I can do some basic functionality using libpixyusb in C++. Any help as to go about doing this would be great.

Thanks.

D. Shinevar

Hi Daniel,
This is a good description on how to get started with libpixyusb:

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

here’s the API:
http://charmedlabs.github.io/pixy/pixy_8h.html

hope this helps!

Edward

I have looked at those and I have fixed a few of my issues.

I am still having a problem of a lot of undefined references. When I try to build my program, which is simply only trying to initialize the pixy, I get a lot of undefined references.

A couple undefined references were to boost::system and boost::thread. I added -lboost_system and -lboost_thread to my linker and it fixed those but I still have a lot of undefined references to a lot of libusb functions and boost::chrono.

Is there a proper way in which I should be going about this to not have these issues? I went through all the steps to install libusb and such but it seems that something is not right.

My code is simply as follows:
#include
#include
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include “pixy.h”

using namespace std;

int main(int argc, char** argv) {

//Initialize pixy
int pixy_init_status;
pixy_init_status = pixy_init();

return 0;

}

Any help would be great. Thanks!

D. Shinevar

Hello Daniel,
It sounds like the boost libraries are not being linked correctly.

Can you post the output of this command?: ./build_libpixyusb.sh (see step 2.2.2 on this page: http://cmucam.org/projects/cmucam5/wiki/Building_the_libpixyusb_example_on_Linux)

Edward