Skip to content

Commit c713d1f

Browse files
committed
Expose InputArray's GetUMat
1 parent 9aefbd0 commit c713d1f

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

src/OpenCvSharp/Internal/PInvoke/NativeMethods/core/NativeMethods_core_InputArray.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ static partial class NativeMethods
4545
public static extern ExceptionStatus core_InputArray_getMat(IntPtr ia, int idx, out IntPtr returnValue);
4646
//[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
4747
//public static extern ExceptionStatus core_InputArray_getMat_(IntPtr ia, int idx, out IntPtr returnValue);
48-
//[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
49-
//public static extern IntPtr core_InputArray_getUMat(IntPtr ia, int idx);
48+
49+
[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
50+
public static extern ExceptionStatus core_InputArray_getUMat(IntPtr ia, int idx, out IntPtr returnValue);
51+
5052
[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
5153
public static extern ExceptionStatus core_InputArray_getMatVector(IntPtr ia, IntPtr mv);
5254
//[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]

src/OpenCvSharp/Modules/core/InputArray.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,20 @@ public Mat[] GetMatVector()
742742
return vec.ToArray();
743743
}
744744

745+
/// <summary>
746+
///
747+
/// </summary>
748+
/// <param name="i"></param>
749+
/// <returns></returns>
750+
public UMat GetUMat(int i = -1)
751+
{
752+
ThrowIfDisposed();
753+
NativeMethods.HandleException(
754+
NativeMethods.core_InputArray_getUMat(ptr, i, out var ret));
755+
GC.KeepAlive(this);
756+
return new UMat(ret);
757+
}
758+
745759
/// <summary>
746760
///
747761
/// </summary>

src/OpenCvSharpExtern/core_InputArray.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,15 @@ CVAPI(ExceptionStatus) core_InputArray_getMat(cv::_InputArray *ia, int idx, cv::
116116
*returnValue = new cv::Mat(ia->getMat_(idx));
117117
END_WRAP
118118
}*/
119-
/*CVAPI(cv::UMat*) core_InputArray_getUMat(cv::_InputArray *ia, int idx)
119+
120+
CVAPI(ExceptionStatus) core_InputArray_getUMat(cv::_InputArray* ia, int idx, cv::UMat** returnValue)
120121
{
121-
return new cv::UMat(ia->getUMat(idx));
122-
}*/
122+
BEGIN_WRAP
123+
* returnValue = new cv::Mat(ia->getUMat(idx));
124+
END_WRAP
125+
126+
}
127+
123128
CVAPI(ExceptionStatus) core_InputArray_getMatVector(cv::_InputArray *ia, std::vector<cv::Mat> *mv)
124129
{
125130
BEGIN_WRAP

0 commit comments

Comments
 (0)