I think that my problem is a basic one.
Till now I work on devices that runs android version less than Lollipop and everything works fine.
Now after I tried to work with Lollipop, the same code doesn't work.
After a search on web I found some solutions but nothing works for me:
1. I was changed the **initOpenCV** function to this:
public static boolean initOpenCV(String Version, final Context AppContext,
final LoaderCallbackInterface Callback) {
AsyncServiceHelper helper = new AsyncServiceHelper(Version, AppContext,
Callback);
Intent intent = new Intent("org.opencv.engine.BIND");
intent.setPackage("org.opencv.engine");
if (AppContext.bindService(intent, helper.mServiceConnection,
Context.BIND_AUTO_CREATE)) {
return true;
} else {
AppContext.unbindService(helper.mServiceConnection);
InstallService(AppContext, Callback);
return false;
}
}
2. I called the library statically :
static {
if (!OpenCVLoader.initDebug()) {
// Handle initialization error
Log.d("OpenCVManager/Helper", "opencv - Handle initialization error");
}
}
3. I changed the apk file to :
> OpenCV_3.0.0_Manager_3.00_armeabi-v7a.apk
I just have to say that I tried also to run the samples from Opencv folder and they're work.
Another thing that can maybe cause the problem is that I called to the static method not from Activity extended class.
This is a part of my code:
public class CodecOutputSurface implements SurfaceTexture.OnFrameAvailableListener
{
static {
if (!OpenCVLoader.initDebug()) {
// Handle initialization error
Log.d("OpenCVManager/Helper", "opencv - Handle initialization error");
}
}
Mat mainMat;
/**
* Creates a CodecOutputSurface backed by a pbuffer with the specified dimensions. The
* new EGL context and surface will be made current. Creates a Surface that can be passed
* to MediaCodec.configure().
*/
public CodecOutputSurface(int width, int height, int frameSize,int frameSizeROI, int _iteration, SurfaceHolder surfaceHolder, int Screenwidth, int Screenheight, int _zoom , Activity _parentActivity) {
try{
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
eglSetup();
makeCurrent();
setup();
Log.v("My Error", "End CodecOutputSurface constructor");
}
catch(Exception ex)
{Log.v("My Error", "CodecOutputSurface constructor Exception -" + ex.toString());}
}
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(parentActivity) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
Log.v("My Error", "Start SetMatix");
mainMat = new Mat(new Size(mWidth,mHeight),CvType.CV_8U);
//Mat TempmMainMat = new Mat(new Size(mainMat.width(),mainMat.height()),mainMat.type());
Log.v("My Error", "Start SetMatix1");
GrayImage1 = new Mat(new Size(CROPPED_FRAME_SIZE_WIDTH,CROPPED_FRAME_SIZE_HEIGHT),CvType.CV_8U);
GrayImage2 = new Mat(new Size(CROPPED_FRAME_SIZE_WIDTH,CROPPED_FRAME_SIZE_HEIGHT),CvType.CV_8U);
Log.v("My Error", "End SetMatix");
} break;
default:
{
super.onManagerConnected(status);
} break;
}
}
};
↧