vision-camera-mrz-scanner
Version:
VisionCamera Frame Processor Plugin to detect and read MRZ data from passports using MLKit Text Recognition.
27 lines (23 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.sortFormatsByResolution = void 0;
/**
* Sort formats by resolution, with higher resolution being better.
* @param {CameraDeviceFormat} left - CameraDeviceFormat - the first format to compare
* @param {CameraDeviceFormat} right - CameraDeviceFormat - the right side of the comparison
* @returns The difference between the two points.
*/
const sortFormatsByResolution = (left, right) => {
// in this case, points aren't "normalized" (e.g. higher resolution = 1 point, lower resolution = -1 points)
let leftPoints = left.photoHeight * left.photoWidth;
let rightPoints = right.photoHeight * right.photoWidth;
// we also care about video dimensions, not only photo.
leftPoints += left.videoWidth * left.videoHeight;
rightPoints += right.videoWidth * right.videoHeight;
// you can also add points for FPS, etc
return rightPoints - leftPoints;
};
exports.sortFormatsByResolution = sortFormatsByResolution;
//# sourceMappingURL=generalUtil.js.map