-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.fs
41 lines (25 loc) · 1.44 KB
/
Program.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
open System
open lensfunNet
open OpenCvSharp
let undistort (remap : float32[]) (img : Mat) =
let size = img.Size()
let remapMat = new Mat(size.Height, size.Width, MatType.CV_32FC2, remap)
let outimg = new Mat(size, img.Type())
let map = InputArray.Create(remapMat)
Cv2.Remap(InputArray.Create img, OutputArray.Create outimg,map,InputArray.Create(new Mat()), InterpolationFlags.Lanczos4)
outimg
let undistortJpg (filename : string) (undistored : string) =
let db = LensFun.initLf "./db_files"
let cameraParameters = Exif.fileToParams filename
let img = Cv2.ImRead filename
let width,height = img.Size(1), img.Size(0)
let lensInfo = LensFun.createModifier db cameraParameters width height
let outimg = undistort lensInfo.remap.Value img
let info = { MetaData.imageInfo = lensInfo } |> MetaData.toJson
Cv2.ImWrite(undistored, outimg) |> printfn "ok: %A"
[<EntryPoint;STAThread>]
let main argv =
LensFun.downloadLensFunFromWheels "." "./db_files"
undistortJpg @"C:\Users\hs\Aardworx GmbH\FotoFassade - Dokumente\Data\Datensaetze Fotoaufnahmen\P1010337.JPG" @"C:\Users\hs\Aardworx GmbH\FotoFassade - Dokumente\Data\Datensaetze Fotoaufnahmen\P1010337_undistNew.JPG"
//undistortJpg @"C:\Users\hs\Aardworx GmbH\FotoFassade - Dokumente\Data\Datensaetze Fotoaufnahmen\IMG_6042.JPG" @"C:\Users\hs\Aardworx GmbH\FotoFassade - Dokumente\Data\Datensaetze Fotoaufnahmen\IMG_6042_undist.JPG"
0