'Multiprocessing OpenCV in Python
I have a simple Algorithm, I want to run it fast in parallel. The algo is.
while stream:
img = read_image()
pre_process_img = pre_process(img)
text = ocr(pre_process_img)
fine_text = post_process(text)
Now I want to explore what are the fastest options I can get using python for multiprocessing the algorithm.
Some of the code is as follows:
def pre_process_img(frame):
return cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
def ocr(frame):
return pytesseractt.image_to_string(frame)
How can I run the given code in parallel/multiple threads/other options, especially the pre-process and ocr part?
I have tried JobLib, but it is for for-loops, and I wasn't sure how to implement it while loop in continuous frames.
I have been seeing people's code, but I am unable to reproduce it for my example.
Edit
We can definitely combine it in a pipeline.
while stream:
img = read_image()
results = pipeline(img)
Now I want to execute the pipeline for different frames in multiple processes.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|