recognition/quality-settings.js

const _MwWrapper = require("../_mwbridge/_mw-wrapper.js");
const { MwQualitySettings } = require("../_mwbridge/_mw-bridge");

/**
 * QualitySettings allows to configure recognition quality and speed manually.<br>
 * You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality,<br>
 * HighQuality, MaxBarCodes or you can manually configure separate options.<br>
 * Default value of QualitySettings is NormalQuality.
 * @example
 * //This sample shows how to use QualitySettings with BarCodeReader
 * let reader = new BarCodeReader("test.png", null,  [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
 * //set high performance mode
 * reader.setQualitySettings(QualitySettings.getHighPerformance());
 * let results = reader.readBarCodes();
 * for(let i = 0; i < results.length; i++)
 * {
 *    let result = results[i];
 *    console.log("BarCode CodeText: " + result.getCodeText());
 * }
 * @example
 * let reader = new BarCodeReader("test.png", null,  [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
 * //normal quality mode is set by default
 * let results = reader.readBarCodes();
 * for(let i = 0; i < results.length; i++)
 * {
 *    let result = results[i];
 *   console.log("BarCode CodeText: " + result.getCodeText());
 * }
 * @example
 * let reader = new BarCodeReader("test.png", null,  [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
 * //set high quality mode with low speed recognition
 * reader.setQualitySettings(QualitySettings.getHighQuality());
 * let results = reader.readBarCodes();
 * for(let i = 0; i < results.length; i++)
 * {
 *   let result = results[i];
 *   console.log("BarCode CodeText: " + result.getCodeText());
 * }
 * @example
 * let reader = new BarCodeReader("test.png", null,  [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
 * //set max barcodes mode, which tries to find all possible barcodes, even incorrect. The slowest recognition mode
 * reader.setQualitySettings(QualitySettings.getMaxBarCodes());
 * let results = reader.readBarCodes();
 * for(let i = 0; i < results.length; i++)
 * {
 *   let result = results[i];
 *   console.log("BarCode CodeText: " + result.getCodeText());
 * }
 * @example
 * let reader = new BarCodeReader("test.png", null,  [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
 * //set high performance mode
 * reader.setQualitySettings(QualitySettings.getHighPerformance());
 * //set separate options
 * reader.getQualitySettings().setAllowMedianSmoothing(true);
 * reader.getQualitySettings().setMedianSmoothingWindowSize(5);
 * let results = reader.readBarCodes();
 * for(let i = 0; i < results.length; i++)
 * {
 *    let result = results[i];
 *    console.log("BarCode CodeText: " + result.getCodeText());
 * }
 * @example
 * let reader = new BarCodeReader("test.png", null,  [ DecodeType.CODE_39, DecodeType.CODE_128 ]);
 * //default mode is NormalQuality
 * //set separate options
 * reader.getQualitySettings().setAllowMedianSmoothing(true);
 * reader.getQualitySettings().setMedianSmoothingWindowSize(5);
 * let results = reader.readBarCodes();
 * for(let i = 0; i < results.length; i++)
 * {
 *   let result = results[i];
 *   console.log("BarCode CodeText: " + result.getCodeText());
 * }
 */
class QualitySettings extends _MwWrapper
{

    constructor(mwObject)
    {
        super(mwObject);
        this._initializeWrapperMembers();
    }

    _initializeWrapperMembers()
    {
    }

    /**
     * HighPerformance recognition quality preset. High quality barcodes are recognized well in this mode.<br>
     * @example
     * let reader = new BarCodeReader("test.png");
     * reader.setQualitySettings(QualitySettings.getHighPerformance());
     */
    static getHighPerformance()
    {
        return new QualitySettings(MwQualitySettings.getHighPerformanceSync());
    }

    /**
     * NormalQuality recognition quality preset. Suitable for the most of barcodes
     *
     * @example
     * let reader = new BarCodeReader("test.png");
     * reader.setQualitySettings(QualitySettings.getNormalQuality());

     */
    static getNormalQuality()
    {
        return new QualitySettings(MwQualitySettings.getNormalQualitySync());
    }

    /**
     * HighQuality recognition quality preset. This preset is developed for low quality barcodes.
     *
     * @example
     * let reader = new BarCodeReader("test.png");
     * reader.setQualitySettings(QualitySettings.getHighQuality());
     */
    static getHighQuality()
    {
        return new QualitySettings(MwQualitySettings.getHighQualitySync());
    }

    /**
     * <p>
     *  MaxQuality recognition quality preset. This preset is developed to recognize all possible barcodes, even incorrect barcodes.
     *  </p><p><hr><blockquote><pre>
     *  This sample shows how to use MaxQuality mode
     *  <pre>
     *
     *  reader = new BarCodeReader("test.png"null, null, DecodeType.CODE_39_FULL_ASCII, DecodeType.CODE_128);
     *  {
     *      reader.setQualitySettings(QualitySettings.getMaxQuality());
     *      for(let i = 0; i < reader.readBarCodes().length; i++)
     *          echo (reader.getFoundBarcodes()[i].getCodeText());
     *  }
     * 	</pre>
     *  </pre></blockquote></hr></p>Value:
     *  MaxQuality recognition quality preset.
     *
     */
    static getMaxQuality()
    {
        return new QualitySettings(MwQualitySettings.getMaxQualitySync());
    }

