1. Produkti
  2.   OCR
  3.   Node.js
  4.   Baidu-ocr-api
 
  

Bezmaksas Node.js API, lai atpazītu un izvilktu tekstu no attēliem

Bezmaksas Node.js ir vadošais Node.js API, kas piedāvā augstu precizitāti teksta atpazīšanā vairākās valodās un dažādos fontos un izkārtojumos.

In today’s AI-driven development world, Optical Character Recognition (OCR) has become essential for automating text extraction from images and documents. Developers seeking to create OCR in Node.js can benefit greatly from the Baidu-OCR-API, a powerful tool that supports extracting text from images, handwriting text recognition, and even advanced tasks like form recognition inside Node.js apps. Whether it's scanning invoices, digitizing documents, or enabling accessibility features, this Node.js OCR library offers high performance and is easy to integrate with modern applications.

Baidu-OCR-API is a free Node.js OCR API that utilizes deep learning to recognize printed and handwritten text across multiple languages, including Chinese, English, Japanese, and more. It excels in table recognition in Node.js, business document scanning, and recognizing text in complex conditions such as low-light or distorted images. Developers can also recognize text within natural scenes, making it perfect for mobile apps, augmented reality, and real-time translation use cases. With its accurate recognition and versatile use cases, Baidu-OCR-API is an ideal choice for any developer looking to integrate reliable OCR functionality into Node.js applications.

Previous Next

Sākšana ar Baidu-OCR-API

Ieteicamais veids, kā instalēt Baidu-OCR-API, ir izmantot npm. Lūdzu, izmantojiet šādu komandu, lai veiktu vienkāršu instalēšanu

Install Baidu-OCR-APIvia npm

 npm install baidu-ocr-api -g 

You can also install it manually; download the latest release files directly from GitHub repository.

Izvilkt tekstu no attēliem Node.js lietotnēs

Baidu-OCR-API atvieglo programmatūras izstrādātājiem attēlu ielādēšanu un nolasīšanu, kā arī teksta izvilkšanu Node.js lietotnēs. Vispārējā teksta atpazīšanas funkcija ļauj izstrādātājiem ielādēt un izvilkt drukātu tekstu no attēliem, kas piemērots plašam dokumentu spektram. API ir iekļāvis atbalstu dažādiem populāriem attēlu failu formātiem, piemēram, JPEG, PNG, GIF, TIFF, PDF, BMP un daudziem citiem. Zemāk esošais piemērs parāda, kā izstrādātāji var ielādēt un veikt teksta atpazīšanu attēlā Node.js lietotnēs.

How to Load and Perform Text Recognition on an Image inside Node.js Apps?

//Read image

const fs = require('fs');

// Read the image file and convert it to base64
function readImage(filePath) {
    return fs.readFileSync(filePath, { encoding: 'base64' });
}

const image = readImage('path_to_your_image.jpg');

// Perform OCR
client.generalBasic(image).then(result => {
    console.log('Recognized Text:');
    result.words_result.forEach(wordInfo => {
        console.log(wordInfo.words);
    });
}).catch(err => {
    console.error(err);
});

Formu un tabulu atpazīšana Node.js lietotnēs

The open source Baidu-OCR-API has provided complete functionality for recognizing form and table inside Node.js applications. To perform the task successful first you need to set up your Baidu OCR client using your API credentials. Then, write the code to read an image and perform form and table recognition. This functionality can be particularly useful for automating data extraction from structured documents and enhancing productivity in various applications. Here is simple example that shows, how software developer can read an image and perform form and table recognition inside Node.js environment.

How to Read an Image and Perform Form and Table Recognition in Node.js Apps?

const BaiduOCR = require('baidu-ocr-api');
const fs = require('fs');

// Your API credentials
const APP_ID = 'your-app-id';
const API_KEY = 'your-api-key';
const SECRET_KEY = 'your-secret-key';

// Initialize the Baidu OCR client
const client = new BaiduOCR(APP_ID, API_KEY, SECRET_KEY);

// Function to read the image file and convert it to base64
function readImage(filePath) {
    return fs.readFileSync(filePath, { encoding: 'base64' });
}

// Path to your image
const image = readImage('path_to_your_image.jpg');

// Perform Form and Table Recognition
client.form(image).then(result => {
    console.log('Form and Table Data:');
    console.log(JSON.stringify(result, null, 2));
}).catch(err => {
    console.error('Error:', err);
});

Rokas raksta teksta atpazīšana caur Node.js API

The open source Baidu-OCR-API is very easy to handle and is fully capable of recognizing handwritten text with high precision inside Node.js applications. The achieve the goal the image file is read and converted to a base64 string and after that The handwriting method is called with the base64-encoded image, and the recognized handwritten text is logged to the console. The following example demonstrates how software developers can perform handwriting text recognition using the open-source Baidu OCR API in Node.js.

How to Perform Handwriting Text Recognition inside Node.js Apps?

// Path to your image
const image = readImage('path_to_your_image.jpg');

// Perform Handwriting Text Recognition
client.handwriting(image).then(result => {
    console.log('Recognized Handwritten Text:');
    result.words_result.forEach(wordInfo => {
        console.log(word
 Latviski