MCPcopy Index your code
hub / github.com/duanhong169/Camera

github.com/duanhong169/Camera @1.0.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.0.3 ↗ · + Follow
382 symbols 859 edges 38 files 26 documented · 7% updated 7y ago1.0.3 · 2018-07-11★ 14017 open issues

Browse by type

Functions 335 Types & classes 47
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Camera gitHub release platform Android Arsenal license Build status

Use android camera to take pictures and videos, based on camera2 api.

Features

  • Auto filled CameraView for previewing
  • Support both image capture & video record
  • Configurable audio/video size and aspect ratio, auto focus, tap to focus, flash control, etc.

Gradle

dependencies {
    implementation 'com.github.duanhong169:camera:${latestVersion}'
    ...
}

Replace ${latestVersion} with the latest version code. See releases.

Usage

  • Add CameraView into your layout xml:
<top.defaults.camera.CameraView
    android:id="@+id/preview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    app:mode="video"
    app:aspectRatio="4:3"
    app:autoFocus="true"
    app:facing="back"
    app:fillSpace="false"
    app:flash="auto"
    app:showFocusIndicator="true"/>

See top_defaults_camera_attrs.xml for all supported attributes.

  • Create a Photographer with the CameraView:
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // ...

    CameraView preview = findViewById(R.id.preview);
    photographer = PhotographerFactory.createPhotographerWithCamera2(this, preview);

    // ...
}
  • Implement and set Photographer.OnEventListener to receive events from the camera:
    photographer.setOnEventListener(new Photographer.OnEventListener() {
        @Override
        public void onDeviceConfigured() {}

        @Override
        public void onPreviewStarted() {}

        @Override
        public void onPreviewStopped() {}

        @Override
        public void onStartRecording() {}

        @Override
        public void onFinishRecording(String filePath) {}

        @Override
        public void onShotFinished(String filePath) {}

        @Override
        public void onError(Error error) {}
    });
  • Start/stop preview in onResume()/onPause():
    @Override
    protected void onResume() {
        super.onResume();
        photographer.startPreview();
    }

    @Override
    protected void onPause() {
        photographer.stopPreview();
        super.onPause();
    }
  • PhotographerHelper is your friend:
photographerHelper = new PhotographerHelper(photographer); // init with photographer
photographerHelper.setFileDir(Commons.MEDIA_DIR); // set directory for image/video saving
photographerHelper.flip(); // flip back/front camera
photographerHelper.switchMode(); // switch between image capture/video record

See a complete usage in the app sample code.

Credits

License

See the LICENSE file.

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Method 335
Class 34
Interface 13

Languages

Java100%

Modules by API surface

camera/src/main/java/top/defaults/camera/Camera2Photographer.java79 symbols
camera/src/main/java/top/defaults/camera/Photographer.java42 symbols
app/src/main/java/top/defaults/cameraapp/PhotographerActivity.java26 symbols
camera/src/main/java/top/defaults/camera/CameraView.java23 symbols
camera/src/main/java/top/defaults/camera/Utils.java20 symbols
camera/src/main/java/top/defaults/camera/AutoFitTextureView.java19 symbols
camera/src/main/java/top/defaults/camera/AspectRatio.java18 symbols
camera/src/main/java/top/defaults/camera/CameraViewOverlay.java12 symbols
camera/src/main/java/top/defaults/camera/CallbackHandler.java12 symbols
app/src/main/java/top/defaults/cameraapp/MainActivity.java12 symbols
camera/src/main/java/top/defaults/camera/Size.java9 symbols
camera/src/main/java/top/defaults/camera/SimpleOnEventListener.java9 symbols

For agents

$ claude mcp add Camera \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page