mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-13 05:31:37 +08:00
Linked config-view to scanner
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {merge, pick} from 'lodash';
|
||||
import {merge, pick, omit} from 'lodash';
|
||||
|
||||
var streamRef;
|
||||
|
||||
@@ -64,7 +64,14 @@ function deprecatedConstraints(videoConstraints) {
|
||||
}
|
||||
|
||||
function applyCameraFacing(facing, constraints) {
|
||||
if (typeof constraints.video.deviceId !== 'undefined' || !facing){
|
||||
if (typeof constraints.video.deviceId === 'string' && constraints.video.deviceId.length > 0) {
|
||||
return Promise.resolve({
|
||||
...constraints,
|
||||
video: {
|
||||
...omit(constraints.video, "facingMode")
|
||||
}
|
||||
});
|
||||
} else if (!facing) {
|
||||
return Promise.resolve(constraints);
|
||||
}
|
||||
if ( typeof MediaStreamTrack !== 'undefined' &&
|
||||
|
||||
+9
-2
@@ -8,8 +8,7 @@ import Config from './config/config';
|
||||
import {merge} from 'lodash';
|
||||
import {createConfigFromSource} from './input/config_factory';
|
||||
|
||||
function fromSource(config, source, inputConfig = {}) {
|
||||
config = createConfigFromSource(config, inputConfig, source);
|
||||
function fromConfig(config) {
|
||||
const scanner = createScanner();
|
||||
return {
|
||||
addEventListener(eventType, cb) {
|
||||
@@ -73,6 +72,11 @@ function fromSource(config, source, inputConfig = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
function fromSource(config, source, inputConfig = {}) {
|
||||
config = createConfigFromSource(config, inputConfig, source);
|
||||
return fromConfig(config);
|
||||
}
|
||||
|
||||
const defaultScanner = createScanner();
|
||||
|
||||
function setConfig(configuration = {}, key, config = {}) {
|
||||
@@ -85,6 +89,9 @@ function createApi(configuration = Config) {
|
||||
fromSource(src, inputConfig) {
|
||||
return fromSource(configuration, src, inputConfig);
|
||||
},
|
||||
fromConfig(conf) {
|
||||
return createApi(merge({}, configuration, conf));
|
||||
},
|
||||
decoder(conf) {
|
||||
return setConfig(configuration, "decoder", conf);
|
||||
},
|
||||
|
||||
+1
-1
@@ -296,7 +296,7 @@ function createScanner() {
|
||||
|
||||
function startContinuousUpdate() {
|
||||
var next = null,
|
||||
delay = 1000 / (_config.frequency || 60);
|
||||
delay = 1000 / (_config.frequency === 0 ? 60 : (_config.frequency || 60));
|
||||
|
||||
_stopped = false;
|
||||
(function frame(timestamp) {
|
||||
|
||||
Reference in New Issue
Block a user