Skip to content

Commit 21f12fe

Browse files
author
DESKTOP-VKH38G4\BZHMedia
committed
Update example with zoom picker
1 parent 4afdb35 commit 21f12fe

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

android/libraries/opencv/src/org/opencv/android/JavaCameraView.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,12 @@ protected boolean initializeCamera(int width, int height) {
179179
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
180180
}
181181

182+
// Set Zoom
183+
params.setZoom(zoom);
184+
182185
mCamera.setParameters(params);
183186
params = mCamera.getParameters();
184187

185-
// Set Zoom
186-
params.setZoom(zoom);
187188

188189
mFrameWidth = params.getPreviewSize().width;
189190
mFrameHeight = params.getPreviewSize().height;

example/App.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ const qualityOptions = [
161161
{ label: 'High', value: CaptureQuality.high },
162162
]
163163

164+
const zoomOptions = [
165+
{ label: '0%', value: 0 },
166+
{ label: '25%', value: 24 },
167+
{ label: '50%', value: 49 },
168+
{ label: '75%', value: 74 },
169+
{ label: '100%', value: 99 },
170+
]
171+
164172
const countryOptions = [
165173
{ label: 'eu', value: 'eu' },
166174
{ label: 'us', value: 'us' },
@@ -179,12 +187,13 @@ export default class App extends Component {
179187
},
180188
captureQuality: CaptureQuality.medium,
181189
aspect: CaptureQuality.stretch,
190+
zoom: 0,
182191
rotateMode: false,
183192
torchMode: false,
184193
showPlateOutline: true,
185194
plateOutlineColor: '#ff0000',
186195
country: 'eu',
187-
touchToFocus: true,
196+
touchToFocus: false,
188197
}
189198

190199
async componentDidMount() {
@@ -276,6 +285,7 @@ export default class App extends Component {
276285
showPlateOutline,
277286
captureQuality,
278287
aspect,
288+
zoom,
279289
rotateMode,
280290
torchMode,
281291
country,
@@ -291,12 +301,13 @@ export default class App extends Component {
291301
style={styles.camera}
292302
aspect={aspect}
293303
captureQuality={captureQuality}
304+
zoom={zoom}
294305
country={country}
295306
onPlateRecognized={this.onPlateRecognized}
296307
plateOutlineColor={plateOutlineColor}
297308
showPlateOutline={showPlateOutline}
298309
torchMode={this.state.torchMode ? TorchMode.on : TorchMode.off}
299-
// rotateMode={this.state.rotateMode ? RotateMode.on : RotateMode.off}
310+
rotateMode={this.state.rotateMode ? RotateMode.on : RotateMode.off}
300311
touchToFocus={touchToFocus}
301312
/>
302313
)}
@@ -352,6 +363,12 @@ export default class App extends Component {
352363
}
353364
values={colorOptions}
354365
/>
366+
<MyPicker
367+
title="Zoom"
368+
selectedValue={zoom}
369+
onValueChange={value => this.setState({ zoom: value })}
370+
values={zoomOptions}
371+
/>
355372
<MyPicker
356373
title="Quality"
357374
selectedValue={captureQuality}

0 commit comments

Comments
 (0)