栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

【OCR】AspriseOCR 条码识别 C++

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【OCR】AspriseOCR 条码识别 C++

源码:

// AspriseOCRDemo.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "DLL/asprise_ocr_api.h"
#include 

using namespace std;

void testOcr() {
	// CHANGE TO THE ACTUAL PATH to the folder where the aocr.dll or aocr.so locates in
	const char* libFolder = "LIB_FOLDER";

	// CHANGE TO THE ACTUAL PATH to the input image, can be jpeg, gif, png, tiff or pdf.
	//const char* fileImg = "PATH/1.png";//barcode 
	const char* fileImg = "PATH/opencvtutorials.png";

	LIBRARY_HANDLE libHandle = dynamic_load_aocr_library(libFolder);
	//cout << "chcp 65001" << endl;
	// one time setup
	int setup = c_com_asprise_ocr_setup(false);
	if (setup != 1) {
		cerr << "Failed to setup. code: " << setup << endl;
		return;
	}

	// starts the ocr engine; the pointer must be of long long type
	long long ptrToApi = c_com_asprise_ocr_start("eng", OCR_SPEED_SLOW, NULL, NULL, NULL);
	if (ptrToApi == 0) {
		cerr << "Failed to start." << endl;
		return;
	}

	 //barcode
	char* s = c_com_asprise_ocr_recognize(ptrToApi, fileImg, -1, -1, -1, -1, -1,
		OCR_RECOGNIZE_TYPE_TEXT, OCR_OUTPUT_FORMAT_PDF,
		"PROP_PDF_OUTPUT_FILE=result.pdf|PROP_PDF_OUTPUT_TEXT_VISIBLE=true|
      PROP_PDF_OUTPUT_RETURN_TEXT=text", "|", "=");

	string ss = s;
	cout << "Returned: " << ss << endl;

	// do more recognition here ...

	// finally, stops the OCR engine.
	c_com_asprise_ocr_stop(ptrToApi);

	cout << "Unload: " << (dynamic_unload_aocr_library(libHandle) ? "OK" : "Failed") << endl;
}


int main()
{
	testOcr();
	std::cout << "Press ENTER to exit: ";
	std::cin.ignore();
	return 0;
}

参考:

cike0cop/AspriseOCRDemo: AspriseOCRDemo (github.com)https://github.com/cike0cop/AspriseOCRDemo

免费在线条形码生成器-条码生成制作工具 (cnaidc.com)http://barcode.cnaidc.com/html/BCGcode128b.php

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/971670.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号