Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please provide F# examples #23

Open
OlegAlexander opened this issue May 15, 2022 · 2 comments
Open

Please provide F# examples #23

OlegAlexander opened this issue May 15, 2022 · 2 comments

Comments

@OlegAlexander
Copy link

OlegAlexander commented May 15, 2022

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!

@charlesroddie
Copy link

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)

@OlegAlexander
Copy link
Author

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants