I am using a simple code to open up a camera on opencv the app works fine on LG G Pro but crashes on samsung galaxy S4 I am using OPENCV 2.4.1 and android studio
Please Note that this activity is called via another activity through intent.
GameActivity.java
public class GameActivity extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2 { public static final String MY_TAG = "MY_CUSTOM_MESSAGE"; private JavaCameraView javaCameraView;
private BaseLoaderCallback baseLoaderCallback= new BaseLoaderCallback(this) { @Override public void onManagerConnected(int status) { switch (status){ case LoaderCallbackInterface.SUCCESS: { Log.i(MY_TAG, "OPENCV Loaded"); javaCameraView.enableView(); break; } default: super.onManagerConnected(status); } } };
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_game); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); Log.i(MY_TAG, "onCreate Act 2");
javaCameraView=(JavaCameraView)findViewById(R.id.MyJavaCam);
javaCameraView.setVisibility(SurfaceView.VISIBLE);
javaCameraView.setCvCameraViewListener(this);
}
@Override protected void onResume() { super.onResume(); Log.i(MY_TAG, "onResume Act 2"); OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_11, this, baseLoaderCallback); Log.i(MY_TAG, "onResume Act 2 done resuming"); }
@Override protected void onPause() { super.onPause(); Log.i(MY_TAG, "onPause Act 2");
}
@Override public void onCameraViewStarted(int width, int height) {
}
@Override public void onCameraViewStopped() {
}
@Override public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) { return inputFrame.rgba(); }
@Override protected void onDestroy() { super.onDestroy(); if(javaCameraView != null) { javaCameraView.disableView(); } }
AndroidManifest.xml
<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"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".GameActivity"
android:label="@string/title_activity_game"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="com.roundcube.gamewithserver.GameActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
On using Logs i figured out that problem in this function call `OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_11, this, baseLoaderCallback);
Please help me find a solution to this thank you.