CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2013
    Posts
    21

    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>:epth) & ((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:

    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<1;i++)
    {
       for(j=0;j<pdf_vector.size ();j++)
        {
          all_vector.push_back (dft_output_vector.at <float>(i,j));
        }   
    }
    
    .................
    }

  2. #2
    Join Date
    Feb 2013
    Posts
    21

    Re: Output error dft() function.

    Revised code would be
    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));
    }
    }

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

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Output error dft() function.

    Quote Originally Posted by nihad View Post
    Revised code would be

    Code:
    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));
        }   
    }
    .................
    }
    Why do you need so strange "loop"? Why not just write
    Code:
    for(i=0;i<pdf_vector.size ();i++)
    {
           all_vector.push_back (dft_output_vector.at <double>(i, 0));
    }
    Victor Nijegorodov

  4. #4
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Output error dft() function.

    line 517 in matt.hpp is part of the at method. So the problem is with dft_output_vector.at

    Code:
    all_vector.push_back (dft_output_vector.at <double>(i,j));
    You'll need to debug the code to find the reason.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured