davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

C++ experiences with the Pixy Cam?

Sat Apr 02, 2016 7:57 pm

hey,
is anyone experienced in programming the Pixy Cam with gpp C/C++ (possibly in Geany IDE)?
which interface ist most easy to use?
SPI, UART, or I2C? (the standard 6-pin header cable just supports SPI, at least for Arduinos, IIRC)
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 1:49 pm

no one who used the Pixy Cam by Raspi C compilers so far?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 2:28 pm

Probably very few have experience with this hardware in general.

Looking at their open-source code, ( https://github.com/charmedlabs/pixy/tre ... r/src/host) I can see that their example software PixyMon usex C++ and QT4 so I would start there.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 2:56 pm

PixyMon is just used for teaching and programming the targeting colors e.g., from a Windows PC, but the Pixy onboard-processor itself then generates the blob data of detected blobs, sorted by color, size, and position.
I once used one of the first Pixy versions on an Arduino Due, but the libs were not ARM (Due-) compatible, neither for UART nor for SPI, so I abandoned my attempts. Myriads of blob data missing and/or dozens of cks errors (check sum), one after the other. I returned the cam to the supplier.

Meanwhile there are newer versions of hardware, firmware, and software, so perhaps some issues have been fixed, for one or the other of the protocols. That's why I was asking about general experience with C and especially about which interface to prefer for the Raspi.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 3:33 pm

The linux build of PixyMon depends on libusb and USB sound like the most convenient interface to me.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 3:46 pm

I saw that a Raspi build uses USB, but I don't see a C lib for that.
A theoretical discussion wouldn't help either, as the issues just appear when you use it, just as it once happened for my Arduino Due.
So if anyone used USB for the Pixy with a C lib (which?) - - - : personal experiences and approved source codes highly appreciated!
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 3:51 pm

davenull wrote:I saw that a Raspi build uses USB, but I don't see a C lib for that.
https://github.com/charmedlabs/pixy/blo ... ude/pixy.h

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 3:55 pm

no, I need application examples, and personal experiences with it , no link to the source code of a lib.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 3:57 pm

something like this, but for Raspi, not Arduino:

Code: Select all


/* 
   06.04.2014 v0.1.3 John Leimon
     + Now using pixy.init() to initialize Pixy in setup().
*/

#include <SPI.h>  
#include <Pixy.h>

Pixy pixy;

void setup()
{

  Serial.begin(9600);
  Serial.print("Starting...\n");

  pixy.init();
}

void loop()
{ 
  static int i = 0;
  int j;
  uint16_t blocks;
  char buf[32]; 
  
  blocks = pixy.getBlocks();
  
  if (blocks)
  {
    i++;
    
    if (i%50==0)
    {
      sprintf(buf, "Detected %d:\n", blocks);
      Serial.print(buf);
      for (j=0; j<blocks; j++)
      {
        sprintf(buf, "  block %d: ", j);
        Serial.print(buf); 
        pixy.blocks[j].print();
      }
    }
  }  
}
and different ones, by personal experiences (not on the paper!)!
How do they work and perform?
Issues?
Hints?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 4:55 pm


davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 5:13 pm

yes, for example.
Many programs look fine at first sight, but actually don't (or didn't) work in practice, or partially (i.e., on Arduino) just by i2c, not by SPI, not by UART.
Or some of the provided original source codes had to be sort of reworked, partially e.g. by additionally patching the Arduino SPI libs.
There once were many issues which have been reported.

This is what my question was about, but now about experiences with the Pi.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26659
Joined: Sat Jul 30, 2011 7:41 pm

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 5:59 pm

I suspect the deafening lack of answers means that few if anyone has done this. Google might find something.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 6:52 pm

I also suspected that.
I did already google - no such experience reports found, but that doesn't mean anything:
if no issues had occured, and if everything worked, why should one post?

But a pity if there are no experiences, could be a good and convenient Raspi addon, in case it worked.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 8926
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 7:14 pm

Someone needs better Google-foo.
viewtopic.php?f=43&t=112300&p=781843#p781843
I got the python code for pixy camera to work, just followed the steps in the link

http://cmucam.org/projects/cmucam5/wiki ... e_on_Linux .
viewtopic.php?f=63&t=86750#p846085
PixyCamera is really an awesome board and it made image processing quite easy , I got it working by following this tutorial , quite impressive .... http://www.theengineeringprojects.com/2 ... amera.html
If the Python code works, then the reference C examples are likely to.

http://cmucam.org/projects/cmucam5/wiki ... spberry_Pi
http://notes.pitfall.org/pixy-for-raspberry-pi.html
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 7:36 pm

Of course I found the Python instruction link, but no references to C sources.
http://cmucam.org/projects/cmucam5/wiki ... e_on_Linux

also this one is just about Python:
http://cmucam.org/projects/cmucam5/wiki ... spberry_Pi

I basically was looking for i2c, UART, or SPI, not USB, just like for Arduino, but also for USB: no experience report with source code found.

So have you found experience reports about C and USB?
To which source codes in detail?
To my experience it's about C not compellingly the same as to Python, and I don't understand Python code at all.

at your last link I also can't find C code for SPI:
http://notes.pitfall.org/pixy-for-raspberry-pi.html
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 8926
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: C++ experiences with the Pixy Cam?

Tue Apr 05, 2016 9:10 pm

From http://notes.pitfall.org/pixy-for-raspberry-pi.html he links to https://github.com/omwah/pixy_rpi
The README includes the wiring for SPI on the Pi. It looks like it's fairly crude in the SPI interfacing based on https://github.com/omwah/pixy_rpi/blob/master/Pixy.h, but it's there.

Same repo referenced from http://www.cmucam.org/boards/9/topics/3529?r=6097

And as a random piece of code, http://pastebin.com/ddEHZWV5 is using Pixy and WiringPi, though I can't find any projects referencing it.

Otherwise I suggest you go and ask on the PixyCam forums - you're more likely to find users there.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C++ experiences with the Pixy Cam?

Wed Apr 06, 2016 7:38 am

no libs and no C++ guides available from Pixy via the Pixy forum.
Only moronic and evasive answers.
That is really rediculous and emberrassing for that company.

Especially this Wiring Pi approach
https://github.com/omwah/pixy_rpi
sounds very promising, I like the syntax because I'm used to Wiring/Sketch for Arduino and it's very handsome.
Thank you for your hints!
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C++ experiences with the Pixy Cam?

Fri Apr 22, 2016 9:27 am

is anyone around here who is already successfully using the Pixy Cam by C/C++ when plugged to USB ?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

Return to “C/C++”