QRCodeReader.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
  2. /*
  3. * QRCodeReader.cpp
  4. * zxing
  5. *
  6. * Created by Christian Brunschen on 20/05/2008.
  7. * Copyright 2008 ZXing authors All rights reserved.
  8. *
  9. * Licensed under the Apache License, Version 2.0 (the "License");
  10. * you may not use this file except in compliance with the License.
  11. * You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing, software
  16. * distributed under the License is distributed on an "AS IS" BASIS,
  17. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. * See the License for the specific language governing permissions and
  19. * limitations under the License.
  20. */
  21. #include <zxing/qrcode/QRCodeReader.h>
  22. #include <zxing/qrcode/detector/Detector.h>
  23. #include <iostream>
  24. namespace zxing {
  25. namespace qrcode {
  26. using namespace std;
  27. QRCodeReader::QRCodeReader() :decoder_() {
  28. }
  29. //TODO: see if any of the other files in the qrcode tree need tryHarder
  30. Ref<Result> QRCodeReader::decode(Ref<BinaryBitmap> image, DecodeHints hints) {
  31. Detector detector(image->getBlackMatrix());
  32. Ref<DetectorResult> detectorResult(detector.detect(hints));
  33. ArrayRef< Ref<ResultPoint> > points (detectorResult->getPoints());
  34. Ref<DecoderResult> decoderResult(decoder_.decode(detectorResult->getBits()));
  35. Ref<Result> result(
  36. new Result(decoderResult->getText(), decoderResult->getRawBytes(), points, BarcodeFormat::QR_CODE));
  37. return result;
  38. }
  39. QRCodeReader::~QRCodeReader() {
  40. }
  41. Decoder& QRCodeReader::getDecoder() {
  42. return decoder_;
  43. }
  44. }
  45. }