OpenCV+zbar开源库实现摄像头识别二维码,测试验证识别率非常高,已实现简单的应用。 打包源码在VS2013下可以完全编译成功,附加包含OpenCV库及zbar-0.10-setup.exe,zbar-0.10.tar.bz2 下载Demo后需要安装 zbar-0.10-setup.exe 以下代码可以可以完成整个流程的开发,也可以贡献积分下载资源包。 1、 环境准备 (1) OpenCV库2.49 (2) ZBar开源库 (3) VS2013 2、 VS2013环境配置 (1) 配置附加包含目录 C/C++ -- 附加包含目录 include\opencv\include\ include\opencv\include\opencv include\opencv\include\opencv2 include (2) 配置链接器 链接器 -- 附加库目录 lib32\opencv\lib lib32 (3) 配置链接器 链接器--输入--附加依赖项 opencv_core249d.lib opencv_highgui249d.lib opencv_imgproc249d.lib libzbar-0.lib 3、 代码开发 (1)包含头文件 include <cv> include <cxcore> include <highgui> include <stdio> include <stdlib> include <zbar> using namespace std; using namespace zbar; using namespace cv; (2)实现函数 void MatToCImage(cv::Mat &mat, CImage &cImage) { //create new CImage int width = mat.cols; int height = mat.rows; int channels = mat.channels(); cImage.Destroy(); //clear cImage.Create(width, height, 8 * channels); //默认图像像素单通道占用1个字节 //copy values uchar* ps; uchar* pimg = (uchar*)cImage.GetBits(); //A pointer to the bitmap buffer int step = cImage.GetPitch(); for (int i = 0; i < height xss=removed>(i)); for (int j = 0; j < width xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed>GetDlgItem(IDC_STATIC_IMG)->GetClientRect(▭); cv::VideoCapture capture(0);//从摄像头读入图像 while (!m_bCloseCamera) { cv::Mat frame; capture >> frame; cv::Mat newframe; cv::Size ResImgSiz = cv::Size(rect.Width(), rect.Height()); cv::resize(frame, newframe, ResImgSiz, CV_INTER_CUBIC); MatToCImage(newframe, imgDst); imgDst.Draw(pThis->GetDlgItem(IDC_STATIC_IMG)->GetDC()->GetSafeHdc(), rect); ImageScanner scanner; scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1); Mat imageGray; cvtColor(frame, imageGray, CV_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()) { } else { iIndex++; if (iIndex > 999999) { iIndex = 0; } for (; symbol != imageZbar.symbol_end(); ++symbol) { char szInfo[1024]; memset(szInfo, 0, sizeof(szInfo)); sprintf(szInfo, "[d]类型:%s\r\n条码:%s\r\n", iIndex , symbol->get_type_name().c_str(), symbol->get_data().c_str()); pThis->GetDlgItem(IDC_EDIT1)->SetWindowText(szInfo); } } imageZbar.set_data(NULL, 0); } imgDst.Destroy(); capture.release(); return 0; }
OpenCV + zbar开源库实现摄像头识别二维码 (241个子文件)
libzbar.dll.a 76KB
ZBarExam.aps 106KB
zbar-0.10.tar.bz2 579KB
ZBarExamDlg.cpp 6KB
ZBarExam.cpp 2KB
stdafx.cpp 141B
libzbar-0.def 3KB
opencv_ffmpeg249.dll 10.05MB
opencv_highgui249d.dll 3.65MB
opencv_highgui249d.dll 3.65MB
opencv_core249d.dll 3.56MB
opencv_core249d.dll 3.56MB
opencv_imgproc249d.dll 3.28MB
opencv_imgproc249d.dll 3.28MB
opencv_highgui249.dll 2.05MB
opencv_core249.dll 2.04MB
opencv_imgproc249.dll 1.83MB
libiconv-2.dll 942KB
libzbar-0.dll 205KB
zbar-0.10-setup.exe 3.11MB
ZBarExam.exe 242KB
ZBarExam.vcxproj.filters 2KB
ts_gtest.h 832KB
core_c.h 78KB
types_c.h 58KB
zbar.h 46KB
kmeans_index.h 35KB
imgproc_c.h 30KB
highgui_c.h 28KB
dist.h 25KB
hierarchical_clustering_index.h 22KB
autotuned_index.h 21KB
kdtree_single_index.h 20KB
kdtree_index.h 20KB
lsh_table.h 18KB
types_c.h 17KB
lsh_index.h 16KB
result_set.h 15KB
index_testing.h 11KB
Symbol.h 11KB
Image.h 8KB
any.h 8KB
hdf5.h 7KB
Processor.h 7KB
nn_index.h 6KB
allocator.h 6KB
composite_index.h 6KB
zbargtk.h 6KB
all_indices.h 6KB
saving.h 6KB
simplex_downhill.h 6KB
cap_ios.h 5KB
Decoder.h 5KB
QZBar.h 5KB
defines.h 5KB
dynamic_bitset.h 5KB
Exception.h 5KB
Video.h 4KB
heap.h 4KB
Scanner.h 4KB
linear_index.h 4KB
random.h 4KB
ImageScanner.h 4KB
Window.h 4KB
logger.h 4KB
cv.h 3KB
matrix.h 3KB
ground_truth.h 3KB
params.h 3KB
object_factory.h 3KB
sampling.h 3KB
cvaux.h 3KB
photo_c.h 3KB
timer.h 2KB
cxcore.h 2KB
ios.h 2KB
highgui.h 2KB
ml.h 2KB
cvwimage.h 2KB
QZBarImage.h 2KB
general.h 2KB
config.h 2KB
resource.h 2KB
stdafx.h 2KB
ZBarExamDlg.h 655B
ZBarExam.h 455B
dummy.h 267B
targetver.h 234B
cxmisc.h 116B
color_detail.hpp 219KB
core.hpp 187KB
legacy.hpp 137KB
operations.hpp 133KB
gpu.hpp 110KB
ocl.hpp 95KB
mat.hpp 81KB
ml.hpp 79KB
features2d.hpp 64KB
imgproc.hpp 56KB
vec_math.hpp 50KB- 1
- 2
- 3
- 粉丝: 2
创作灵感
更多 >
我的内容管理
展开
我的资源
快来上传第一个资源
我的收益 登录查看自己的收益
我的积分
登录查看自己的积分
我的C币
登录后查看C币余额
我的收藏
我的下载
下载帮助
前往需求广场,查看用户热搜最新资源
- mediatailor-jvm-1.2.47-sources.jar
- sagemakera2iruntime-jvm-1.4.89-javadoc.jar
- healthlake-jvm-1.4.41.jar
- polly-jvm-1.4.27-javadoc.jar
- kinesisvideowebrtcstorage-jvm-1.4.19.jar
- vraptor-validator-example-2.0.3-sources.jar
- anteros-persistence-android-1.0.4-sources.jar
- nunaliit2-auth-http-0.1.4.jar
- route53domains-jvm-1.3.74-sources.jar
- mturk-jvm-0.34.1-beta-sources.jar
- stubby4j-1.0.55-no-dependencies.jar
- workdocs-0.17.12-beta-javadoc.jar
- ivschat-jvm-1.5.0.jar
- licensemanager-jvm-1.0.52-javadoc.jar
- lakeformation-jvm-1.0.78.jar
- datalake-spark31_2.12-0.1.7.jar


信息提交成功