mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge pull request #24692 from savuor:doc_android_tutorial_camera
Android camera tutorial update #24692 This PR extends the OpenCV 4 Android tutorial by a simple camera app based on existing code. This part was accidentally removed during the #24653 preparation, this PR restores it and aligns it to the latest Android Studio. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
committed by
GitHub
parent
850be1e087
commit
42ab298f01
@@ -27,11 +27,13 @@
|
||||
android:largeScreens="true"
|
||||
android:anyDensity="true" />
|
||||
|
||||
//! [camera_permissions]
|
||||
<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"/>
|
||||
//! [camera_permissions]
|
||||
|
||||
</manifest>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<!-- [camera_view] -->
|
||||
<org.opencv.android.JavaCameraView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
@@ -11,5 +12,6 @@
|
||||
android:id="@+id/tutorial1_activity_java_surface_view"
|
||||
opencv:show_fps="true"
|
||||
opencv:camera_id="any" />
|
||||
<!-- [camera_view] -->
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
+6
-3
@@ -9,7 +9,6 @@ import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
@@ -21,8 +20,6 @@ public class Tutorial1Activity extends CameraActivity implements CvCameraViewLis
|
||||
private static final String TAG = "OCVSample::Activity";
|
||||
|
||||
private CameraBridgeViewBase mOpenCvCameraView;
|
||||
private boolean mIsJavaCamera = true;
|
||||
private MenuItem mItemSwitchCamera = null;
|
||||
|
||||
public Tutorial1Activity() {
|
||||
Log.i(TAG, "Instantiated new " + this.getClass());
|
||||
@@ -44,7 +41,9 @@ public class Tutorial1Activity extends CameraActivity implements CvCameraViewLis
|
||||
}
|
||||
//! [ocv_loader_init]
|
||||
|
||||
//! [keep_screen]
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
//! [keep_screen]
|
||||
|
||||
setContentView(R.layout.tutorial1_surface_view);
|
||||
|
||||
@@ -76,18 +75,22 @@ public class Tutorial1Activity extends CameraActivity implements CvCameraViewLis
|
||||
return Collections.singletonList(mOpenCvCameraView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mOpenCvCameraView != null)
|
||||
mOpenCvCameraView.disableView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraViewStarted(int width, int height) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraViewStopped() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
|
||||
return inputFrame.rgba();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user