OOP Python in vision processing with OpenCV

When I was looking old FRC vision codes from github I saw some teams use OOP things like def() , main() etc. how its effect the performance of the vision processing code that runs on a Raspberry Pi 3 model B+ ?

Very little. What really drives vision processing performance is the resolution of the image (every pixel takes time, so going from 160x120 to 640x480 means you’re processing 16 times as much data) and the operations you are performing on the image–some operations are very expensive, and in general the fewer steps the better.

1 Like

def() and main() aren’t OOP constructs, they’re simple functions. If you see class then you have OOP (though, you can write pretty procedural class-based code). Anyway, this shouldn’t affect performance and as @Peter_Johnson says, minimizing the data stream you’re processing probably the biggest boost to performance. Use the native OpenCV functions when available, they’re much faster than Python. Use Numpy and it’s functions, again, instead of Python whenever possible. Avoid looping over data when other techniques will work.


Changing resolution worked magically, thank you for your answer.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.