<< return to Pixycam.com

Pixycam multiprocessing?

Hello. In my BeagleBone system, I have multiple processes which attempt to communicate with the pixycam2. When one process starts, it calls pixy.init() to initialize the pixycam and then does some work. Then another process starts and it also needs to call pixy.init() before communicating and doing work. However, this initializing always returns -1 and I believe it’s because the other process already called init(). Is it true that only 1 process at a time can interface with the pixycam over USB? Furthermore, is there a way “stop” or “release” the pixycam after doing some work? For example, something like:

  1. pixy.init()
  2. Do work
  3. pixy.stop()

Hello,
You’re right – only one process can be connected to Pixy at a time. The demo programs create the Pixy2 object in static memory so it’s impossible to destroy the object. But if you crate the PIxy2 object on the heap, you can then delete it, which will free up the USB port.

// create Pixy on the heap
pixy = new Pixy2();

// delete Pixy
delete pixy;

Hope this helps.

Edward

Thanks for the advice. Is there a way to do this in Python as well? I tried using the del operator but it didn’t seem to work.

Hello,
That’s a good question. Deleting objects in Python can be challenging because references are sometimes hard to track down.

Edward