This is the sample program that can see the decode result of barcode data on Watson IoT.
Dependencies: AsciiFont DisplayApp GR-PEACH_video LCD_shield_config LWIPBP3595Interface_STA_for_mbed-os USBDevice
zxing_lib/ImageReaderSource.h@0:7d720671e6dc, 2016-11-10 (annotated)
- Committer:
- Osamu Nakamura
- Date:
- Thu Nov 10 20:04:48 2016 +0900
- Revision:
- 0:7d720671e6dc
Initial Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Osamu Nakamura |
0:7d720671e6dc | 1 | // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- |
Osamu Nakamura |
0:7d720671e6dc | 2 | #ifndef __IMAGE_READER_SOURCE_H_ |
Osamu Nakamura |
0:7d720671e6dc | 3 | #define __IMAGE_READER_SOURCE_H_ |
Osamu Nakamura |
0:7d720671e6dc | 4 | /* |
Osamu Nakamura |
0:7d720671e6dc | 5 | * Copyright 2010-2011 ZXing authors |
Osamu Nakamura |
0:7d720671e6dc | 6 | * |
Osamu Nakamura |
0:7d720671e6dc | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Osamu Nakamura |
0:7d720671e6dc | 8 | * you may not use this file except in compliance with the License. |
Osamu Nakamura |
0:7d720671e6dc | 9 | * You may obtain a copy of the License at |
Osamu Nakamura |
0:7d720671e6dc | 10 | * |
Osamu Nakamura |
0:7d720671e6dc | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Osamu Nakamura |
0:7d720671e6dc | 12 | * |
Osamu Nakamura |
0:7d720671e6dc | 13 | * Unless required by applicable law or agreed to in writing, software |
Osamu Nakamura |
0:7d720671e6dc | 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
Osamu Nakamura |
0:7d720671e6dc | 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Osamu Nakamura |
0:7d720671e6dc | 16 | * See the License for the specific language governing permissions and |
Osamu Nakamura |
0:7d720671e6dc | 17 | * limitations under the License. |
Osamu Nakamura |
0:7d720671e6dc | 18 | */ |
Osamu Nakamura |
0:7d720671e6dc | 19 | |
Osamu Nakamura |
0:7d720671e6dc | 20 | #include "mbed.h" |
Osamu Nakamura |
0:7d720671e6dc | 21 | #include <iostream> |
Osamu Nakamura |
0:7d720671e6dc | 22 | #include <fstream> |
Osamu Nakamura |
0:7d720671e6dc | 23 | #include <string> |
Osamu Nakamura |
0:7d720671e6dc | 24 | #include <zxing/LuminanceSource.h> |
Osamu Nakamura |
0:7d720671e6dc | 25 | #include <zxing/common/Counted.h> |
Osamu Nakamura |
0:7d720671e6dc | 26 | #include <zxing/Binarizer.h> |
Osamu Nakamura |
0:7d720671e6dc | 27 | #include <zxing/MultiFormatReader.h> |
Osamu Nakamura |
0:7d720671e6dc | 28 | #include <zxing/Result.h> |
Osamu Nakamura |
0:7d720671e6dc | 29 | #include <zxing/ReaderException.h> |
Osamu Nakamura |
0:7d720671e6dc | 30 | #include <zxing/common/GlobalHistogramBinarizer.h> |
Osamu Nakamura |
0:7d720671e6dc | 31 | #include <zxing/common/HybridBinarizer.h> |
Osamu Nakamura |
0:7d720671e6dc | 32 | #include <exception> |
Osamu Nakamura |
0:7d720671e6dc | 33 | #include <zxing/Exception.h> |
Osamu Nakamura |
0:7d720671e6dc | 34 | #include <zxing/common/IllegalArgumentException.h> |
Osamu Nakamura |
0:7d720671e6dc | 35 | #include <zxing/BinaryBitmap.h> |
Osamu Nakamura |
0:7d720671e6dc | 36 | #include <zxing/DecodeHints.h> |
Osamu Nakamura |
0:7d720671e6dc | 37 | |
Osamu Nakamura |
0:7d720671e6dc | 38 | #include <zxing/qrcode/QRCodeReader.h> |
Osamu Nakamura |
0:7d720671e6dc | 39 | #include <zxing/multi/qrcode/QRCodeMultiReader.h> |
Osamu Nakamura |
0:7d720671e6dc | 40 | #include <zxing/multi/ByQuadrantReader.h> |
Osamu Nakamura |
0:7d720671e6dc | 41 | #include <zxing/multi/MultipleBarcodeReader.h> |
Osamu Nakamura |
0:7d720671e6dc | 42 | #include <zxing/multi/GenericMultipleBarcodeReader.h> |
Osamu Nakamura |
0:7d720671e6dc | 43 | |
Osamu Nakamura |
0:7d720671e6dc | 44 | using std::string; |
Osamu Nakamura |
0:7d720671e6dc | 45 | using std::ostringstream; |
Osamu Nakamura |
0:7d720671e6dc | 46 | using zxing::Ref; |
Osamu Nakamura |
0:7d720671e6dc | 47 | using zxing::ArrayRef; |
Osamu Nakamura |
0:7d720671e6dc | 48 | using zxing::LuminanceSource; |
Osamu Nakamura |
0:7d720671e6dc | 49 | |
Osamu Nakamura |
0:7d720671e6dc | 50 | using namespace std; |
Osamu Nakamura |
0:7d720671e6dc | 51 | using namespace zxing; |
Osamu Nakamura |
0:7d720671e6dc | 52 | using namespace zxing::multi; |
Osamu Nakamura |
0:7d720671e6dc | 53 | using namespace zxing::qrcode; |
Osamu Nakamura |
0:7d720671e6dc | 54 | |
Osamu Nakamura |
0:7d720671e6dc | 55 | |
Osamu Nakamura |
0:7d720671e6dc | 56 | class ImageReaderSource : public zxing::LuminanceSource { |
Osamu Nakamura |
0:7d720671e6dc | 57 | private: |
Osamu Nakamura |
0:7d720671e6dc | 58 | typedef LuminanceSource Super; |
Osamu Nakamura |
0:7d720671e6dc | 59 | |
Osamu Nakamura |
0:7d720671e6dc | 60 | const zxing::ArrayRef<char> image; |
Osamu Nakamura |
0:7d720671e6dc | 61 | const int comps; |
Osamu Nakamura |
0:7d720671e6dc | 62 | |
Osamu Nakamura |
0:7d720671e6dc | 63 | char convertPixel(const char* pixel) const; |
Osamu Nakamura |
0:7d720671e6dc | 64 | |
Osamu Nakamura |
0:7d720671e6dc | 65 | public: |
Osamu Nakamura |
0:7d720671e6dc | 66 | static zxing::Ref<LuminanceSource> create(char* buf, int buf_size, int width, int height); |
Osamu Nakamura |
0:7d720671e6dc | 67 | |
Osamu Nakamura |
0:7d720671e6dc | 68 | ImageReaderSource(zxing::ArrayRef<char> image, int width, int height, int comps); |
Osamu Nakamura |
0:7d720671e6dc | 69 | |
Osamu Nakamura |
0:7d720671e6dc | 70 | zxing::ArrayRef<char> getRow(int y, zxing::ArrayRef<char> row) const; |
Osamu Nakamura |
0:7d720671e6dc | 71 | zxing::ArrayRef<char> getMatrix() const; |
Osamu Nakamura |
0:7d720671e6dc | 72 | }; |
Osamu Nakamura |
0:7d720671e6dc | 73 | |
Osamu Nakamura |
0:7d720671e6dc | 74 | extern int ex_decode(uint8_t* buf, int buf_size, int width, int height, vector<Ref<Result> > * results); |
Osamu Nakamura |
0:7d720671e6dc | 75 | |
Osamu Nakamura |
0:7d720671e6dc | 76 | |
Osamu Nakamura |
0:7d720671e6dc | 77 | #endif /* __IMAGE_READER_SOURCE_H_ */ |