+ let img =
+ match imgData with
+ | FromMemory i -> i
+ | FromFile path -> new Image<Bgr, byte> (path)
+
+ let mutable tempFile : string option =
+ match imgData with
+ | FromMemory _ -> None
+ | FromFile path ->
+ let tmpDirname = Guid.NewGuid ()
+ let filename = Path.GetFileName path
+
+ // Copy it to a temporary directory.
+ let tmpDir = Path.Combine (Path.GetTempPath (), string tmpDirname)
+ Directory.CreateDirectory tmpDir |> ignore
+ let tmpPath = Path.Combine (tmpDir, filename)
+
+ File.Copy (path, tmpPath)
+
+ Some tmpPath
+