[英]C++ zbar library - unresolved external symbol
I ran the following code for getting code feature for barcode using zbar library and set the properties for the project.我运行以下代码以使用 zbar 库获取条形码的代码功能并设置项目的属性。 I am getting errors such as unresolved external symbol error (LNK2019).
我收到错误,例如未解决的外部符号错误 (LNK2019)。 How to resolve this error?
如何解决此错误? The code for my program and the errors are attached below
我的程序代码和错误附在下面
#include <opencv2/opencv.hpp>
#include <C:/Program Files/ZBar/include/zbar.h>
using namespace cv;
using namespace std;
using namespace zbar;
typedef struct
{
string type;
string data;
vector <Point> location;
} decodedObject;
// Find and decode barcodes and QR codes
void decode(Mat& im, vector<decodedObject>& decodedObjects)
{
// Create zbar scanner
ImageScanner scanner;
// Configure scanner
scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);
// Convert image to grayscale
Mat imGray;
cvtColor(im, imGray, COLOR_BGR2GRAY);
// Wrap image data in a zbar image
Image image(im.cols, im.rows, "Y800", (uchar*)imGray.data, im.cols * im.rows);
// Scan the image for barcodes and QRCodes
int n = scanner.scan(image);
// Print results
for (Image::SymbolIterator symbol = image.symbol_begin(); symbol != image.symbol_end(); ++symbol)
{
decodedObject obj;
obj.type = symbol->get_type_name();
obj.data = symbol->get_data();
// Print type and data
cout << "Type : " << obj.type << endl;`
cout << "Data : " << obj.data << endl << endl;
// Obtain location
for (int i = 0; i < symbol->get_location_size(); i++)
{
obj.location.push_back(Point(symbol->get_location_x(i), symbol->get_location_y(i)));
}
decodedObjects.push_back(obj);
}
}
// Display barcode and QR code location
void display(Mat& im, vector<decodedObject>& decodedObjects)
{
// Loop over all decoded objects
for (int i = 0; i < decodedObjects.size(); i++)
{
vector<Point> points = decodedObjects[i].location;
vector<Point> hull;
// If the points do not form a quad, find convex hull
if (points.size() > 4)
convexHull(points, hull);
else
hull = points;
// Number of points in the convex hull
int n = hull.size();
for (int j = 0; j < n; j++)
{
line(im, hull[j], hull[(j + 1) % n], Scalar(255, 0, 0), 3);
}
}
// Display results
imshow("Results", im);
waitKey(0);
}
int main(int argc, char* argv[])
{
// Read image
Mat im = imread("zbar-test.jpg");
// Variable for decoded objects
vector<decodedObject> decodedObjects;
// Find and decode barcodes and QR codes
decode(im, decodedObjects);
// Display location
display(im, decodedObjects);
return EXIT_SUCCESS;
}
The errors are as follows,错误如下,
Your code runs OK!您的代码运行正常! You just need to refer the Zbar library on: Project Properties -> Linker -> Input -> C:\\opencv\\Zbar\\lib\\libzbar64-0.lib (for example)
您只需要在以下位置引用 Zbar 库:项目属性 -> 链接器 -> 输入 -> C:\\opencv\\Zbar\\lib\\libzbar64-0.lib(例如)
With kind regards, PFG亲切的问候, PFG
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.