+
+// ID * cell list.
+let doMultipleAnalysis (imgs: (string * Config * Image<Bgr, byte>) list) (reportProgress: (int -> unit) option) : (string * Cell list) list =
+ let inline report (percent: int) =
+ match reportProgress with
+ | Some f -> f percent
+ | _ -> ()
+
+ let progressPerAnalysis = System.Collections.Concurrent.ConcurrentDictionary<string, int>()
+ let nbImgs = List.length imgs
+
+ let reportProgressImg (id: string) (progress: int) =
+ progressPerAnalysis.AddOrUpdate(id, progress, (fun _ _ -> progress)) |> ignore
+ report (progressPerAnalysis.Values.Sum() / nbImgs)
+
+ let n = Environment.ProcessorCount
+
+ imgs
+ |> PSeq.map (fun (id, config, img) -> id, doAnalysis img id config (Some (fun p -> reportProgressImg id p)))
+ |> PSeq.withDegreeOfParallelism n
+ |> PSeq.toList