Ask Your Question
0

Output error dft() function

asked 2013-03-21 05:40:24 -0600

Nihad gravatar image

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:

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));
    }   
}

.................
}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-03-21 06:15:32 -0600

berak gravatar image

updated 2013-03-21 06:17:23 -0600

found 2 bugs here:

  1. dft_output_vector.at <float> that should be double here, right ?
  2. a construct like this: Mat dft_input_vector(pdf_vector); makes a n-row, 1-column matrix, not a 1 row matrix, so your dft output has the same layout. you got rows(n) and cols(1) wrong in your loops

btw, nothing to do with dct here(that's even misleading), it's a plain how-to-access-a-matrix problem

edit flag offensive delete link more

Comments

Thank you. Yes, you are correct. Here is my revised code. 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)); }
}

................. }

Nihad gravatar imageNihad ( 2013-03-21 06:24:57 -0600 )edit

Question Tools

Stats

Asked: 2013-03-21 05:40:24 -0600

Seen: 624 times

Last updated: Mar 21 '13