SciSharp/SharpCV

Please provide F# examples

OlegAlexander opened this issue · 2 comments

Hello and thank you for creating SharpCV. Could you please provide a few F# examples in the readme? Because I'm having trouble getting SharpCV to work in F#. Thank you!

This code type-checks:

open SharpCV
open type SharpCV.Binding

let arr =
    let m =
        [   [ 0.; 1.; 0. ]
            [ -1.; 5.; -1. ]
            [ 0.; -1.; 0.]
        ] |> array2D
    new Tensorflow.NumPy.NDArray(m)
let mat = new Mat(arr)

@charlesroddie Yes! It's working for me now. open type is what I was missing.

Here's my working example:

#r "nuget: SharpCV"
#r "nuget: OpenCvSharp4.runtime.win"
open SharpCV
open type SharpCV.Binding

let img = cv2.imread("image.png")
let imgSmall = cv2.resize(img, (0,0), 0.5, 0.5, InterpolationFlags.INTER_CUBIC)
cv2.imshow("imgSmall", imgSmall)
cv2.waitKey(0);

Now a related question: How do I display a cv image in a .NET Interactive Notebook in VS Code? Thanks!