forked from RobertSasak/react-native-openalpr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (49 loc) · 1.63 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { NativeModules, requireNativeComponent } from 'react-native'
const { ALPRCameraManager } = NativeModules
const ALPRCamera = requireNativeComponent('ALPRCamera', Camera, {
nativeOnly: {
rotateMode: true,
mounted: true,
},
})
class Camera extends Component {
onPlateRecognized = ({ nativeEvent }) =>
this.props.onPlateRecognized(nativeEvent)
render() {
return (
<ALPRCamera {...this.props} onPlateRecognized={this.onPlateRecognized} />
)
}
}
Camera.propTypes = {
aspect: PropTypes.number,
captureQuality: PropTypes.number,
country: PropTypes.string,
onPlateRecognized: PropTypes.func,
plateOutlineColor: PropTypes.string,
showPlateOutline: PropTypes.bool,
torchMode: PropTypes.PropTypes.number,
touchToFocus: PropTypes.bool,
}
Camera.defaultProps = {
aspect: ALPRCameraManager.Aspect.fill,
captureQuality: ALPRCameraManager.CaptureQuality.medium,
country: 'us',
plateOutlineColor: '#0028ff',
showPlateOutline: true,
torchMode: ALPRCameraManager.TorchMode.off,
touchToFocus: true,
onPlateRecognized: () => {},
}
export default Camera
export const Aspect = ALPRCameraManager.Aspect
export const CaptureQuality = ALPRCameraManager.CaptureQuality
export const TorchMode = ALPRCameraManager.TorchMode
export const RotateMode = ALPRCameraManager.RotateMode
// Take a picture of what is currently seen by the user.
// Possible options: width (int), height (int) and quality (float).
// @return a Promise<String:uri>.
// @warn Currently only works on iOS.
export const takePicture = ALPRCameraManager.takePicture