Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tzmax/ocr-common

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tzmax/ocr-common - npm Package Compare versions

Comparing version 1.4.6 to 1.4.8

38

build/backend/splitIntoLineImages.js

@@ -12,3 +12,3 @@ "use strict";

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var cv = _interopRequireWildcard(require("@techstark/opencv-js"));
var _opencvJs = _interopRequireDefault(require("@techstark/opencv-js"));
var clipper = _interopRequireWildcard(require("js-clipper"));

@@ -32,6 +32,6 @@ var _index = require("../backend/index.js");

src = cvImread(image);
cv.cvtColor(src, src, cv.COLOR_RGBA2GRAY, 0);
contours = new cv.MatVector();
hierarchy = new cv.Mat();
cv.findContours(src, contours, hierarchy, cv.RETR_LIST, cv.CHAIN_APPROX_SIMPLE);
_opencvJs["default"].cvtColor(src, src, _opencvJs["default"].COLOR_RGBA2GRAY, 0);
contours = new _opencvJs["default"].MatVector();
hierarchy = new _opencvJs["default"].Mat();
_opencvJs["default"].findContours(src, contours, hierarchy, _opencvJs["default"].RETR_LIST, _opencvJs["default"].CHAIN_APPROX_SIMPLE);
_loop = /*#__PURE__*/_regenerator["default"].mark(function _loop() {

@@ -56,3 +56,3 @@ var minSize, cnt, _getMiniBoxes, points, sside, clipBox, boxMap, resultObj, box, clip, rx, ry, _i, box1, rect_width, rect_height, c;

clipBox = unclip(points);
boxMap = cv.matFromArray(clipBox.length / 2, 1, cv.CV_32SC2, clipBox);
boxMap = _opencvJs["default"].matFromArray(clipBox.length / 2, 1, _opencvJs["default"].CV_32SC2, clipBox);
resultObj = getMiniBoxes(boxMap);

@@ -128,3 +128,3 @@ box = resultObj.points;

function getMiniBoxes(contour) {
var boundingBox = cv.minAreaRect(contour);
var boundingBox = _opencvJs["default"].minAreaRect(contour);
var points = Array.from(boxPoints(boundingBox.center, boundingBox.size, boundingBox.angle)).sort(function (a, b) {

@@ -212,11 +212,11 @@ return a[0] - b[0];

var pts_std = [[0, 0], [img_crop_width, 0], [img_crop_width, img_crop_height], [0, img_crop_height]];
var srcTri = cv.matFromArray(4, 1, cv.CV_32FC2, flatten(points));
var dstTri = cv.matFromArray(4, 1, cv.CV_32FC2, flatten(pts_std));
var srcTri = _opencvJs["default"].matFromArray(4, 1, _opencvJs["default"].CV_32FC2, flatten(points));
var dstTri = _opencvJs["default"].matFromArray(4, 1, _opencvJs["default"].CV_32FC2, flatten(pts_std));
// 获取到目标矩阵
var M = cv.getPerspectiveTransform(srcTri, dstTri);
var M = _opencvJs["default"].getPerspectiveTransform(srcTri, dstTri);
var src = cvImread(imageRaw);
var dst = new cv.Mat();
var dsize = new cv.Size(img_crop_width, img_crop_height);
var dst = new _opencvJs["default"].Mat();
var dsize = new _opencvJs["default"].Size(img_crop_width, img_crop_height);
// 透视转换
cv.warpPerspective(src, dst, M, dsize, cv.INTER_CUBIC, cv.BORDER_REPLICATE, new cv.Scalar());
_opencvJs["default"].warpPerspective(src, dst, M, dsize, _opencvJs["default"].INTER_CUBIC, _opencvJs["default"].BORDER_REPLICATE, new _opencvJs["default"].Scalar());
var dst_img_height = dst.matSize[0];

@@ -227,7 +227,7 @@ var dst_img_width = dst.matSize[1];

if (dst_img_height / dst_img_width >= 1.5) {
dst_rot = new cv.Mat();
var dsize_rot = new cv.Size(dst.rows, dst.cols);
var center = new cv.Point(dst.cols / 2, dst.cols / 2);
var _M = cv.getRotationMatrix2D(center, 90, 1);
cv.warpAffine(dst, dst_rot, _M, dsize_rot, cv.INTER_CUBIC, cv.BORDER_REPLICATE, new cv.Scalar());
dst_rot = new _opencvJs["default"].Mat();
var dsize_rot = new _opencvJs["default"].Size(dst.rows, dst.cols);
var center = new _opencvJs["default"].Point(dst.cols / 2, dst.cols / 2);
var _M = _opencvJs["default"].getRotationMatrix2D(center, 90, 1);
_opencvJs["default"].warpAffine(dst, dst_rot, _M, dsize_rot, _opencvJs["default"].INTER_CUBIC, _opencvJs["default"].BORDER_REPLICATE, new _opencvJs["default"].Scalar());
}

@@ -311,3 +311,3 @@ src["delete"]();

function cvImread(image) {
return cv.matFromImageData(image);
return _opencvJs["default"].matFromImageData(image);
}

@@ -314,0 +314,0 @@ function cvImshow(mat) {

{
"name": "@tzmax/ocr-common",
"description": "Guten OCR is a high accurate text detection (OCR) Javascript/Typescript library that runs on Node.js, Browser, React Native and C++. Based on PaddleOCR and ONNX runtime",
"version": "1.4.6",
"version": "1.4.8",
"type": "commonjs",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -1,2 +0,2 @@

import * as cv from '@techstark/opencv-js'
import cv from '@techstark/opencv-js'
import * as clipper from 'js-clipper'

@@ -3,0 +3,0 @@ import { ImageRaw } from '#common/backend'

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc