I am looking for a way to overlay an image in openCV(2.4.3) for Android. Basically, I am doing some image filtering, and I want the user to be able to see the cleanly filtered video stream, but in the upper hand corner see a preview of what the filter is doing:
I have tried setting an ROI on the filtered image, and the using AddWeighted in JNI code like this
In Activity:
liveFrame.copyTo(mRgba); //going to be used as the unfiltered stream
//image filtering happends here...
Rect roi = new Rect(0, 0, liveFrame.cols()/4, liveFrame.rows()/4);
mProcMat = new Mat(liveFrame, roi);
AddMats(mRgba.getNativeObjAddr(),mProcMat.getNativeObjAddr()); //will add the two, assign the result to mRgba
AddMats (Native Method):
Mat* image1=(Mat*)mat1;
Mat* image2 = (Mat*)mat2;
float alpha = 0.5;
float beta = 0.5;
addWeighted( (InputArray)*image1, alpha, (InputArray)*image2, beta, 0.0, (OutputArray)*image1);
But this wont work because the size of the images has to be the same, so I cant seem to think of a way to get this to work. I can do this easily in iOS, because you can simply just apply the frame to a new view on top of the live stream. For Android, as far as I know, you can only have 1 surface view per camera input stream. So thats why I went down the path of doing this in opencv, but I would consider ANY solution at this point