5 * Created by Christian Brunschen on 20/05/2008.
6 * Copyright 2008 ZXing authors All rights reserved.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #include "QRCodeReader.h"
22 #include "detector/Detector.h"
28 using namespace decoder;
29 using namespace detector;
30 using namespace common;
33 Ref<Result> QRCodeReader::decode(Ref<MonochromeBitmapSource> image) {
34 cout << "decoding image " << image.object_ << ":\n" << flush;
35 Detector detector(image);
36 cout << "(1) created detector " << &detector << "\n" << flush;
37 Ref<DetectorResult> detectorResult(detector.detect());
38 cout << "(2) detected, have detectorResult " << detectorResult.object_ << "\n" << flush;
39 ArrayRef<Ref<ResultPoint> > points(detectorResult->getPoints());
40 cout << "(3) extracted points " << &points << "\n" << flush;
41 cout << "found " << points->size() << " points:\n";
42 for (size_t i = 0; i < points->size(); i++) {
43 cout << " " << points[i]->getX() << "," << points[i]->getY() << "\n";
46 cout << *(detectorResult->getBits()) << "\n";
47 Ref<DecoderResult> decoderResult(decoder_.decode(detectorResult->getBits()));
48 cout << "(4) decoded, have decoderResult " << decoderResult.object_ << "\n" << flush;
49 Ref<Result> result(new Result(decoderResult->getText(),
50 decoderResult->getRawBytes(),
52 BarcodeFormat_QR_CODE));
53 cout << "(5) created result " << result.object_ << ", returning\n" << flush;
57 QRCodeReader::~QRCodeReader() {