At first thanks for the reply
i found another solution for this using the following tutorial http://www.jpct.net/forum2/index.php?topic=1586.0, but i changed the CameraView class for another similar, but with OpenCV integrated, i will put here a llitle example if someone need to use OpenCV with JPCT-AE
Activity XML File:
Activity Java File:
CameraView Java Class:
The class RendererJPCT its simple class extended of Renderer
I hope this will helpful, thanks EgonOlsen
i found another solution for this using the following tutorial http://www.jpct.net/forum2/index.php?topic=1586.0, but i changed the CameraView class for another similar, but with OpenCV integrated, i will put here a llitle example if someone need to use OpenCV with JPCT-AE
Activity XML File:
Code Select
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=your application context>
<android.opengl.GLSurfaceView
android:id="@+id/glsurfaceview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<CameraView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/cameraView"
opencv:show_fps="true"
opencv:camera_id="any" >
</CameraView>
</FrameLayout>
Activity Java File:
Code Select
public class MainActivity extends AppCompatActivity {
private GLSurfaceView glSurfaceView;
private RendererJPCT renderer;
private boolean gl2 = true;
private CameraView cameraView;
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
Log.i(TAG, "OpenCV loaded successfully");
cameraView.enableView();
} break;
default:
{
super.onManagerConnected(status);
} break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
if(masterMainActivity != null){
copyActivity(masterMainActivity);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.
FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
cameraView = (CameraView) findViewById(R.id.cameraView);
cameraView.setVisibility(SurfaceView.VISIBLE);
cameraView.setCvCameraViewListener(cameraView);
glSurfaceView = (GLSurfaceView) findViewById(R.id.glsurfaceview);
if (gl2) {
glSurfaceView.setEGLContextClientVersion(2);
} else {
glSurfaceView.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
int[] attributes = new int[] { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE };
EGLConfig[] configs = new EGLConfig[1];
int[] result = new int[1];
egl.eglChooseConfig(display, attributes, configs, 1, result);
return configs[0];
}
});
}
glSurfaceView.setEGLConfigChooser(8,8,8,8,16,0);
renderer = new RendererJPCT(masterMainActivity);
glSurfaceView.setRenderer(renderer);
glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
}
}
CameraView Java Class:
Code Select
public class CameraView extends JavaCameraView implements CvCameraViewListener2{
public CameraView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void onCameraViewStarted(int width, int height) {
}
@Override
public void onCameraViewStopped() {
}
@Override
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
return inputFrame.rgba();
}
}
The class RendererJPCT its simple class extended of Renderer
I hope this will helpful, thanks EgonOlsen