Question

I've tried bitwise xor on android but I get the following error:

04-11 00:25:47.404: E/cv::error()(7370): OpenCV Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and type), nor 'array op scalar', nor 'scalar op array') in void cv::binary_op(cv::InputArray, cv::InputArray, cv::OutputArray, cv::InputArray, void (* const*)(const uchar*, size_t, const uchar*, size_t, uchar*, size_t, cv::Size, void*), bool), file /home/reports/ci/slave/50-SDK/opencv/modules/core/src/arithm.cpp, line 1021

Here is my code:

Mat temp1 = mRgba.submat(roi); 
Mat temp2 = Mat.zeros(temp1.size(), CvType.CV_8UC1);    
Core.bitwise_xor(temp1, temp2, temp1);

I've also tried to instantiate temp1 and temp2 the following way:

Mat temp1 = new Mat(height, width, CvType.CV_8UC1); 
Mat temp2 = new Mat(height, width, CvType.CV_8UC1);

But still the same error..

Was it helpful?

Solution

Your code doesn't mention the type of mRgba, but from the name I assume it is RGBA, or CV_8UC4. This means that temp1 will be of the same type as mRgba. As the error states, both matrices must be of the same size and type. That means that either temp2 must be declared as type CV_8UC4 or you must first convert mRgba to CV_8UC1, perhaps via converting to greyscale. I'm not familiar with the Java interface, but the equivalent C++ call would be:

cv::cvtColor(mRgba, mRgba, CV_RGBA2GRAY);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top