Some functions of opencv showing error on some specific scenerio
I am using opencv with android , for that I just try my code first on visual studio with opencv , it works fine on it and then I put it on android, but something is confusing in understanding function and their cause of error like in for example the simple program
resize(image,image,image2.size());
image.convertTo(image,CV_32FC4,1.0/255.0);
image2.convertTo(image2,CV_32FC4,1.0/255.0);
vector<Mat> channel;
split(image,channel);
Mat mask = image.clone(); // clone function work fine
//Mat mask = channel[3].clone(); // clone function show me error
// channel.resize(3); // show error
Mat it;
multiply(mask,channel[0],channel[0]);
multiply(mask,channel[1],channel[1]);
multiply(mask,channel[2],channel[2]);
merge(channel,it);
When I use Mat mask = channel[3].clone();
It show me error of Method 'clone' could not be resolved
but when I use Mat mask = image.clone();
it works fine. Why is that ?
Same when I use channel.resize(3);
it show me error in resize function , error is Invalid arguments 'Candidates are: void resize(?, cv::Mat)'
.
and when I move on to multiply function it show me error of Invalid arguments ' Candidates are: void multiply(const cv::_InputArray &, const cv::_InputArray &, const cv::_OutputArray&, double, int)'
.
Though these all function are working in visual studio using opencv and they are also working in android when using on different scenario's .
I am working on native environment using eclipse with opencv android version of 2.4.8.
multiply and clone alternate work for me as i tried the code below , but don't know how to merge it
Mat alpha1 = ch[3];
Mat alpha = alpha1.clone();
Mat I1;
vector<Mat> ch0 = ch[0];
vector<Mat> ch1 = ch[1];
vector<Mat> ch2 = ch[2];
// I1 = alpha1.mul(ch0);
// I1 = alpha1.mul(ch1);
// I1 = alpha1.mul(ch2);
multiply(alpha, ch0, ch0);
multiply(alpha, ch1, ch1);
multiply(alpha, ch2, ch2);
merge(ch, I1);
Try changing the converto functions to use a clone of the original data. I am not sure if this operator is a safe inplace operator.
clone is not working in android ndk , but i tried the above as `void Vite(Mat& img1, Mat& img2, Mat& out)
{
cv::resize(img2,img2,img1.size());
out=img1+img2; }`
But still the same output
Hmm .clone() is a C++ function thus should work right? What error is that one giving you?
Sorry I deleted my comment , because your comment is valid about .clone() but I didn't explain it well accordingly , lemme edit my question and change it in the way you comment , I can get better answer out of it and can solve my problem easily and quickly
Hmm it seems that the wrapping to android is somewhere failing. To solve the first problem, I think by first assigning channel[3] to a temp Mat element and then calling .clone() on that temporary element should fix the problem, though creating a small overhead. As to the multiply I have no idea why this is happening.
clone work with alternate way and multiply work for me too but need to create different vector<Mat> everytime (i think there is some index problem with ndk) but don't know how to merge it with the image matrix