我正在使用OpenCV和Zxing,我想添加2d代码扫描.我有几种类型的图像可以发送.可能最好的是Bitmat(另一种选择是OpenCV Mat).
看起来你曾经能够像这样转换:
Bitmap frame = //this is the frame coming in
LuminanceSource source = new RGBLuminanceSource(frame);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
//then I can use reader.decode(bitmap) to decode the BinaryBitmap
Run Code Online (Sandbox Code Playgroud)
但是,RGBLuminaceSource看起来不再需要位图作为输入.那么我怎样才能将输入图像转换为BinaryBitmap ???
好的,我相信我已经取得了一些进展,但我仍然遇到了问题.我想我有代码将Bitmap转换为正确的格式,但我现在得到一个arrayIndexOutOfBounds
public void zxing(){
Bitmap bMap = Bitmap.createBitmap(frame.width(), frame.height(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(frame, bMap);
byte[] array = BitmapToArray(bMap);
LuminanceSource source = new PlanarYUVLuminanceSource(array, bMap.getWidth(), bMap.getHeight(), 0, 0, bMap.getWidth(), bMap.getHeight(), false);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new DataMatrixReader();
String sResult = "";
try { …Run Code Online (Sandbox Code Playgroud)