Output error dft() function

I am trying to use following code, but it gives error. Error message is like : OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si ze.p[0] && (unsigned)(i1DataType<_Tp>::channels) < (unsigned)(size.p[1]channel s()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3 ) - 1))*4) & 15) == elemSize1()) in unknown function, file c:\program files (x86 )\opencv2.2\include\opencv2\core\mat.hpp, line 517

My code is given below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int main(.....)
{
vector<double>pdf_vector;
//read data from file and put it in pdf_vector.
vector<double>all_vector;
Mat dft_input_vector(pdf_vector);
Mat dft_output_vector;
dft(dft_input_vector, dft_output_vector);

for(i=0;i<1;i++)
{
   for(j=0;j<pdf_vector.size ();j++)
    {
      all_vector.push_back (dft_output_vector.at <float>(i,j));
    }   
}

.................
}
Revised code would be

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int main(.....)
{
vector<double>pdf_vector;
//read data from file and put it in pdf_vector.
vector<double>all_vector;
Mat dft_input_vector(pdf_vector);
Mat dft_output_vector;
dft(dft_input_vector, dft_output_vector);

for(i=0;i<pdf_vector.size ();i++)
{
   for(j=0;j<1;j++)
    {
      all_vector.push_back (dft_output_vector.at <double>(i,j));
    }   
}

.................
}
Well what are you trying to do?

You have two for loops but yet the variables i and j are not declared? You should have written:

 
for (int i=0;i<1;i++)


Why on earth are you doing this anyway, it will only iterate once i.e. while i==0

 
for (int j=0; j<pdf_vector.size();j++)


What are the following lines attempting to do? Have you defined Mat and dft somewhere?
1
2
3
Mat dft_input_vector(pdf_vector);
Mat dft_output_vector;
dft(dft_input_vector, dft_output_vector);
I am using OpenCV library, and Mat & dft are from OpenCV.
Topic archived. No new replies allowed.