dist/ngx-document-scanner/bundles/ngx-document-scanner.umd.js
function () {
                var _this = this;
                return new Promise(function (resolve, reject) {
                    _this.processing.emit(true);
                    setTimeout(function () {
                        /** @type {?} */
                        var dst = cv.imread(_this.editedImage);
                        // create source coordinates matrix
                        /** @type {?} */
                        var sourceCoordinates = [
                            _this.getPoint(['top', 'left']),
                            _this.getPoint(['top', 'right']),
                            _this.getPoint(['bottom', 'right']),
                            _this.getPoint(['bottom', 'left'])
                        ].map(function (point) {
                            return [point.x / _this.imageResizeRatio, point.y / _this.imageResizeRatio];
                        });
                        // get max width
                        /** @type {?} */
                        var bottomWidth = _this.getPoint(['bottom', 'right']).x - _this.getPoint(['bottom', 'left']).x;
                        /** @type {?} */
                        var topWidth = _this.getPoint(['top', 'right']).x - _this.getPoint(['top', 'left']).x;
                        /** @type {?} */
                        var maxWidth = Math.max(bottomWidth, topWidth) / _this.imageResizeRatio;
                        // get max height
                        /** @type {?} */
                        var leftHeight = _this.getPoint(['bottom', 'left']).y - _this.getPoint(['top', 'left']).y;
                        /** @type {?} */
                        var rightHeight = _this.getPoint(['bottom', 'right']).y - _this.getPoint(['top', 'right']).y;
                        /** @type {?} */
                        var maxHeight = Math.max(leftHeight, rightHeight) / _this.imageResizeRatio;
                        // create dest coordinates matrix
                        /** @type {?} */
                        var destCoordinates = [
                            [0, 0],
                            [maxWidth - 1, 0],
                            [maxWidth - 1, maxHeight - 1],
                            [0, maxHeight - 1]
                        ];
                        // convert to open cv matrix objects
                        /** @type {?} */
                        var Ms = cv.matFromArray(4, 1, cv.CV_32FC2, [].concat.apply([], __spread(sourceCoordinates)));
                        /** @type {?} */
                        var Md = cv.matFromArray(4, 1, cv.CV_32FC2, [].concat.apply([], __spread(destCoordinates)));
                        /** @type {?} */
                        var transformMatrix = cv.getPerspectiveTransform(Ms, Md);
                        // set new image size
                        /** @type {?} */
                        var dsize = new cv.Size(maxWidth, maxHeight);
                        // perform warp
                        cv.warpPerspective(dst, dst, transformMatrix, dsize, cv.INTER_LINEAR, cv.BORDER_CONSTANT, new cv.Scalar());
                        cv.imshow(_this.editedImage, dst);
                        dst.delete();
                        Ms.delete();
                        Md.delete();
                        transformMatrix.delete();
                        _this.setPreviewPaneDimensions(_this.editedImage);
                        _this.showPreview().then(function () {
                            _this.processing.emit(false);
                            resolve();
                        });
                    }, 30);
                });
            }
function () {
                var _this = this;
                return new Promise(function (resolve, reject) {
                    _this.processing.emit(true);
                    setTimeout(function () {
                        /** @type {?} */
                        var dst = cv.imread(_this.editedImage);
                        // create source coordinates matrix
                        /** @type {?} */
                        var sourceCoordinates = [
                            _this.getPoint(['top', 'left']),
                            _this.getPoint(['top', 'right']),
                            _this.getPoint(['bottom', 'right']),
                            _this.getPoint(['bottom', 'left'])
                        ].map(function (point) {
                            return [point.x / _this.imageResizeRatio, point.y / _this.imageResizeRatio];
                        });
                        // get max width
                        /** @type {?} */
                        var bottomWidth = _this.getPoint(['bottom', 'right']).x - _this.getPoint(['bottom', 'left']).x;
                        /** @type {?} */
                        var topWidth = _this.getPoint(['top', 'right']).x - _this.getPoint(['top', 'left']).x;
                        /** @type {?} */
                        var maxWidth = Math.max(bottomWidth, topWidth) / _this.imageResizeRatio;
                        // get max height
                        /** @type {?} */
                        var leftHeight = _this.getPoint(['bottom', 'left']).y - _this.getPoint(['top', 'left']).y;
                        /** @type {?} */
                        var rightHeight = _this.getPoint(['bottom', 'right']).y - _this.getPoint(['top', 'right']).y;
                        /** @type {?} */
                        var maxHeight = Math.max(leftHeight, rightHeight) / _this.imageResizeRatio;
                        // create dest coordinates matrix
                        /** @type {?} */
                        var destCoordinates = [
                            [0, 0],
                            [maxWidth - 1, 0],
                            [maxWidth - 1, maxHeight - 1],
                            [0, maxHeight - 1]
                        ];
                        // convert to open cv matrix objects
                        /** @type {?} */
                        var Ms = cv.matFromArray(4, 1, cv.CV_32FC2, [].concat.apply([], __spread(sourceCoordinates)));
                        /** @type {?} */
                        var Md = cv.matFromArray(4, 1, cv.CV_32FC2, [].concat.apply([], __spread(destCoordinates)));
                        /** @type {?} */
                        var transformMatrix = cv.getPerspectiveTransform(Ms, Md);
                        // set new image size
                        /** @type {?} */
                        var dsize = new cv.Size(maxWidth, maxHeight);
                        // perform warp
                        cv.warpPerspective(dst, dst, transformMatrix, dsize, cv.INTER_LINEAR, cv.BORDER_CONSTANT, new cv.Scalar());
                        cv.imshow(_this.editedImage, dst);
                        dst.delete();
                        Ms.delete();
                        Md.delete();
                        transformMatrix.delete();
                        _this.setPreviewPaneDimensions(_this.editedImage);
                        _this.showPreview().then(function () {
                            _this.processing.emit(false);
                            resolve();
                        });
                    }, 30);
                });
            }
