@yoonit/nativescript-camera
Advanced tools
Comparing version 1.7.0 to 1.8.0
{ | ||
"name": "@yoonit/nativescript-camera", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "Yoonit Camera have a custom view that shows a preview layer of the front/back camera and detects human faces in it and read qr code.", | ||
@@ -5,0 +5,0 @@ "main": "Yoonit.Camera", |
@@ -18,3 +18,3 @@ [<img src="https://raw.githubusercontent.com/Yoonit-Labs/nativescript-yoonit-camera/development/logo_cyberlabs.png" width="300">](https://cyberlabs.ai/) | ||
- Frame capture | ||
- Face ROI (Soon) | ||
- Face ROI | ||
- QR Code scanning | ||
@@ -32,3 +32,2 @@ | ||
#### VueJS Plugin | ||
@@ -145,21 +144,24 @@ `main.js` | ||
| Function | Parameters | Valid values | Return Type | Description | ||
| - | - | - | - | - | ||
| **`requestPermission`** | - | - | promise | Ask to user to give the permission to access camera. | ||
| **`hasPermission`** | - | - | boolean | Return if application has camera permission. | ||
| **`preview`** | - | - | void | Start camera preview if has permission. | ||
| **`startCapture`** | `captureType: string` | <ul><li>`"none"`</li><li>`"face"`</li><li>`"barcode"`</li><li>`"frame"`</li></ul> | void | Set capture type none, face, barcode or frame. | ||
| **`stopCapture`** | - | - | void | Stop any type of capture. | ||
| **`toggleLens`** | - | - | void | Set camera lens facing front or back. | ||
| **`getLens`** | - | - | number | Return `number` that represents lens face state: 0 for front 1 for back camera. | ||
| **`setFaceNumberOfImages`** | `faceNumberOfImages: number` | Any positive `number` value | void | Default value is 0. For value 0 is saved infinity images. When saved images reached the "face number os images", the `onEndCapture` is triggered. | ||
| **`setFaceDetectionBox`** | `faceDetectionBox: boolean` | `true` or `false` | void | Set to show face detection box when face detected. | ||
| **`setFaceTimeBetweenImages`** | `faceTimeBetweenImages: number` | Any positive `number` that represent time in milli seconds | void | Set saving face images time interval in milli seconds. | ||
| **`setFacePaddingPercent`** | `facePaddingPercent: number` | Any positive `number` value | void | Set face image and bounding box padding in percent. | ||
| **`setFaceImageSize`** | `faceImageSize: number` | Any positive `number` value | void | Set face image size to be saved. | ||
| **`setFaceCaptureMinSize`** | `faceCaptureMinSize: Float` | Value between `0` and `1`. Represents the percentage. | void | Set the minimum face capture related by percentage with the screen width. | ||
| **`setFaceCaptureMaxSize`** | `faceCaptureMaxSize: Float` | Value between `0` and `1`. Represents the percentage. | void | Set the maximum face capture related by percentage with the screen width. | ||
| **`setFrameNumberOfImages`** | `frameNumberOfImages: number` | Any positive `number` value | void | Default value is 0. For value 0 is saved infinity images. When saved images reached the "frame number os images", the `onEndCapture` is triggered. | ||
| **`setFrameTimeBetweenImages`** | `frameTimeBetweenImages: number` | Any positive `number` that represent time in milli seconds | void | Set saving frame images time interval in milli seconds. | ||
| **`setFaceSaveImages`** | `faceSaveImages: Boolean` | `true` or `false` | void | Set to enable/disable face save images when capturing faces. | ||
| Function | Parameters | Valid values | Return Type | Description | ||
| - | - | - | - | - | ||
| **`requestPermission`** | - | - | promise | Ask to user to give the permission to access camera. | ||
| **`hasPermission`** | - | - | boolean | Return if application has camera permission. | ||
| **`preview`** | - | - | void | Start camera preview if has permission. | ||
| **`startCapture`** | `captureType: string` | <ul><li>`"none"`</li><li>`"face"`</li><li>`"barcode"`</li><li>`"frame"`</li></ul> | void | Set capture type none, face, barcode or frame. | ||
| **`stopCapture`** | - | - | void | Stop any type of capture. | ||
| **`toggleLens`** | - | - | void | Set camera lens facing front or back. | ||
| **`getLens`** | - | - | number | Return `number` that represents lens face state: 0 for front 1 for back camera. | ||
| **`setFaceNumberOfImages`** | `faceNumberOfImages: number` | Any positive `number` value | void | Default value is 0. For value 0 is saved infinity images. When saved images reached the "face number os images", the `onEndCapture` is triggered. | ||
| **`setFaceDetectionBox`** | `faceDetectionBox: boolean` | `true` or `false` | void | Set to show face detection box when face detected. | ||
| **`setFaceTimeBetweenImages`** | `faceTimeBetweenImages: number` | Any positive `number` that represent time in milli seconds | void | Set saving face images time interval in milli seconds. | ||
| **`setFacePaddingPercent`** | `facePaddingPercent: number` | Any positive `number` value | void | Set face image and bounding box padding in percent. | ||
| **`setFaceImageSize`** | `faceImageSize: number` | Any positive `number` value | void | Set face image size to be saved. | ||
| **`setFaceCaptureMinSize`** | `faceCaptureMinSize: number` | Value between `0` and `1`. Represents the percentage. | void | Set the minimum face capture related by percentage with the screen width. | ||
| **`setFaceCaptureMaxSize`** | `faceCaptureMaxSize: number` | Value between `0` and `1`. Represents the percentage. | void | Set the maximum face capture related by percentage with the screen width. | ||
| **`setFrameNumberOfImages`** | `frameNumberOfImages: number` | Any positive `number` value | void | Default value is 0. For value 0 is saved infinity images. When saved images reached the "frame number os images", the `onEndCapture` is triggered. | ||
| **`setFrameTimeBetweenImages`** | `frameTimeBetweenImages: number` | Any positive `number` that represent time in milli seconds | void | Set saving frame images time interval in milli seconds. | ||
| **`setFaceSaveImages`** | `faceSaveImages: boolean` | `true` or `false` | void | Set to enable/disable face save images when capturing faces. | ||
| **`setFaceROIEnable`** | `faceROIEnable: boolean` | `true` or `false` | void | Enable/disable face region of interest capture. | ||
| **`setFaceROIOffset`** | `topOffset: number, rightOffset: number,bottomOffset: number, leftOffset: number` | Values between `0` and `1`. Represents the percentage. | void | <ul><li>topOffset: "Above" the face detected.</li><li>rightOffset: "Right" of the face detected.</li><li>bottomOffset: "Bottom" of the face detected.</li><li>leftOffset: "Left" of the face detected.</li></ul> | ||
| **`setFaceROIMinSize`** | `minimumSize: number` | Values between `0` and `1`. Represents the percentage. | void | Set the minimum face size related with the region of interest. | ||
@@ -178,3 +180,2 @@ #### Events | ||
### KeyError | ||
@@ -196,13 +197,16 @@ | ||
| INVALID_FRAME_TIME_BETWEEN_IMAGES | Tried to input invalid frame time interval to capture face. | ||
| INVALID_FACE_ROI_OFFSET | Tried to input invalid face region of interest offset. | ||
| INVALID_FACE_ROI_MIN_SIZE | Tried to input invalid face region of interest minimum size. | ||
### Message | ||
Pre-define message constants used by the `onMessage`event. | ||
Pre-define message constants used by the `onMessage` event. | ||
| Message | Description | ||
| - | - | ||
| INVALID_CAPTURE_FACE_MIN_SIZE | Face bounding box width percentage in relation of the screen width is less than the setted (`setFaceCaptureMinSize`). | ||
| INVALID_CAPTURE_FACE_MAX_SIZE | Face bounding box width percentage in relation of the screen width is more than the setted (`setFaceCaptureMaxSize`). | ||
| Message | Description | ||
| - | - | ||
| INVALID_CAPTURE_FACE_MIN_SIZE | Face width percentage in relation of the screen width is less than the setted (`setFaceCaptureMinSize`). | ||
| INVALID_CAPTURE_FACE_MAX_SIZE | Face width percentage in relation of the screen width is more than the setted (`setFaceCaptureMaxSize`). | ||
| INVALID_CAPTURE_FACE_OUT_OF_ROI | Face bounding box is out of the setted region of interest (`setFaceROIOffset`). | ||
| INVALID_CAPTURE_FACE_ROI_MIN_SIZE | Face width percentage in relation of the screen width is less than the setted (`setFaceROIMinSize`). | ||
## To contribute and make it better | ||
@@ -209,0 +213,0 @@ |
14
vue.js
@@ -49,4 +49,7 @@ // +-+-+-+-+-+-+ | ||
nativeView, | ||
requestPermission, | ||
hasPermission, | ||
preview, | ||
stopCapture, | ||
setLens, | ||
toggleLens, | ||
@@ -65,4 +68,5 @@ getLens, | ||
setFrameTimeBetweenImages, | ||
requestPermission, | ||
hasPermission | ||
setFaceROIEnable, | ||
setFaceROIOffset, | ||
setFaceROIMinSize, | ||
} = element.nativeView | ||
@@ -79,2 +83,3 @@ | ||
stopCapture, | ||
setLens, | ||
toggleLens, | ||
@@ -91,3 +96,6 @@ getLens, | ||
setFrameNumberOfImages, | ||
setFrameTimeBetweenImages | ||
setFrameTimeBetweenImages, | ||
setFaceROIEnable, | ||
setFaceROIOffset, | ||
setFaceROIMinSize, | ||
} | ||
@@ -94,0 +102,0 @@ |
@@ -20,2 +20,11 @@ import { CameraBase } from './Yoonit.Camera.common'; | ||
} | ||
requestPermission(explanation = '') { | ||
return new Promise((resolve, reject) => permissions | ||
.requestPermission(CAMERA(), explanation) | ||
.then(() => resolve(true)) | ||
.catch(err => reject(false))); | ||
} | ||
hasPermission() { | ||
return permissions.hasPermission(CAMERA()); | ||
} | ||
startCapture(captureType) { | ||
@@ -54,11 +63,11 @@ this.nativeView.startCaptureType(captureType); | ||
} | ||
requestPermission(explanation = '') { | ||
return new Promise((resolve, reject) => permissions | ||
.requestPermission(CAMERA(), explanation) | ||
.then(() => resolve(true)) | ||
.catch(err => reject(false))); | ||
setFaceROIEnable(faceROIEnable) { | ||
this.nativeView.setFaceROIEnable(faceROIEnable); | ||
} | ||
hasPermission() { | ||
return permissions.hasPermission(CAMERA()); | ||
setFaceROIOffset(topOffset, rightOffset, bottomOffset, leftOffset) { | ||
this.nativeView.setFaceROIOffset(topOffset, rightOffset, bottomOffset, leftOffset); | ||
} | ||
setFaceROIMinSize(minimumSize) { | ||
this.nativeView.setFaceROIMinSize(minimumSize); | ||
} | ||
} | ||
@@ -65,0 +74,0 @@ var CameraEventListener = /** @class */ (function (_super) { |
import { ContentView } from '@nativescript/core'; | ||
export class CameraBase extends ContentView { | ||
requestPermission(explanationText) { | ||
return new Promise((resolve, reject) => resolve()); | ||
} | ||
hasPermission() { return false; } | ||
preview() { | ||
@@ -9,2 +13,5 @@ this.nativeView.startPreview(); | ||
} | ||
setLens(lens) { | ||
this.getLens() !== lens && this.toggleLens(); | ||
} | ||
toggleLens() { | ||
@@ -27,7 +34,6 @@ this.nativeView.toggleCameraLens(); | ||
setFrameTimeBetweenImages(frameTimeBetweenImages) { } | ||
requestPermission(explanationText) { | ||
return new Promise((resolve, reject) => resolve()); | ||
} | ||
hasPermission() { return false; } | ||
setFaceROIEnable(faceROIEnable) { } | ||
setFaceROIOffset(topOffset, rightOffset, bottomOffset, leftOffset) { } | ||
setFaceROIMinSize(minimumSize) { } | ||
} | ||
//# sourceMappingURL=Yoonit.Camera.common.js.map |
@@ -23,2 +23,36 @@ import { CameraBase } from './Yoonit.Camera.common'; | ||
} | ||
requestPermission(explanation = '') { | ||
return new Promise((resolve, reject) => { | ||
const cameraStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo); | ||
switch (cameraStatus) { | ||
case 0: { | ||
AVCaptureDevice.requestAccessForMediaTypeCompletionHandler(AVMediaTypeVideo, (granted) => { | ||
if (granted) { | ||
this.permission = true; | ||
resolve(true); | ||
} | ||
else { | ||
this.permission = false; | ||
reject(false); | ||
} | ||
}); | ||
break; | ||
} | ||
case 1: | ||
case 2: { | ||
this.permission = false; | ||
reject(false); | ||
break; | ||
} | ||
case 3: { | ||
this.permission = true; | ||
resolve(true); | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
hasPermission() { | ||
return this.permission; | ||
} | ||
startCapture(captureType) { | ||
@@ -57,36 +91,11 @@ this.nativeView.startCaptureTypeWithCaptureType(captureType); | ||
} | ||
requestPermission(explanation = '') { | ||
return new Promise((resolve, reject) => { | ||
const cameraStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo); | ||
switch (cameraStatus) { | ||
case 0: { | ||
AVCaptureDevice.requestAccessForMediaTypeCompletionHandler(AVMediaTypeVideo, (granted) => { | ||
if (granted) { | ||
this.permission = true; | ||
resolve(true); | ||
} | ||
else { | ||
this.permission = false; | ||
reject(false); | ||
} | ||
}); | ||
break; | ||
} | ||
case 1: | ||
case 2: { | ||
this.permission = false; | ||
reject(false); | ||
break; | ||
} | ||
case 3: { | ||
this.permission = true; | ||
resolve(true); | ||
break; | ||
} | ||
} | ||
}); | ||
setFaceROIEnable(faceROIEnable) { | ||
this.nativeView.setFaceROIEnableWithFaceROIEnable(faceROIEnable); | ||
} | ||
hasPermission() { | ||
return this.permission; | ||
setFaceROIOffset(topOffset, rightOffset, bottomOffset, leftOffset) { | ||
this.nativeView.setFaceROIOffsetWithTopOffsetRightOffsetBottomOffsetLeftOffset(topOffset, rightOffset, bottomOffset, leftOffset); | ||
} | ||
setFaceROIMinSize(minimumSize) { | ||
this.nativeView.setFaceROIMinSizeWithMinimumSize(minimumSize); | ||
} | ||
} | ||
@@ -93,0 +102,0 @@ var CameraEventListener = /** @class */ (function (_super) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
37566
571
216