https://opencv.org/releases/ source code download
1. lib file
F:\openCV\lib_debug
opencv_imgproc420d.lib
opencv_calib3d420d.lib
opencv_core420d.lib
opencv_dnn420d.lib
opencv_features2d420d.lib
opencv_flann420d.lib
opencv_highgui420d.lib
opencv_imgcodecs420d.lib
opencv_ml420d.lib
opencv_objdetect420d.lib
opencv_photo420d.lib
opencv_stitching420d.lib
opencv_ts420d.lib
opencv_video420d.lib
opencv_videoio420d.lib
libzbar-0.lib
2. header file
F:\openCV\include\opencv2
F:\openCV\include
#include <opencv2/imgproc.hpp> // Gaussian Blur
#include <opencv2/core.hpp> // Basic OpenCV structures (cv::Mat, Scalar)
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp> // OpenCV window I/O
#include <opencv2/features2d.hpp>
#include <opencv2/objdetect.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <zbar.h>
using namespace cv;
using namespace std;
using namespace zbar;
int main(int argc, char* argv[])
{
ImageScanner scanner;
scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);
Mat image = imread("F:\\EAN13.jpg");
//Mat image = imread("F:\\Code39.jpg");
//Mat image = imread("F:\\Code93.jpg");
//Mat image = imread("F:\\Code128.jpg");
Mat imageGray;
cvtColor(image, imageGray, COLOR_BGR2GRAY);
int width = imageGray.cols;
int height = imageGray.rows;
uchar *raw = (uchar *)imageGray.data;
Image imageZbar(width, height, "Y800", raw, width * height);
scanner.scan(imageZbar); //扫描条码 dyxx5zxx
Image::SymbolIterator symbol = imageZbar.symbol_begin();
if (imageZbar.symbol_begin() == imageZbar.symbol_end())
{
cout << "查询条码失败,请检查图片!" << endl;
}
for (; symbol != imageZbar.symbol_end(); ++symbol)
{
cout << "类型:" << endl << symbol->get_type_name() << endl << endl;
cout << "条码:" << endl << symbol->get_data() << endl << endl;
}
imshow("Source Image", image);
waitKey();
imageZbar.set_data(NULL, 0);
return 0;
}
Zbar支持的条形码格式有:
EAN-13
UPC-A
UPC-E
EAN-8
Code128
Code39
Interleaved 2 / 5
EAN13.jpg / Code39.jpg / Code93.jpg / Code128.jpg