Skip to content

Commit 4c18a10

Browse files
committed
updated React App
1 parent a60706c commit 4c18a10

12 files changed

+131
-984
lines changed

ReactApp/package-lock.json

Lines changed: 0 additions & 938 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
9.62 KB
Binary file not shown.
-256 KB
Binary file not shown.

ReactApp/public/AcuantImageProcessingWorker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-193 KB
Binary file not shown.

ReactApp/public/AcuantJavascriptWebSdk.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ReactApp/src/rootReducer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import {configReducer} from "./screens/reducers/configReducer";
22
import {processedDataReducer} from "./screens/reducers/processedDataReducer";
33
import {idPropertiesReducer} from "./screens/reducers/idPropertiesReducer";
4+
import {capturedReducer} from "./screens/reducers/capturedReducer";
45

56
export default {
67
config: configReducer,
78
processedData: processedDataReducer,
8-
idProperties: idPropertiesReducer
9+
idProperties: idPropertiesReducer,
10+
captureProperties: capturedReducer
911
}
Lines changed: 85 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,99 @@
11
import React, { Component } from 'react';
2-
import {connect} from "react-redux";
2+
import { connect } from "react-redux";
3+
import Processing from "./Processing";
4+
import {setCaptured} from "./actions/capturedActions";
5+
import {bindActionCreators} from "redux";
36

47
class AcuantReactCamera extends Component {
5-
constructor(props){
6-
super(props);
7-
this.detectedCount = 0;
8+
constructor(props) {
9+
super(props);
10+
this.detectedCount = 0;
11+
this.state = {
12+
processing: false
813
}
9-
componentDidMount() {
10-
if(window.AcuantCameraUI){
11-
window.AcuantCameraUI.start((response) => {
12-
this.props.history.push('/photo/confirm', {
13-
blurry: response.sharpness < 50,
14-
hasGlare: response.glare < 50,
15-
cardImage: response.image.data
16-
});
17-
}, (error) => {
18-
console.log("error occured", error);
19-
});
20-
}
14+
}
15+
16+
setProcessing(value) {
17+
this.setState({
18+
processing: value
19+
})
20+
}
21+
22+
onCaptured(response) {
23+
//document captured
24+
//this is not the final result of processed image
25+
//show a loading screen until onCropped is called
26+
this.setProcessing(true);
27+
}
28+
29+
onCropped(response) {
30+
this.setProcessing(false);
31+
if (response) {
32+
//use response
33+
this.props.setCaptured(response);
34+
this.props.history.push('/photo/confirm')
2135
}
36+
else {
37+
//cropping error
38+
//restart capture
39+
this.startCamera()
40+
}
41+
}
42+
43+
onFrameAvailable(response) {
44+
45+
}
2246

23-
componentWillUnmount(){
24-
window.AcuantCameraUI.end();
47+
startCamera(){
48+
if (window.AcuantCameraUI) {
49+
if (window.AcuantCamera.isCameraSupported) {
50+
window.AcuantCameraUI.start({
51+
onCaptured: this.onCaptured.bind(this),
52+
onCropped: this.onCropped.bind(this),
53+
onFrameAvailable: this.onFrameAvailable.bind(this)
54+
}, this.onError.bind(this));
55+
}
56+
else {
57+
window.AcuantCamera.startManualCapture({
58+
onCaptured: this.onCaptured.bind(this),
59+
onCropped: this.onCropped.bind(this)
60+
}, this.onError.bind(this));
61+
}
2562
}
63+
}
2664

27-
render() {
28-
return(
65+
onError(err){
66+
window.AcuantCamera.isCameraSupported = false
67+
alert("This device does not support Live Capture. Manual Capture will be started. Please try again.")
68+
this.props.history.replace("/capture/photo")
69+
}
70+
71+
componentDidMount() {
72+
this.startCamera()
73+
}
74+
componentWillUnmount() {
75+
}
76+
77+
render() {
78+
if (this.state.processing) {
79+
return <Processing />
80+
}
81+
else {
82+
return (
2983
<div>
30-
<video id="acuant-player" controls autoPlay playsInline style={{display:'none' }}></video>
31-
<div style={{ textAlign:'center' }}>
32-
<canvas id="acuant-video-canvas" width="100%" height="auto"></canvas>
33-
</div>
84+
<video id="acuant-player" controls autoPlay playsInline style={{ display: 'none' }}></video>
85+
<div style={{ textAlign: 'center' }}>
86+
<canvas id="acuant-video-canvas" width="100%" height="auto"></canvas>
87+
</div>
3488
</div>
3589
)
3690
}
91+
92+
}
93+
}
94+
95+
function mapDispatchToProps(dispatch) {
96+
return bindActionCreators({ setCaptured }, dispatch);
3797
}
3898

39-
export default connect()(AcuantReactCamera);
99+
export default connect(null, mapDispatchToProps)(AcuantReactCamera);

ReactApp/src/screens/ProcessedImageResult.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,18 @@ class ProcessedImageResult extends Component {
1616
}
1717

1818
proceedToNextStep() {
19-
let processedData = this.props.location.state;
20-
21-
this.sendImageToAPI(this.dataURLToBlob(processedData.cardImage));
19+
this.sendImageToAPI(this.dataURLToBlob(this.props.cardImage));
2220
}
2321

2422
processClassification(classificationData) {
25-
let processedData = this.props.location.state;
26-
processedData.classificationData = classificationData;
2723
this.setProcessing(false);
2824

29-
if (processedData.classificationData && processedData.classificationData.PresentationChanged) {
25+
if (classificationData && classificationData.PresentationChanged) {
3026
this.props.setCardOrientation(0);
3127
} else {
3228
this.props.setCardOrientation(1);
3329
}
34-
if (processedData.classificationData && processedData.classificationData.Type.Size !== 3 || this.props.cardType === 2) {
30+
if (classificationData && classificationData.Type.Size !== 3 || this.props.cardType === 2) {
3531
this.props.decrementSidesLeft();
3632

3733
if (this.props.sidesLeft === 1) {
@@ -135,15 +131,13 @@ class ProcessedImageResult extends Component {
135131
}
136132

137133
renderTitleText() {
138-
let processedData = this.props.location.state;
139-
if (processedData.blurry) return "Image appears blurry. Please retry.";
140-
if (processedData.hasGlare) return "Image has glare. Please retry.";
134+
if (this.props.blurry) return "Image appears blurry. Please retry.";
135+
if (this.props.hasGlare) return "Image has glare. Please retry.";
141136
return "Ensure all texts are visible."
142137
}
143138

144139

145140
render() {
146-
let processedData = this.props.location.state;
147141
if (this.state.processing) {
148142
return <Processing />
149143
}
@@ -154,31 +148,30 @@ class ProcessedImageResult extends Component {
154148

155149
<div className='body column capture_photo'>
156150

157-
{processedData.blurry &&
151+
{this.props.blurry &&
158152

159153
<div className='column description_container'>
160154
<img alt='idscango' className='icon' src={require('../assets/images/icon_attention@2x.png')} />
161155
<p className={'description error'}>{this.renderTitleText()}</p>
162156
</div>
163-
164157
}
165158

166159
<div className='row wrapper description_container'>
167-
{!processedData.blurry && <p className={'description'}>{this.renderTitleText()}</p>}
160+
{!this.props.blurry && <p className={'description'}>{this.renderTitleText()}</p>}
168161
</div>
169162

170163
<div className="capture_group">
171164

172165
<div className='row wrapper capture_container'>
173-
{processedData.cardImage && <img alt={'idscango'} src={processedData.cardImage} className='capture'/>}
166+
{this.props.cardImage && <img alt={'idscango'} src={this.props.cardImage} className='capture'/>}
174167
</div>
175168

176169
<div className="wrapper column capture_controls">
177170

178171
<a className={'btn'} onClick={() => this.proceedToNextStep()}>
179172
<p className={'buttonBgText'}>Continue with this image</p>
180173
</a>
181-
{!processedData.orientation && <div className={'btn outline'} onClick={() => this.retryPhoto()}>
174+
{<div className={'btn outline'} onClick={() => this.retryPhoto()}>
182175
<p className={'buttonBdText'}>Retry</p>
183176
</div>}
184177

@@ -200,7 +193,10 @@ function mapStateToProps(state) {
200193
cardType: state.idProperties.cardType,
201194
sidesLeft: state.idProperties.sidesLeft,
202195
frontSubmitted: state.config.frontSubmitted,
203-
backSubmitted: state.config.backSubmitted
196+
backSubmitted: state.config.backSubmitted,
197+
cardImage: state.captureProperties.image.data,
198+
blurry: state.captureProperties.sharpness < 50,
199+
hasGlare: state.captureProperties.glare < 50
204200
};
205201
}
206202

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
export function setCaptured(payload) {
3+
return {
4+
type: "@@acuant/ADD_CAPTURED_IMAGE",
5+
data: payload
6+
7+
}
8+
}

0 commit comments

Comments
 (0)