function ( ) { var _this = this ; return new Promise ( function ( resolve , reject ) { _this . processing . emit ( true ) ; setTimeout ( function ( ) { /** @type {?} */ var dst = cv . imread ( _this . editedImage ) ; // create source coordinates matrix /** @type {?} */ var sourceCoordinates = [ _this . getPoint ( [ 'top' , 'left' ] ) , _this . getPoint ( [ 'top' , 'right' ] ) , _this . getPoint ( [ 'bottom' , 'right' ] ) , _this . getPoint ( [ 'bottom' , 'left' ] ) ] . map ( function ( point ) { return [ point . x / _this . imageResizeRatio , point . y / _this . imageResizeRatio ] ; } ) ; // get max width /** @type {?} */ var bottomWidth = _this . getPoint ( [ 'bottom' , 'right' ] ) . x - _this . getPoint ( [ 'bottom' , 'left' ] ) . x ; /** @type {?} */ var topWidth = _this . getPoint ( [ 'top' , 'right' ] ) . x - _this . getPoint ( [ 'top' , 'left' ] ) . x ; /** @type {?} */ var maxWidth = Math . max ( bottomWidth , topWidth ) / _this . imageResizeRatio ; // get max height /** @type {?} */ var leftHeight = _this . getPoint ( [ 'bottom' , 'left' ] ) . y - _this . getPoint ( [ 'top' , 'left' ] ) . y ; /** @type {?} */ var rightHeight = _this . getPoint ( [ 'bottom' , 'right' ] ) . y - _this . getPoint ( [ 'top' , 'right' ] ) . y ; /** @type {?} */ var maxHeight = Math . max ( leftHeight , rightHeight ) / _this . imageResizeRatio ; // create dest coordinates matrix /** @type {?} */ var destCoordinates = [ [ 0 , 0 ] , [ maxWidth - 1 , 0 ] , [ maxWidth - 1 , maxHeight - 1 ] , [ 0 , maxHeight - 1 ] ] ; // convert to open cv matrix objects /** @type {?} */ var Ms = cv . matFromArray ( 4 , 1 , cv . CV_32FC2 , [ ] . concat . apply ( [ ] , __spread ( sourceCoordinates ) ) ) ; /** @type {?} */ var Md = cv . matFromArray ( 4 , 1 , cv . CV_32FC2 , [ ] . concat . apply ( [ ] , __spread ( destCoordinates ) ) ) ; /** @type {?} */ var transformMatrix = cv . getPerspectiveTransform ( Ms , Md ) ; // set new image size /** @type {?} */ var dsize = new cv . Size ( maxWidth , maxHeight ) ; // perform warp cv . warpPerspective ( dst , dst , transformMatrix , dsize , cv . INTER_LINEAR , cv . BORDER_CONSTANT , new cv . Scalar ( ) ) ; cv . imshow ( _this . editedImage , dst ) ; dst . delete ( ) ; Ms . delete ( ) ; Md . delete ( ) ; transformMatrix . delete ( ) ; _this . setPreviewPaneDimensions ( _this . editedImage ) ; _this . showPreview ( ) . then ( function ( ) { _this . processing . emit ( false ) ; resolve ( ) ; } ) ; } , 30 ) ; } ) ; }
apply perspective transform
@private
@return {?}
apply perspective transform