UNPKG

mindee

Version:

Mindee Client Library for Node.js

24 lines (23 loc) 775 B
import { BaseField } from "../../../v1/parsing/standard/index.js"; /** * The clockwise rotation to apply (in degrees) to make the image upright. */ export class OrientationField extends BaseField { /** * @param {OrientationFieldConstructor} constructor Constructor parameters. */ constructor({ prediction = {}, valueKey = "value", reconstructed = false, pageId, }) { super({ prediction, valueKey, reconstructed }); const orientations = [0, 90, 180, 270]; this.pageId = pageId; this.value = parseInt(prediction[valueKey]); if (!orientations.includes(this.value)) this.value = 0; } /** * Default string representation. */ toString() { return `${this.value} degrees`; } }