Closed warren-byoun closed 2 years ago
I found it by myself.
Cv2_photo.cs:
public static void FastNlMeansDenoisingMulti(
IEnumerable<Mat> srcImgs, OutputArray dst,
int imgToDenoiseIndex, int temporalWindowSize,
float h = 3, int templateWindowSize = 7, int searchWindowSize = 21)
{
if (srcImgs == null)
throw new ArgumentNullException(nameof(srcImgs));
if (dst == null)
throw new ArgumentNullException(nameof(dst));
// changed
dst.ThrowIfNotReady();
var srcImgPtrs = srcImgs.Select(x => x.CvPtr).ToArray();
NativeMethods.HandleException(
NativeMethods.photo_fastNlMeansDenoisingMulti(
srcImgPtrs, srcImgPtrs.Length, dst.CvPtr,
imgToDenoiseIndex,
temporalWindowSize, h, templateWindowSize, searchWindowSize));
dst.Fix();
GC.KeepAlive(srcImgs);
/*
//previous source
var srcImgsAsArrays = srcImgs.Select(m => new InputArray(m)).ToArray();
try
{
FastNlMeansDenoisingMulti(srcImgsAsArrays, dst, imgToDenoiseIndex, temporalWindowSize,
h, templateWindowSize, searchWindowSize);
}
finally
{
foreach (var img in srcImgsAsArrays)
{
img.Dispose();
}
}
*/
}
photo.h in OpenCvSharpExtern
CVAPI(ExceptionStatus) photo_fastNlMeansDenoisingMulti(cv::Mat ** srcImgs, int srcImgsLength,
cv::_OutputArray *dst, int imgToDenoiseIndex, int temporalWindowSize,
float h, int templateWindowSize, int searchWindowSize)
{
BEGIN_WRAP
std::vector<cv::Mat> srcImgsVec;
for (int i = 0; i < srcImgsLength; i++)
srcImgsVec.push_back(*srcImgs[i]);
cv::fastNlMeansDenoisingMulti(srcImgsVec, *dst, imgToDenoiseIndex, temporalWindowSize, h, templateWindowSize,
searchWindowSize);
END_WRAP
}
Thank you for your information!
Summary of your issue
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:
Output:
What did you intend to be?