I am getting following error while using cv::merge() statement to merge two images:
OpenCV Error: Assertion failed (mv[i].size == mv[0].size && mv[i].depth() == depth) in merge, file /home/yasin/ProgramFile/opencv-3.0.0/modules/core/src/convert.cpp, line 950 terminate called after throwing an instance of 'cv::Exception' what(): /home/yasin/ProgramFile/opencv-3.0.0/modules/core/src/convert.cpp:950: error: (-215) mv[i].size == mv[0].size && mv[i].depth() == depth in function merge
I tried to solve this problem by searching and using some methods but my effort was not useful.
My methods are:
void TakeDFT(cv::Mat&source,cv::Mat&DFTofSource){
cv::Mat OriginalFloat;
OriginalFloat.convertTo(source,CV_32FC1,1.0/255.0);
cv::Mat OriginalComplex[2] = {
OriginalFloat,cv::Mat::zeros(OriginalFloat.size(),CV_32F)
};
cv::Mat dftready;
dftready.convertTo(dftready,CV_32F);
cv::merge(OriginalComplex,2,dftready);
cv::dft(dftready,DFTofSource,cv::DFT_COMPLEX_OUTPUT);
}
and:
void TakeDFT(cv::Mat&source,cv::Mat&DFTofSource){
cv::Mat OriginalFloat;
OriginalFloat.convertTo(source,CV_32FC1,1.0/255.0);
cv::Mat OriginalComplex[2] = {
OriginalFloat,cv::Mat::zeros(OriginalFloat.size(),CV_32F)
};
cv::Mat dftready;
dftready.convertTo(dftready,CV_32F);
std::vector<cv::Mat>array_to_merge;
array_to_merge.push_back(OriginalComplex[0]);
array_to_merge.push_back(OriginalComplex[1]);
cv::merge(array_to_merge,dftready);
cv::dft(dftready,DFTofSource,cv::DFT_COMPLEX_OUTPUT);
}
I'm a beginner in opencv and confused. can anyone help me?
From the OpenCV 3.0 documentation:
The functions merge merge several arrays to make a single multi-channel array.
Your destination matrix dftready is created as one-channel matrix (CV_32F) instead of 2-channel matrix with CV_32FC2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With