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

static Mat.Diag(Mat) の戻りが正方対角行列になっていない #329

Closed
takuya-takeuchi opened this Issue Mar 20, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@takuya-takeuchi
Copy link
Contributor

takuya-takeuchi commented Mar 20, 2017

引数に rows x columns 3x1 の行列を渡した結果が 1x1 の行列になってしまっている。
C++で直接 static Mat::diag(Mat&) で 3x1 の行列を渡した結果は 3x3 の行列になります。
OpenCVSharpのソースを見ると、static Mat.Diag(Mat) は、クラスメソッドである cv::Mat::diag(int d) を呼び出しているが、static Mat::diag(Mat&) の実装は、

inline Mat Mat::diag(const Mat& d)
{
    CV_Assert( d.cols == 1 || d.rows == 1 );
    int len = d.rows + d.cols - 1;
    Mat m(len, len, d.type(), Scalar(0)), md = m.diag();
    if( d.cols == 1 )
        d.copyTo(md);
    else
        transpose(d, md);
    return m;
}

であり、OpenCV::Mat::diag(int d) を呼んでいません。

takuya-takeuchi added a commit to takuya-takeuchi/opencvsharp that referenced this issue Mar 20, 2017

shimat#329: Mat.Diag(Mat) does not reutrn a square diagonal matrix
Add core_Mat_diag3 to call cv::Mat::diag(Mat&) and fix OpenCVSharp.Mat.Diag(Mat) bug

shimat added a commit that referenced this issue Mar 21, 2017

Merge pull request #330 from takuya-takeuchi/feature/MatDiagFix
#329: Mat.Diag(Mat) does not reutrn a square diagonal matrix

@shimat shimat added the bug label Mar 21, 2017

@shimat

This comment has been minimized.

Copy link
Owner

shimat commented Mar 21, 2017

#330 で解決。ありがとうございます 👍

@shimat shimat closed this Mar 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment