Ask Your Question

Revision history [back]

Assertion failed (!fixedType() || ((Mat*)obj)->type() == mtype) in cv::_OutputArray::create while Performing DFT

I am trying to perform DFT on two images such that I get a full size complex valued spectrum. In order to achieve that I have written following code:

cv::Mat_<std::complex<float>> DFTReal2Complex(const cv::Mat_<float>& input) { cv::Mat_<float> result = cv::Mat::zeros(input.size(), input.type()); cv::dft(input, result, cv::DFT_COMPLEX_OUTPUT); //,
return result; }

When I execute the code, I get an exception Assertion failed (!fixedType() || ((Mat*)obj)->type() == mtype) in cv::_OutputArray::create, file C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\core\src\matrix.cpp, line 2130.

If I remove DFT_COMPLEX_OUTPUT flag, the code executes fine but am looking for a complex valued spectrum. 1. Am I using DFT_COMPLEX_OUTPUT flag in a wrong way? Is there another way to do this 2. Is there any way to get a complex valued spectrum in an alternate way?

click to hide/show revision 2
None

updated 2019-12-28 07:54:03 -0600

berak gravatar image

Assertion failed (!fixedType() || ((Mat*)obj)->type() == mtype) in cv::_OutputArray::create while Performing DFT

I am trying to perform DFT on two images such that I get a full size complex valued spectrum. In order to achieve that I have written following code:

cv::Mat_<std::complex<float>> DFTReal2Complex(const cv::Mat_<float>& input)
{
    cv::Mat_<float> result = cv::Mat::zeros(input.size(), input.type());
    cv::dft(input, result, cv::DFT_COMPLEX_OUTPUT);     //, 
return result; }

}

When I execute the code, I get an exception

Assertion failed (!fixedType() || ((Mat*)obj)->type() == mtype) in cv::_OutputArray::create, file C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\core\src\matrix.cpp, line 2130.

2130.

If I remove DFT_COMPLEX_OUTPUT flag, the code executes fine but am looking for a complex valued spectrum. 1. Am I using DFT_COMPLEX_OUTPUT flag in a wrong way? Is there another way to do this 2. Is there any way to get a complex valued spectrum in an alternate way?

click to hide/show revision 3
None

updated 2019-12-28 07:54:19 -0600

berak gravatar image

Assertion failed (!fixedType() || ((Mat*)obj)->type() == mtype) in cv::_OutputArray::create while Performing DFT

I am trying to perform DFT on two images such that I get a full size complex valued spectrum. In order to achieve that I have written following code:

cv::Mat_<std::complex<float>> DFTReal2Complex(const cv::Mat_<float>& input)
{
    cv::Mat_<float> result = cv::Mat::zeros(input.size(), input.type());
    cv::dft(input, result, cv::DFT_COMPLEX_OUTPUT);     //,     
        return result; 
}

When I execute the code, I get an exception

Assertion failed (!fixedType() || ((Mat*)obj)->type() == mtype) in cv::_OutputArray::create, file C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\core\src\matrix.cpp, line 2130.

If I remove DFT_COMPLEX_OUTPUT flag, the code executes fine but am looking for a complex valued spectrum. 1. spectrum.

  1. Am I using DFT_COMPLEX_OUTPUT flag in a wrong way? Is there another way to do this 2. this
  2. Is there any way to get a complex valued spectrum in an alternate way?