P5 code optimisation for raspberry Pi

When I try to execute this sketch that is based on a face recognition algorithm it really lags on raspberry, whereas when run on different devices (macbook pro and notebook), it runs smoothly. I am not sure what is the best way to optimise this code so It can run faster. I use it with a local node server directly on the pi.

I am wondering if any of you have experience optimising code for raspberry and if this kind of hardware acceleration might be an option.

Any pointer is welcome. Thanks!

1 Like

I don’t have too much experience working on the Raspberry Pi but it sounds like you’re probably getting close to the hardware limits. Face recognition and video in general are pretty intensive tasks. While your interest in gpu.js would make sense in a lot of circumstances, the gpu for the raspberry pi probably isn’t worth the effort involved. Sorry to disappoint you.

I do still have a few suggestions if you’re interested but I don’t think they’ll ever be able to compare to laptop speeds.

  1. Web Workers are a way to do multiple threads on in the browser. Which might be worth looking into over gpu.js especially if you have a newer 4 core arm cpu on the raspberry pi. I haven’t used them in a long time but I remember it being kind of a struggle.
  2. openFrameworks is a C++ library for creative coding. Generally you can get better performance because it’s a compiled to binary instead of interpreted by the browser, among other things. I understand if C++ is intimidating but I’m happy to recommend resources if you’re interested in learning it.

I spent a while trying to run a kinect on a raspberry pi for an installation awhile ago and in the end it just wasn’t worth it. I bought an old dell desktop for about $100 and all my problems went away. Depending on what you’re doing investing some money can be worth it to avoid hours of work.

Best of luck!

3 Likes

Hey @figraham , I took the “other device” route and it works like a charm. Thanks for your answer, it helped me make this decision.

1 Like