Repository: shimat/opencvsharp (csharp)

Issue:
FastNlMeansDenoisingMulti does not work
# Summary of your issue

<!-- Please refrain from posting issues other than those related to the WRAPPERS. Please look up the native OpenCV information. -->

# Environment

Visual Studio 2017, 
OpenCvSharp4 v4.5.5



# What did you do when you faced the problem?

I uses
Cv2.FastNlMeanDenoising and Cv2.FastNIMeanDenoisingMulti

Cv2.FastNIMeanDenoising works fine.
But Cv2.FastNIMeanDenoisingMulti does not.

exception occurs :
"Unsupported depth! Only CV_8U is supported for NORM_L2"

MatTypes of input sources are MatType.CV_8UC1 all. 

## Example code:

<!-- ↓do not remove ``` please!!! -->
```
public override int Run(ClsImageCollection<Mat> inputImages)
        {
            try
            {
                Mat outMat = new Mat(this.OutputImageHeight, this.OutputImageWidth, MatType.CV_8UC1);
                if (inputImages.Count == 1)
                    Cv2.FastNlMeansDenoising(inputImages[0], outMat, this.h, this.templateWindowSize, this.searchWindowSize);
                else
                {
                    List<Mat> inputs = inputImages.Values.ToList();
                    inputs.ForEach(mat => Trace.WriteLine($"{mat.Depth()}"));

                    Cv2.FastNlMeansDenoisingMulti(inputs, outMat, this.InputCount / 2, this.InputCount, this.h, this.templateWindowSize, this.searchWindowSize);
                }
                _outputImages.Add(0, outMat);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                Trace.WriteLine(ex.StackTrace);
                return ClsFilter.NG;
            }
            return ClsFilter.OK;
            //return base.Run(inputImages);
        }


```



## Output:

<!-- ↓do not remove ``` please!!! -->
```
예외 발생: 'OpenCvSharp.OpenCVException'(OpenCvSharp.dll)
Unsupported depth! Only CV_8U is supported for NORM_L2
   위치: OpenCvSharp.Internal.NativeMethods.<>c.<.cctor>b__1674_0(ErrorCode status, String funcName, String errMsg, String fileName, Int32 line, IntPtr userData)
   위치: OpenCvSharp.Internal.NativeMethods.photo_fastNlMeansDenoisingMulti(IntPtr[] srcImgs, Int32 srcImgsLength, IntPtr dst, Int32 imgToDenoiseIndex, Int32 temporalWindowSize, Single h, Int32 templateWindowSize, Int32 searchWindowSize)
   위치: OpenCvSharp.Cv2.FastNlMeansDenoisingMulti(IEnumerable`1 srcImgs, OutputArray dst, Int32 imgToDenoiseIndex, Int32 temporalWindowSize, Single h, Int32 templateWindowSize, Int32 searchWindowSize)
   위치: OpenCvSharp.Cv2.FastNlMeansDenoisingMulti(IEnumerable`1 srcImgs, OutputArray dst, Int32 imgToDenoiseIndex, Int32 temporalWindowSize, Single h, Int32 templateWindowSize, Int32 searchWindowSize)
   위치: ACE.Imaging.Filter.ClsFilterNLM.Run(ClsImageCollection`1 inputImages) 파일 D:\Work-PlatformLAB\Project\02.ACE\03.Source\ACEProject\ACE\ACE.Imaging\Filter\ClsFilterNLM.cs:줄 85

where 예외 발생 = exception, 위치 = location, 줄 = line
```

## What did you intend to be?

Pull request:
issue is caused by improper std::vector allocation
fixes #1402

Patch:
diff --git a/src/OpenCvSharpExtern/photo.h b/src/OpenCvSharpExtern/photo.h
index 439160967..c9b48780d 100644
--- a/src/OpenCvSharpExtern/photo.h
+++ b/src/OpenCvSharpExtern/photo.h
@@ -37,7 +37,7 @@ CVAPI(ExceptionStatus) photo_fastNlMeansDenoisingMulti(cv::Mat **srcImgs, int sr
 {
     BEGIN_WRAP
 
-    std::vector<cv::Mat> srcImgsVec;
+    std::vector<cv::Mat> srcImgsVec(srcImgsLength);
     for (int i = 0; i < srcImgsLength; i++)
         srcImgsVec[i] = *srcImgs[i];
 


Test patch:
diff --git a/test/OpenCvSharp.Tests/photo/PhotoTest.cs b/test/OpenCvSharp.Tests/photo/PhotoTest.cs
index f3b55a64a..d91bb5729 100644
--- a/test/OpenCvSharp.Tests/photo/PhotoTest.cs
+++ b/test/OpenCvSharp.Tests/photo/PhotoTest.cs
@@ -32,7 +32,6 @@ public void FastNlMeansDenoising()
             Window.ShowImages(src, dst);
     }
 
-    /*
     [Fact]
     public void FastNlMeansDenoisingMulti()
     {
@@ -45,5 +44,5 @@ public void FastNlMeansDenoisingMulti()
 
         if (Debugger.IsAttached)
             Window.ShowImages(src1, src2, dst);
-    }*/
+    }
 }