    /**
     * Recognition mode which sets size (from 1 to infinity) of barcode minimal element: matrix cell or bar.
     * @return size (from 1 to infinity) of barcode minimal element: matrix cell or bar.
     */
    getXDimension()
    {
        return this.getJavaClass().getXDimensionSync();
    }
    /**
     * Recognition mode which sets size (from 1 to infinity) of barcode minimal element: matrix cell or bar.
     * @param value (from 1 to infinity) of barcode minimal element: matrix cell or bar.
     */
    setXDimension(value)
    {
        this.getJavaClass().setXDimensionSync(value);
    }

    /**
     * Minimal size of XDimension in pixels which is used with UseMinimalXDimension.
     * @return Minimal size of XDimension in pixels which is used with UseMinimalXDimension.
     */
    getMinimalXDimension()
    {
        return this.getJavaClass().getMinimalXDimensionSync();
    }

    /**
     * Minimal size of XDimension in pixels which is used with UseMinimalXDimension.
     * @param value Minimal size of XDimension in pixels which is used with UseMinimalXDimension.
     */
    setMinimalXDimension(value)
    {
        this.getJavaClass().setMinimalXDimensionSync(value);
    }

    /**
     * Mode which enables methods to recognize barcode elements with the selected quality. Barcode element with lower quality requires more hard methods which slows the recognition.
     * @return Mode which enables methods to recognize barcode elements with the selected quality.
     */
    getBarcodeQuality()
    {
        return this.getJavaClass().getBarcodeQualitySync();
    }
    /**
     * Mode which enables methods to recognize barcode elements with the selected quality. Barcode element with lower quality requires more hard methods which slows the recognition.
     * @param value Mode which enables methods to recognize barcode elements with the selected quality.
     */
    setBarcodeQuality(value)
    {
        this.getJavaClass().setBarcodeQualitySync(value);
    }

    /**
     * <p>
     * Deconvolution (image restorations) mode which defines level of image degradation. Originally deconvolution is a function which can restore image degraded
     * (convoluted) by any natural function like blur, during obtaining image by camera. Because we cannot detect image function which corrupt the image,
     * we have to check most well know functions like sharp or mathematical morphology.
     * @return Deconvolution mode which defines level of image degradation.
     */
    getDeconvolution()
    {
        return this.getJavaClass().getDeconvolutionSync();
    }
    /**
     * Deconvolution (image restorations) mode which defines level of image degradation. Originally deconvolution is a function which can restore image degraded
     * (convoluted) by any natural function like blur, during obtaining image by camera. Because we cannot detect image function which corrupt the image,
     * we have to check most well know functions like sharp or mathematical morphology.
     * @param value Deconvolution mode which defines level of image degradation.
     */
    setDeconvolution(value)
    {
        this.getJavaClass().setDeconvolutionSync(value);
    }

    /**
     * <p>
     * Mode which enables or disables additional recognition of barcodes on images with inverted colors (luminance).
     * @return Additional recognition of barcodes on images with inverse colors
     */
    getInverseImage()
    {
        return this.getJavaClass().getInverseImageSync();
    }
    /**
     * Mode which enables or disables additional recognition of barcodes on images with inverted colors (luminance).
     * @param value Additional recognition of barcodes on images with inverse colors
     */
    setInverseImage(value)
    {
        this.getJavaClass().setInverseImageSync(value);
    }

    /**
     * Mode which enables or disables additional recognition of color barcodes on color images.
     * @return Additional recognition of color barcodes on color images.
     */
    getComplexBackground()
    {
        return this.getJavaClass().getComplexBackgroundSync();
    }

    /**
     * Mode which enables or disables additional recognition of color barcodes on color images.
     * @param value Additional recognition of color barcodes on color images.
     */
    setComplexBackground(value)
    {
        this.getJavaClass().setComplexBackgroundSync(value);
    }

    /**
     * <p>
     * Allows engine to recognize barcodes which has incorrect checksumm or incorrect values. Mode can be used to recognize damaged barcodes with incorrect text.
     * @return Allows engine to recognize incorrect barcodes.
     */
    getAllowIncorrectBarcodes()
    {
        return this.getJavaClass().getAllowIncorrectBarcodesSync();
    }
    /**
     * <p>
     * Allows engine to recognize barcodes which has incorrect checksumm or incorrect values. Mode can be used to recognize damaged barcodes with incorrect text.
     * @param value Allows engine to recognize incorrect barcodes.
     */
    setAllowIncorrectBarcodes(value)
    {
        this.getJavaClass().setAllowIncorrectBarcodesSync(value);
    }
}

module.exports = QualitySettings;