(TUTORIAL) introduction_to_pca

asked 2015-04-22 15:03:21 -0600

LBerger gravatar image

updated 2015-04-22 15:10:48 -0600

Hi,

I want to run tutorial introduction_to_pca with image pca_test1.jpg in folder sample/data. When I launch this tutorial I have got this error :

OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)size.p[0] && (unsigned)(i1 * DataType<_Tp>::channels)
< (unsigned)(size.p[1] * channels()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3) - 1))*4) & 15) ==
elemSize1()) in cv::Mat::at, file F:\Lib\opencv\modules\core\include\opencv2/core/mat.inl.hpp, line 872

In source introduction_to_pca error occurs.cpp at line 76

eigen_val[i] = pca_analysis.eigenvalues.at<double>(0, i);

Have you got same errors using opencv 3.0 windows 7-64bits visual studio 2013?

Is it a good idea to change line 76 in

eigen_val[i] = pca_analysis.eigenvalues.at<double>(i, 0);

Thanks for yours answers

edit retag flag offensive close merge delete

Comments

@LBerger it is strange that you get this error, here it works without any issues. However, I am in linux and qtcreator environment. As, for changing the code in line 76 you can do it freely. It does not affect, the outcome.

theodore gravatar imagetheodore ( 2015-04-22 17:27:56 -0600 )edit

I have added before line 76

    cout << pca_analysis.eigenvalues.rows << " " << pca_analysis.eigenvalues.cols<<"\n";

result is 2 rows and 1 column

LBerger gravatar imageLBerger ( 2015-04-22 19:55:34 -0600 )edit
1

@theodore, are you running a debug build ? this is one of the dreaded CV_DbgAsserts, that do not show up in release.

also, imho @LBerger is right, it should be pca_analysis.eigenvalues.at<double>(i, 0);

berak gravatar imageberak ( 2015-04-23 00:21:08 -0600 )edit

@berak yup I am running it in the debug mode and no problem.

theodore gravatar imagetheodore ( 2015-04-23 05:27:37 -0600 )edit

i'm getting the same exception.

berak gravatar imageberak ( 2015-04-23 05:29:07 -0600 )edit

I see. In what kind of environment are you e.g. windows, linux, visual studio, etc...

theodore gravatar imagetheodore ( 2015-04-23 05:42:49 -0600 )edit