Calling an overloaded C # method from F #

There are a few similar questions on SO, but I cannot find what I am looking for.

There is a C # library (OpenCVSharp) declaring an overloaded method as follows:

public static void CalcHist(Mat[] images, 
            int[] channels, InputArray mask,
            OutputArray hist, int dims, int[] histSize,
            Rangef[] ranges, bool uniform = true, bool accumulate = false)
{
           ....
}

public static void CalcHist(Mat[] images,
            int[] channels, InputArray mask,
            OutputArray hist, int dims, int[] histSize,
            float[][] ranges, bool uniform = true, bool accumulate = false)
{
    ....
}

i.e. changing only by the type of the parameter "ranges".

I can’t name this method, even if it is used in the style of an argument argument, including optional parameters and adds a whole bunch of annotations like:

let images = [|new Mat()|] 
let hist = OutputArray.Create(new Mat());
let hdims = [|256|];
let ranges = [| new Rangef(0.f,256.f) |];
Cv2.CalcHist<Mat [] * int [] * InputArray * OutputArray * int * int [] * Rangef [] * bool * bool>
            (images,
            [|0|],
            null,
            hist,
            1,
            hdims,
            ranges,
            true,
            false)

Error: "Error 4 The constructor of the CalcHist element or object that takes 9 arguments is not accessible from this code location. All available versions of the CalcHist method accept 9 arguments."

Is there any way to call this method from F #?

+4
source share
1

, , . :

let imGeneric<'t, 'u> (x: 't, y: 'u) = ...
let callGeneric = imGeneric<int, string> (5, "abc")

, , F # , :

let imGeneric (x, y) = ...
let callGeneric = imGeneric (5, "abc")

Cv2.CalcHist . , :

Cv2.CalcHist( images, [|0|], null, hist, 1, hdims, ranges, true, false )

, , ranges Rangef [], .

( ) . :

Cv2.CalcHist( 
   images, [|0|], null, hist, 1, hdims, 
   (ranges : Rangef []), 
   true, false )

(ranges : Rangef []). ranges, images, [|0|], null, hist, 1, hdims, ranges, , Rangef [].

:

let ranges: Rangef [] = getRanges()
Cv2.CalcHist( images, [|0|], null, hist, 1, hdims, ranges, true, false )

. , , , , .

+5

Source: https://habr.com/ru/post/1608525/


All Articles