Hello everybody
My target is to make an android application with openCV, that has a camera preview. In this preview i want to filter out a color range and set it transparent. For example, I want to filter out green and set it to transparent.
Question 1: is it possible to make parts of the CvCameraViewFrame transparent?
In the background of my application, (behind the camerapreview) is a static picture that should come through the transparent part of the camera preview.
Question 2: with respect to these answers: sustract color from Mat why is following code not working?
android activity:
public Mat onCameraFrame(CvCameraViewFrame inputFrame){
mRgba = inputFrame.rgba();
RemovePink(mRgba.getNativeObjAddr());
return mRgba;
}
public native void RemovePink( long matAddrRgba);
and the jni:
JNIEXPORT void JNICALL
Java_org_opencv_samples_tutorial2_Tutorial2Activity_RemovePink(JNIEnv*, jobject, jlong addrRgba);
JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial2_Tutorial2Activity_RemovePink(JNIEnv*, jobject, jlong addrRgba){
Mat& mRgba = *(Mat*)addrRgba;
Mat alpha;
inRange(mRgba , Scalar(0,0,250), Scalar(0,0,255),alpha);
bitwise_not(alpha,alpha);
//split source
Mat bgr[4];
split(mRgba ,bgr);
//Merge to final image including alpha
Mat tmp[4] = { bgr[0],bgr[1],bgr[2],alpha};
merge(mRgba ,4,dst);
}
}
thanks in advance for every kind of help!