Android OpenCV 3.1 seamlessclone [closed]
I'm trying to execue the following lines in native OpenCV for Android (C++). And everything compiles.
warpedSub.convertTo(warpedSub, CV_8UC3);
img2sub.convertTo(img2sub, CV_8UC3);
output.convertTo(output, CV_8UC3);
maskSub.convertTo(maskSub, CV_8UC1);
seamlessClone(warpedSub, img2sub, maskSub, center, output, NORMAL_CLONE);
But I get this error when executing:
E/cv::error(): OpenCV Error: Assertion failed (CV_MAT_TYPE(mtype) == m.type()) in void cv::_OutputArray::create(int, const int*, int, int, bool, int) const, file /builds/master_pack-android/opencv/modules/core/src/matrix.cpp, line 2236
According to the OpenCV documentation, I have the correct types. I have also tested a prototype completely in C++ on my desktop computer and it all works fine! I don't know what to do, please help!
what are all those convertTo()'s for ?
are you aware, that those only change the depth, not the channel count ?
how do you initialize those Mat's in the 1st place ? please show some more code above those lines.
In Java:
where path1 and path2 are the paths to the bitmaps.
In C++:
where the addrImg1 and addrImg2 are jlong:s
again: reason behind the convertTo's ?
I removed them. But I think Java sends 4-channel images, so I have to convert them to 3-channel images.
ahh, that might explain the complaint about the types.
please use
Imgproc.cvtColor(src,dst,COLOR_BGRA2BGR)
then, notconvertTo()
It seems to work! Thank you very much!