mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-13 05:31:37 +08:00
merged master; fixed tests
This commit is contained in:
@@ -50,14 +50,19 @@ export default function createEventedElement() {
|
||||
var event = getEvent(eventName),
|
||||
subscribers = event.subscribers;
|
||||
|
||||
// Publish one-time subscriptions
|
||||
subscribers.filter(function(subscriber) {
|
||||
return !!subscriber.once;
|
||||
}).forEach((subscriber) => {
|
||||
publishSubscription(subscriber, data);
|
||||
});
|
||||
|
||||
// remove them from the subscriber
|
||||
event.subscribers = subscribers.filter(function(subscriber) {
|
||||
return !subscriber.once;
|
||||
});
|
||||
|
||||
// publish the rest
|
||||
event.subscribers.forEach((subscriber) => {
|
||||
publishSubscription(subscriber, data);
|
||||
});
|
||||
|
||||
@@ -34,11 +34,11 @@ function waitForVideo(video) {
|
||||
function initCamera(video, constraints) {
|
||||
return navigator.mediaDevices.getUserMedia(constraints)
|
||||
.then((stream) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise((resolve) => {
|
||||
streamRef = stream;
|
||||
video.setAttribute("autoplay", 'true');
|
||||
video.srcObject = stream;
|
||||
video.addEventListener('loadedmetadata', (e) => {
|
||||
video.addEventListener('loadedmetadata', () => {
|
||||
video.play();
|
||||
resolve();
|
||||
});
|
||||
@@ -51,13 +51,13 @@ function deprecatedConstraints(videoConstraints) {
|
||||
const normalized = pick(videoConstraints, ["width", "height", "facingMode",
|
||||
"aspectRatio", "deviceId"]);
|
||||
|
||||
if (typeof videoConstraints["minAspectRatio"] !== 'undefined' &&
|
||||
videoConstraints["minAspectRatio"] > 0) {
|
||||
normalized["aspectRatio"] = videoConstraints["minAspectRatio"];
|
||||
if (typeof videoConstraints.minAspectRatio !== 'undefined' &&
|
||||
videoConstraints.minAspectRatio > 0) {
|
||||
normalized.aspectRatio = videoConstraints.minAspectRatio;
|
||||
console.log("WARNING: Constraint 'minAspectRatio' is deprecated; Use 'aspectRatio' instead");
|
||||
}
|
||||
if (typeof videoConstraints["facing"] !== 'undefined') {
|
||||
normalized["facingMode"] = videoConstraints["facing"];
|
||||
if (typeof videoConstraints.facing !== 'undefined') {
|
||||
normalized.facingMode = videoConstraints.facing;
|
||||
console.log("WARNING: Constraint 'facing' is deprecated. Use 'facingMode' instead'");
|
||||
}
|
||||
return normalized;
|
||||
@@ -69,7 +69,7 @@ function applyCameraFacing(facing, constraints) {
|
||||
}
|
||||
if ( typeof MediaStreamTrack !== 'undefined' &&
|
||||
typeof MediaStreamTrack.getSources !== 'undefined') {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise((resolve) => {
|
||||
MediaStreamTrack.getSources((sourceInfos) => {
|
||||
const videoSource = sourceInfos.filter((sourceInfo) => (
|
||||
sourceInfo.kind === "video" && sourceInfo.facing === facing
|
||||
|
||||
@@ -561,7 +561,7 @@ export default function createLocator(inputImageWrapper, config) {
|
||||
boxes = findBoxes(topLabels, maxLabel);
|
||||
return boxes;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
export function checkImageConstraints(inputStream, config) {
|
||||
var patchSize,
|
||||
|
||||
@@ -7,7 +7,6 @@ import ResultCollector from './analytics/result_collector';
|
||||
import Config from './config/config';
|
||||
import {merge, pick, omitBy, isEmpty} from 'lodash';
|
||||
|
||||
|
||||
function fromImage(config, imageSrc, inputConfig = {}) {
|
||||
const staticImageConfig = {
|
||||
inputStream: {
|
||||
|
||||
Reference in New Issue
Block a user