{"id":23086670,"url":"https://github.com/evangunawan/cap-usb-camera","last_synced_at":"2025-08-16T05:32:01.709Z","repository":{"id":57135855,"uuid":"371579986","full_name":"evangunawan/cap-usb-camera","owner":"evangunawan","description":"External USB Camera support for android capacitor projects.","archived":false,"fork":false,"pushed_at":"2021-06-08T07:20:57.000Z","size":768,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-15T22:26:42.961Z","etag":null,"topics":["capacitor","capacitor-plugin","ionic"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evangunawan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-28T04:32:42.000Z","updated_at":"2023-06-15T02:43:53.000Z","dependencies_parsed_at":"2022-09-04T10:00:23.024Z","dependency_job_id":null,"html_url":"https://github.com/evangunawan/cap-usb-camera","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evangunawan%2Fcap-usb-camera","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evangunawan%2Fcap-usb-camera/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evangunawan%2Fcap-usb-camera/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evangunawan%2Fcap-usb-camera/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evangunawan","download_url":"https://codeload.github.com/evangunawan/cap-usb-camera/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229885865,"owners_count":18139383,"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":["capacitor","capacitor-plugin","ionic"],"created_at":"2024-12-16T19:29:28.285Z","updated_at":"2024-12-16T19:29:28.933Z","avatar_url":"https://github.com/evangunawan.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @periksa/cap-usb-camera\n\nUVC Cameras support for capacitor apps connected via device's USB.\nBased on [UVCCamera](https://github.com/saki4510t/UVCCamera) library,\nusing [Metuuu's](https://github.com/Metuuu/UVCCamera) forked repository to support Android SDK 30.\n\nThis plugin enable web apps to take picture or access your UVC external camera (e.g. webcams).\nThe plugin provides a native activity to access and opens stream from external camera,\nwhich you can capture, fetch photo, and get the data from the plugin call\n(it works similarly with [@capacitor/camera](https://capacitorjs.com/docs/apis/camera) plugin).\nIt supports the functionality to save the image to your media storage too.\n\nCurrently supports only Android platform, and not tested on many devices.\n\n### Tested Devices\n\nTested and developed on an Android 11 Samsung Galaxy A51.\n\nPlease report or open an issue if your device is bugged or crashed using the plugin.\n\n## Install\n\n```bash\nnpm install @periksa/cap-usb-camera\nnpx cap sync\n```\n\nModify your `build.gradle` (top-level project scope),\nusually on `/android/build.gradle` path if you are developing ionic-capacitor project.\n\nAdd new maven repository line to your `allprojects` -\u003e `repositories` body.\n\n```gradle\nallprojects {\n  repositories {\n      google()\n      jcenter()\n      // Add This Line\n      maven { url 'https://raw.github.com/saki4510t/libcommon/master/repository/' }\n  }\n}\n```\nThen sync your gradle project by pressing \"Sync Now\" on the top after you modify the file.\n\n## Usage\n\nHere is some example to use the plugin inside your web app.\n\nExample code is written in Angular platform.\n\n```typescript\nimport { UsbCamera } from '@periksa/cap-usb-camera';\n\n// ...\n\nprivate async fetchExternalCameraPhoto(): Promise\u003cvoid\u003e {\n  const photoResult = await UsbCamera.getPhoto({ saveToStorage: false });\n  if (photoResult.status_code === 0) {\n    if (photoResult.exit_code === 'exit_no_device') {\n      // Handle show alert/notice when there is no device attached.\n    }\n    return;\n  }\n  if (photoResult.data) {\n    const photoSrc = photoResult.data.dataURL; //Base64 enconded image.\n    // Handle the base64 encoded image.\n    // e.g. put it on \u003cimg src=\"\"\u003e tag.\n  }\n}\n\n```\n\n`status_code` is retrieved from Android's Activity `RESULT_CODE`,we use these 2 values:\n- `-1`: OK, image fetched successfully. Will be accompanied by `success` exit_code.\n- `0`: CANCELED, canceled by user, or plugin can't access camera.\n\n\nThen you can have the exit reason inside `exit_code`. Available values are:\n- `user_canceled` - User clicked *cancel* button or declined camera access permission on the plugin activity.\n- `exit_no_device` - Plugin won't start the activity when there is no device connected.\n- `device_disconnected` - Device is disconnected on plugin activity.\n- `success` - Exit code if the plugin succeed to take the photo.\n\n\n## API\n\n\u003cdocgen-index\u003e\n\n* [`getPhoto(...)`](#getphoto)\n* [Interfaces](#interfaces)\n\n\u003c/docgen-index\u003e\n\n\u003cdocgen-api\u003e\n\u003c!--Update the source file JSDoc comments and rerun docgen to update the docs below--\u003e\n\n### getPhoto(...)\n\n```typescript\ngetPhoto(config?: UsbCameraPhotoOptions) =\u003e any\n```\n\nOpen native activity and get photo from usb camera device attached to the phone.\nIf there is no usb device connected, will return canceled exit code.\n\n| Param        | Type                                                                    |\n| ------------ | ----------------------------------------------------------------------- |\n| **`config`** | \u003ccode\u003e\u003ca href=\"#usbcameraphotooptions\"\u003eUsbCameraPhotoOptions\u003c/a\u003e\u003c/code\u003e |\n\n**Returns:** \u003ccode\u003eany\u003c/code\u003e\n\n--------------------\n\n\n### Interfaces\n\n\n#### UsbCameraPhotoOptions\n\n| Prop                | Type                 | Description                                        |\n| ------------------- | -------------------- | -------------------------------------------------- |\n| **`saveToStorage`** | \u003ccode\u003eboolean\u003c/code\u003e | Let app save captured photo to the device storage. |\n\n\n#### UsbCameraResult\n\n| Prop                | Type                                                 | Description                                                                                    |\n| ------------------- | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------- |\n| **`status_code`**   | \u003ccode\u003enumber\u003c/code\u003e                                  | Status Code from Intent ResultCode.                                                            |\n| **`status_code_s`** | \u003ccode\u003estring\u003c/code\u003e                                  | Description string of the status code number.                                                  |\n| **`exit_code`**     | \u003ccode\u003estring\u003c/code\u003e                                  | Description of exit or cancel reason.                                                          |\n| **`data`**          | \u003ccode\u003e{ dataURL?: string; fileURI?: string; }\u003c/code\u003e | Result data payload, contains image in base64 DataURL, and Android filesystem URI to the file. |\n\n\u003c/docgen-api\u003e\n\n## Contributing\n\nAny contribution is very much appreciated, just clone the project and post a pull request!\nThank you very much!\n\n### Unimplemented and future functionalities\n\n- Activity not yet supports image manipulation, such as brightness, contrast and mirroring.\nHowever the library supports this.\n- Still have bugs with device connectivity.\n- Activity user interface is somehow very simple, and not tested on more screen dimensions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevangunawan%2Fcap-usb-camera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevangunawan%2Fcap-usb-camera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevangunawan%2Fcap-usb-camera/lists"}