GUI (work in progress..)
[master-thesis.git] / Parasitemia / Parasitemia / MainAnalysis.fs
index 043eb73..5ee6886 100644 (file)
@@ -3,6 +3,8 @@
 open System
 open System.Drawing
 
+open FSharp.Collections.ParallelSeq
+
 open Emgu.CV
 open Emgu.CV.Structure
 
@@ -91,3 +93,13 @@ let doAnalysis (img: Image<Bgr, byte>) (name: string) (config: Config) : Cell li
     | _ -> ()
 
     cells
+
+
+let doMultipleAnalysis (imgs: (string * Image<Bgr, byte>) list) (config : Config) : (string * Cell list) list =
+    let nbConcurrentTaskLimit = 4
+    let n = Environment.ProcessorCount
+
+    imgs
+    |> PSeq.map (fun (id, img) -> id, doAnalysis img id (config.Copy()))
+    |> PSeq.withDegreeOfParallelism (if n > nbConcurrentTaskLimit then nbConcurrentTaskLimit else n)
+    |> PSeq.toList
\ No newline at end of file