With a python script that I have now, processing a single frame takes as long as 6 seconds. Can it be sped up by about 10 times, hopefully?
I asked ChatGPT. Here is the answer from ChatGPT o3-mini-high (just one of many suggestions):
Since each
cv2.matchTemplate
call for different rotation angles is independent, you can use Python’s parallel processing (for example,concurrent.futures.ThreadPoolExecutor
orProcessPoolExecutor
) to compute them simultaneously.
Note: Since OpenCV’s internal processing is implemented in C++ and the GIL is often released, thread-based parallelism can be sufficiently effective.
It even provided me with a code solution for the task. Amazingly, the processing time was reduced from roughly 6 seconds to about 1.3 seconds.