camera preview from opencv shows bad/incorrect image. using javacameraview

asked 2016-03-11 12:36:53 -0500

mihirranadive gravatar image

The System I'm using is: Mac + Eclipse + Opencv4Android (v3.0)

all samples and everything is running correctly except for the results or quality displayed by the camera. here is a sample below of how it looks http://imgur.com/fGgw1Sr

This is not just through the emulator but also when I upload it to my phone. in the image the tablet cover is actually bright red, the phone is blue. here is the clear image from the actual android camera app: http://imgur.com/kSdDVSI

the transparent layer on top is also a bother. I thought it was because of the alpha channel but I've tried removing it also why does it show up 4 times?

I've used only a basic code to setup my opencv here it is AndroidManifest.xml file:

<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.CAMERA"/>

<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>

MainActivity:

private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
    switch (status) {
    case LoaderCallbackInterface.SUCCESS: 
    {
        Log.i(TAG, "OpenCV loaded successfully");

        // Load native library after(!) OpenCV initialization
        // System.loadLibrary("mixed_sample");

        mOpenCvCameraView.enableView();
        break;
    }
    default: {
        super.onManagerConnected(status);
    }
        break;
    }
}
};

@Override
public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "called onCreate");
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_main);
mOpenCvCameraView = (JavaCameraView) findViewById(R.id.aslgesturerecogapp_surface_view);
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraView.setCvCameraViewListener(this);
}

@Override
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
return inputFrame.rgba();
}

This is the only layout file used:

 <RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.aslgesturerecogapp.MainActivity" >

<org.opencv.android.JavaCameraView
android:id="@+id/aslgesturerecogapp_surface_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
opencv:show_fps="true"
opencv:camera_id="any"
/>
</RelativeLayout>
edit retag flag offensive close merge delete