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);