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

#329: Mat.Diag(Mat) does not reutrn a square diagonal matrix #330

Merged
merged 1 commit into from Mar 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/OpenCvSharp/PInvoke/core/NativeMethods_core_Mat.cs
Expand Up @@ -103,6 +103,8 @@ static partial class NativeMethods
[DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern IntPtr core_Mat_diag2(IntPtr self, int d);
[DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern IntPtr core_Mat_diag3(IntPtr self);
[DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern double core_Mat_dot(IntPtr self, IntPtr m);
[DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ulong core_Mat_elemSize(IntPtr self);
Expand Down
4 changes: 3 additions & 1 deletion src/OpenCvSharp/modules/core/Mat/Mat.cs
Expand Up @@ -655,7 +655,9 @@ public static Mat FromImageData(byte[] imageBytes, ImreadModes mode = ImreadMode
/// <returns></returns>
public static Mat Diag(Mat d)
{
return d.Diag();
IntPtr retPtr = NativeMethods.core_Mat_diag3(d.CvPtr);
Mat retVal = new Mat(retPtr);
return retVal;
}

#endregion
Expand Down
5 changes: 5 additions & 0 deletions src/OpenCvSharpExtern/core_Mat.h
Expand Up @@ -221,6 +221,11 @@ CVAPI(cv::Mat*) core_Mat_diag2(cv::Mat *self, int d)
cv::Mat ret = self->diag(d);
return new cv::Mat(ret);
}
CVAPI(cv::Mat*) core_Mat_diag3(cv::Mat *self)
{
cv::Mat ret = cv::Mat::diag(*self);
return new cv::Mat(ret);
}

CVAPI(double) core_Mat_dot(cv::Mat *self, cv::Mat *m)
{
Expand Down