如何使用Zxing C++解码数据

4
我遇到了一些使用Zxing项目中的C++源代码的问题。我从https://code.google.com/p/zxing/downloads/list下载了整个项目,只提取了cpp文件(核心和命令行界面)。
我只是想要一个像这样的方法:
decode(byte[] dataToDecode, int widthFrame, int heightFrame)

但是我真的不知道该如何做(我对c++和Zxing项目很陌生)。

我在网上做了一些研究,并找到了http://wiki.ssrrsummerschool.org/doku.php?id=robocup2012:qrcode-cppexample,这正是我所需要的。

不幸的是,Zxing核心已经更改,现在我遇到了一些由于ArrayRef引起的问题。

有没有一种简单的方法来解码一个字节数组(RGB)并返回一个结果字符串?

真的非常感谢您的帮助。

1个回答

4
通过修改BufferBitmapSource类示例(http://wiki.ssrrsummerschool.org/doku.php?id=robocup2012:qrcode-cppexample),根据Zxing库2.2解决了问题。

BufferBitmapSource.hpp:

#include <zxing/LuminanceSource.h>
#include <stdio.h>
#include <stdlib.h>
using namespace zxing; 
namespace qrviddec {

class BufferBitmapSource : public LuminanceSource {
private:
  ArrayRef<char>* buffer;

public:
  BufferBitmapSource(int inWidth, int inHeight, ArrayRef<char> buffer);
  ~BufferBitmapSource(); 

  ArrayRef<char> getRow(int y, ArrayRef<char> row) const;
  ArrayRef<char> getMatrix() const;
}; 
}

BufferBitmapSource.cpp 内容过长,如有需要可提出请求。

test.cpp (main)

测试程序.cpp(主要文件)

...
// Convert the buffer to something that the library understands.
ArrayRef<char> data((char*)buffer, width*height);
Ref<LuminanceSource> source (new BufferBitmapSource(width, height, data));
...

嗨@hico,我对那个BufferBitmapSource.cpp文件感兴趣。你能发给我吗?谢谢! - makeMonday

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接