lundi 2 mars 2020

Concurrency design in image processing

I'm new to this topic and I need to design concurrency for a program that includes the following tasks:

1. Load image from the database (100ms)
2. Find some metadata of the image (50ms)
3. Converts the image to grayscale. (100ms)
4. Finds all objects in the greyscale image. (600ms)
5. Crop the parts of the image that contain the object. (100ms / object)
6. Saves the data (original image, metadata and new cropped images) in a database (100ms)

How could I design to run the program in concurrent way. I found that step 2 is independent of step 3,4,5,6, so it can be run in parallel as follow:

1->2     -> 6
   3->4->5

However, since task 2 is only 50ms and task 6 need to have all task 2,3,4,5 done to be executed. How can I specify that task 2 need to "wait" for the other tasks?

To run concurrent, what is a reasonable pattern for this problem? And what kind of possible issues may arise? I'm thinking of a "pipeline pattern" like this. But not sure if there is a more efficient pattern

1->2     -> 6
   3->4->5
   1->2     -> 6
      3->4->5
      1->2     -> 6
         3->4->5
...

Thanks in advanced!

Aucun commentaire:

Enregistrer un commentaire