Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4397

Python • Getting more out of the CPU when running python project

$
0
0
Hey

I wonder how I can utilize more of my CPU when running a python project. I have a hobby project where I'm building a small toy car, which is controlled via an xbox controller. It has a camera attached to a servo and an arduino that reads sensor values.
So the camera is run in the main thread since I had problems running cv2 in a thread. I have two threads running in parallell for handling the input from the xbox controller and reading of arduino sensor values.
My camera is getting a very low fps, so out of curiosity I created an extra thread that printed out the CPU utilization (getting averages of 4 second intervals). It doesn't seem to go above 55% no matter what else is happening in the other threads. Memory usage stayed at 23-25%.

So my question is if you have any tips on how I can utilize more of my CPU to get better performance when running my projects.
Any input appreciated.

I know I sometimes do a bad job of explaining details, so here is a link to the GitHub for the project. Most of the logic for the camera is in Camera.py and main.py, threading logic is in CarControl.py.

https://github.com/Siggerud/roboCar/tree/main/src
robocar.jpg

Statistics: Posted by Siggerud — Thu Aug 22, 2024 7:41 pm — Replies 2 — Views 41



Viewing all articles
Browse latest Browse all 4397

Trending Articles