-
大小: 44.83MB文件類型: .rar金幣: 1下載: 0 次發(fā)布日期: 2023-07-24
- 語言: 其他
- 標簽: 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??ZbarTest\Debug\1235.png
?????文件?????964989??2009-10-16?07:13??ZbarTest\Debug\libiconv-2.dll
?????文件?????234004??2009-10-16?07:10??ZbarTest\Debug\libjpeg-7.dll
?????文件????3225283??2009-10-17?00:06??ZbarTest\Debug\libMagickCore-2.dll
?????文件????1030247??2009-10-17?00:06??ZbarTest\Debug\libMagickWand-2.dll
?????文件?????187149??2009-10-16?07:11??ZbarTest\Debug\libpng12-0.dll
?????文件?????375388??2009-10-16?07:12??ZbarTest\Debug\libtiff-3.dll
?????文件????1157984??2009-10-17?10:35??ZbarTest\Debug\libxm
?????文件?????209438??2009-10-27?23:31??ZbarTest\Debug\libzbar-0.dll
?????文件??????30120??2009-10-27?23:31??ZbarTest\Debug\libzbar-0.lib
?????文件??????66048??2018-04-24?11:46??ZbarTest\Debug\ZbarTest.exe
?????文件?????596980??2018-04-24?11:46??ZbarTest\Debug\ZbarTest.ilk
?????文件????1715200??2018-04-24?11:46??ZbarTest\Debug\ZbarTest.pdb
?????文件??????78465??2009-10-16?07:09??ZbarTest\Debug\zlib1.dll
?????文件???45809664??2018-04-24?11:16??ZbarTest\ipch\zbartest-fcef7939\zbartest-3aa27cf5.ipch
?????文件???87818240??2018-04-24?11:39??ZbarTest\ipch\zbartest-fcef7939\zbartest-e398e1bb.ipch
?????文件????2587104??2018-01-12?15:25??ZbarTest\ZBar.rar
?????文件???????1623??2018-04-24?10:21??ZbarTest\ZbarTest\1111.png
?????文件????1561236??2018-01-12?13:48??ZbarTest\ZbarTest\1234.jpg
?????文件???????6742??2018-01-12?14:06??ZbarTest\ZbarTest\1235.jpg
?????文件?????402876??2018-01-16?08:44??ZbarTest\ZbarTest\12353.jpg
?????文件????????290??2018-01-12?14:25??ZbarTest\ZbarTest\44444.props
?????文件????1561236??2018-01-12?13:48??ZbarTest\ZbarTest\9999.jpg
?????文件????1208396??2018-01-12?14:21??ZbarTest\ZbarTest\baidu匯總.jpg
?????文件?????398085??2018-01-12?14:09??ZbarTest\ZbarTest\code39.jpg
?????文件????????654??2018-04-24?11:46??ZbarTest\ZbarTest\Debug\cl.command.1.tlog
?????文件??????32546??2018-04-24?11:46??ZbarTest\ZbarTest\Debug\CL.read.1.tlog
?????文件????????384??2018-04-24?11:46??ZbarTest\ZbarTest\Debug\CL.write.1.tlog
?????文件??????????2??2018-04-24?11:46??ZbarTest\ZbarTest\Debug\li
?????文件??????????2??2018-04-24?11:46??ZbarTest\ZbarTest\Debug\li
............此處省略79個文件信息
- 上一篇:樂鑫8266官方開發(fā)資料
- 下一篇:多源信息融合 韓崇昭
評論
共有 條評論