VS+OPENCV+ZBAR一维,二维码识别[包含中文]


VS+OPENCV+ZBAR一维,二维码识别,对于中文乱码已经解码
资源截图
代码片段和文件信息

#include “opencv/cv.h“     
#include “opencv2/imgproc/imgproc.hpp“
#include “opencv2/highgui/highgui.hpp“      
#include “zbar.h“      
#include         
#include 

using namespace std;        
using namespace zbar;  //添加zbar名称空间      
using namespace cv;        


void ConvertUtf8ToGBK(const char *strUtf8char *szResult)  
{  
int len=MultiByteToWideChar(CP_UTF8 0 strUtf8 -1 NULL0);  
wchar_t * wszGBK = new wchar_t[len];  
memset(wszGBK0len);  
MultiByteToWideChar(CP_UTF8 0 strUtf8 -1 wszGBK len);
#ifdef _UNICODE  
wcscpy(szResultwszGBK);  
#else  
len = WideCharToMultiByte(CP_ACP 0 wszGBK -1 NULL 0 NULL NULL);  
char *szGBK=new char[len + 1];  
memset(szGBK 0 len + 1);  
WideCharToMultiByte (CP_ACP 0 wszGBK -1 szGBK len NULLNULL);  
strcpy(szResultszGBK);  
delete[] szGBK;  
#endif  
delete[] wszGBK;  
}  


int main(int argcchar*argv[])      
{        
ImageScanner scanner;        
scanner.set_config(ZBAR_NONE ZBAR_CFG_ENABLE 1);      
Mat image = imread(“1111.png“);    
if(!image.data)  
{  
cout<<“请确认图片“< system(“pause“);  
return 0;  
}  
Mat imageGray;        
cvtColor(imageimageGrayCV_RGB2GRAY);        
int width = imageGray.cols;        
int height = imageGray.rows;        
uchar *raw = (uchar *)imageGray.data;           
Image imageZbar(width height “Y800“ raw width * height);          
scanner.scan(imageZbar); //扫描条码      
Image::SymbolIterator symbol = imageZbar.symbol_begin();    
if(imageZbar.symbol_begin()==imageZbar.symbol_end())    
{    
cout<<“查询条码失败,请检查图片!“< }    
for(;symbol != imageZbar.symbol_end();++symbol)      
{       
#ifdef _UNICODE
wchar_t szResult[256];
ConvertUtf8ToGBK(symbol->get_data().c_str()szResult); 
cout<<“类型:“<get_type_name()< wcout.imbue(locale(“chs“)); 
wcout<<“条码:“<#else
char szResult[256];
ConvertUtf8ToGBK(symbol->get_data().c_str()szResult); 
cout<<“类型:“<get_type_name()< cout<<“条码:“<#endif
}        

imshow(“Source Image“image);   
//cv::resizeWindow(“Source Image“600450);
waitKey();      
imageZbar.set_data(NULL0);    
return 0;    
}        




 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      30931  2018-04-23 12:03  ZbarTestDebug1235.png

     文件     964989  2009-10-16 07:13  ZbarTestDebuglibiconv-2.dll

     文件     234004  2009-10-16 07:10  ZbarTestDebuglibjpeg-7.dll

     文件    3225283  2009-10-17 00:06  ZbarTestDebuglibMagickCore-2.dll

     文件    1030247  2009-10-17 00:06  ZbarTestDebuglibMagickWand-2.dll

     文件     187149  2009-10-16 07:11  ZbarTestDebuglibpng12-0.dll

     文件     375388  2009-10-16 07:12  ZbarTestDebuglibtiff-3.dll

     文件    1157984  2009-10-17 10:35  ZbarTestDebuglibxml2-2.dll

     文件     209438  2009-10-27 23:31  ZbarTestDebuglibzbar-0.dll

     文件      30120  2009-10-27 23:31  ZbarTestDebuglibzbar-0.lib

     文件      66048  2018-04-24 11:46  ZbarTestDebugbarTest.exe

     文件     596980  2018-04-24 11:46  ZbarTestDebugbarTest.ilk

     文件    1715200  2018-04-24 11:46  ZbarTestDebugbarTest.pdb

     文件      78465  2009-10-16 07:09  ZbarTestDebugzlib1.dll

     文件   45809664  2018-04-24 11:16  ZbarTestipchzbartest-fcef7939zbartest-3aa27cf5.ipch

     文件   87818240  2018-04-24 11:39  ZbarTestipchzbartest-fcef7939zbartest-e398e1bb.ipch

     文件    2587104  2018-01-12 15:25  ZbarTestBar.rar

     文件       1623  2018-04-24 10:21  ZbarTestbarTest1111.png

     文件    1561236  2018-01-12 13:48  ZbarTestbarTest1234.jpg

     文件       6742  2018-01-12 14:06  ZbarTestbarTest1235.jpg

     文件     402876  2018-01-16 08:44  ZbarTestbarTest12353.jpg

     文件        290  2018-01-12 14:25  ZbarTestbarTest44444.props

     文件    1561236  2018-01-12 13:48  ZbarTestbarTest9999.jpg

     文件    1208396  2018-01-12 14:21  ZbarTestbarTestaidu汇总.jpg

     文件     398085  2018-01-12 14:09  ZbarTestbarTestcode39.jpg

     文件        654  2018-04-24 11:46  ZbarTestbarTestDebugcl.command.1.tlog

     文件      32546  2018-04-24 11:46  ZbarTestbarTestDebugCL.read.1.tlog

     文件        384  2018-04-24 11:46  ZbarTestbarTestDebugCL.write.1.tlog

     文件          2  2018-04-24 11:46  ZbarTestbarTestDebuglink-cvtres.read.1.tlog

     文件          2  2018-04-24 11:46  ZbarTestbarTestDebuglink-cvtres.write.1.tlog

............此处省略79个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)