{"id":26497544,"url":"https://github.com/duanhong169/camera","last_synced_at":"2025-03-20T13:43:11.194Z","repository":{"id":145190807,"uuid":"139418037","full_name":"duanhong169/Camera","owner":"duanhong169","description":"📸 Use Android camera to take pictures and videos, based on `camera2` api.","archived":false,"fork":false,"pushed_at":"2018-09-18T12:08:00.000Z","size":464,"stargazers_count":131,"open_issues_count":15,"forks_count":45,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-12-05T06:34:10.220Z","etag":null,"topics":["android-camera","android-camera-preview","android-camera-view","android-camera2","android-library","android-video-recorder"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/duanhong169.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-07-02T09:03:28.000Z","updated_at":"2024-11-07T02:25:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"e567b80f-847d-44c0-a8f8-ebd9e4f8e798","html_url":"https://github.com/duanhong169/Camera","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duanhong169%2FCamera","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duanhong169%2FCamera/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duanhong169%2FCamera/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duanhong169%2FCamera/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duanhong169","download_url":"https://codeload.github.com/duanhong169/Camera/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244620357,"owners_count":20482598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-camera","android-camera-preview","android-camera-view","android-camera2","android-library","android-video-recorder"],"created_at":"2025-03-20T13:43:09.768Z","updated_at":"2025-03-20T13:43:11.186Z","avatar_url":"https://github.com/duanhong169.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Camera [![gitHub release](https://img.shields.io/github/release/duanhong169/Camera.svg?style=social)](https://github.com/duanhong169/Camera/releases) [![platform](https://img.shields.io/badge/platform-android-brightgreen.svg)](https://developer.android.com/index.html) \u003ca target=\"_blank\" href=\"https://android-arsenal.com/api?level=21\"\u003e\u003cimg src=\"https://img.shields.io/badge/API-21%2B-brightgreen.svg?style=flat\"\u003e\u003c/a\u003e [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Camera-green.svg?style=flat)](https://android-arsenal.com/details/1/7018) [![license](https://img.shields.io/badge/license-Apache%202-green.svg)](https://github.com/duanhong169/Camera/blob/master/LICENSE) [![Build status](https://build.appcenter.ms/v0.1/apps/09612c7d-00b4-4b16-86b5-054c45d749f8/branches/master/badge)](https://appcenter.ms)\n\nUse Android camera to take pictures and videos, based on [camera2](https://developer.android.com/reference/android/hardware/camera2/package-summary) api.\n\n\u003cimg src='art/screenshot1.jpg' height='500px'/\u003e \u003cimg src='art/screenshot2.jpg' height='500px'/\u003e\n\n## Features\n\n* Auto filled `CameraView` for previewing\n* Support both image capture \u0026 video record\n* Configurable audio/video size and aspect ratio, auto focus, tap to focus, flash control, pinch to zoom, etc.\n\n## Gradle\n\n```\ndependencies {\n    implementation 'com.github.duanhong169:camera:${latestVersion}'\n    ...\n}\n```\n\n\u003e Replace `${latestVersion}` with the latest version code. See [releases](https://github.com/duanhong169/Camera/releases).\n\n## Usage\n\n* Add `CameraView` into your layout xml:\n\n```xml\n\u003ctop.defaults.camera.CameraView\n    android:id=\"@+id/preview\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:layout_centerInParent=\"true\"\n    app:mode=\"video\"\n    app:aspectRatio=\"4:3\"\n    app:autoFocus=\"true\"\n    app:facing=\"back\"\n    app:fillSpace=\"false\"\n    app:flash=\"auto\"\n    app:pinchToZoom=\"false\"\n    app:showFocusIndicator=\"true\"/\u003e\n```\n\n\u003e See [`top_defaults_camera_attrs.xml`](./camera/src/main/res/values/top_defaults_camera_attrs.xml) for all supported attributes.\n\n* Create a `Photographer` with the `CameraView`:\n\n```java\n@Override\nprotected void onCreate(@Nullable Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    \n    // ...\n\n    CameraView preview = findViewById(R.id.preview);\n    photographer = PhotographerFactory.createPhotographerWithCamera2(this, preview);\n    \n    // ...\n}\n```\n\n* Implement and set `Photographer.OnEventListener` to receive events from the camera:\n\n```java\n    photographer.setOnEventListener(new SimpleOnEventListener() {\n        @Override\n        public void onDeviceConfigured() {}\n\n        @Override\n        public void onPreviewStarted() {}\n\n        @Override\n        public void onZoomChanged(float zoom) {}\n\n        @Override\n        public void onPreviewStopped() {}\n\n        @Override\n        public void onStartRecording() {}\n\n        @Override\n        public void onFinishRecording(String filePath) {}\n\n        @Override\n        public void onShotFinished(String filePath) {}\n\n        @Override\n        public void onError(Error error) {}\n    });\n```\n\n* Start/stop preview in `onResume()`/`onPause()`:\n\n```java\n    @Override\n    protected void onResume() {\n        super.onResume();\n        photographer.startPreview();\n    }\n\n    @Override\n    protected void onPause() {\n        photographer.stopPreview();\n        super.onPause();\n    }\n```\n\n* `PhotographerHelper` is your friend:\n\n```java\nphotographerHelper = new PhotographerHelper(photographer); // init with photographer\nphotographerHelper.setFileDir(Commons.MEDIA_DIR); // set directory for image/video saving\nphotographerHelper.flip(); // flip back/front camera\nphotographerHelper.switchMode(); // switch between image capture/video record\n```\n\nSee a complete usage in the app sample code.\n\n## Credits\n\n* [google/cameraview](https://github.com/google/cameraview)\n* [googlesamples/android-Camera2Basic](https://github.com/googlesamples/android-Camera2Basic)\n* [googlesamples/android-Camera2Video](https://github.com/googlesamples/android-Camera2Video)\n\n## License\n\nSee the [LICENSE](./LICENSE) file.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduanhong169%2Fcamera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduanhong169%2Fcamera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduanhong169%2Fcamera/lists"}