Ask Your Question

Jack jack jacky's profile - activity

2017-08-19 08:24:27 -0600 asked a question How to reconstruct matrix from eigenvalues and eigenvectors?

I use cv::eigen to calculate a symmetric matrix's eigenvalues and eigenvectors, but I have no ideas how to reconstruct the original matrix. I have tried the following code but failed:

    cv::Mat square_vals(eigenvalues.rows, eigenvalues.rows, CV_32FC1, cv::Scalar(0));
for (int i = 0; i < eigenvalues.rows; ++i) {
    square_vals.ptr<float>(i)[i] = eigenvalues.ptr<float>(i)[0];
}
cv::Mat e = eigenvectors * square_vals * eigenvectors_inverted;
2017-08-13 01:54:51 -0600 received badge  Scholar (source)
2017-08-10 23:35:33 -0600 asked a question cv::Mat_ vs std::vector

Which is better, cv::Mat_<cv::point2f> or std::vector<cv::point2f>?

2017-08-10 06:37:11 -0600 asked a question How to avoid memory deallocation error when using OpenCV as DLL?

The following codes will result in debug assertion fault (when deconstructing corners) like '_Debug Assertion Failed! Expression: _acrt_first_block == header':

std::vector<cv::Point2f> corners;
cv::goodFeaturesToTrack(image_gray, corners, 4, 0.01, 100);

The problem lies in different heaps used for allocation and deallocation (because the OpenCV DLLs and my executeable use different CRT).

Replacing std::vector<cv::point2f> with cv::Mat_<cv::point2f> will solve the problem.

However, some functions (e.g. cv::findContours) accept std::vector only, so how can I avoid potential memory deallocation error in such case? Thanks.