vision-camera-mrz-scanner
Version:
VisionCamera Frame Processor Plugin to detect and read MRZ data from passports using MLKit Text Recognition.
20 lines (17 loc) • 881 B
JavaScript
/**
* 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.
*/
export 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;
};
//# sourceMappingURL=generalUtil.js.map