Apache License 2.0

项目介绍

duanhong169/Camera 是一个托管在 GitHub 上的开源项目,主要使用 Java 编写,采用 Apache License 2.0 许可证,目前获得 139 个 Star、45 次 Fork。

仓库全名
duanhong169/Camera
开源许可证
Apache License 2.0
Star 数
139
Fork 数
45
未关闭 Issue
17

README 摘要

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, pinch to zoom, etc. Gradle Replace ${latestVersion} with the latest version code. See releases. Usage Add CameraView into your layout xml: See topdefaultscameraattrs.xml…

完整内容见 GitHub 原始 README 或本页 。

常见问题

Camera 用什么语言开发?

主要使用 Java 编写,采用 Apache License 2.0 许可证,目前有 139 个 Star。

Camera 可以免费商用吗?

仓库采用 Apache License 2.0 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 Camera 的源码?

可以直接克隆仓库:git clone https://github.com/duanhong169/Camera.git,默认分支为 master;安装与运行步骤见仓库 README。

Camera 最近还在维护吗?

仓库最近一次更新为 2018年9月18日,当前有 17 个未关闭 Issue;Star 数为 139,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

📸 Use Android camera to take pictures and videos, based on `camera2` api.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
235
价值分
96
活跃状态
活跃

语言占比

Java

Release

贡献者

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, pinch to zoom, 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:pinchToZoom="false"
    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 SimpleOnEventListener() {
        @Override
        public void onDeviceConfigured() {}

        @Override
        public void onPreviewStarted() {}

        @Override
        public void onZoomChanged(float zoom) {}

        @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.

评论

暂无评论