using namespace std;
Ref<Result> QRCodeReader::decode(Ref<MonochromeBitmapSource> image) {
+#ifdef DEBUG
cout << "decoding image " << image.object_ << ":\n" << flush;
+#endif
+
Detector detector(image);
+
+#ifdef DEBUG
cout << "(1) created detector " << &detector << "\n" << flush;
+#endif
+
Ref<DetectorResult> detectorResult(detector.detect());
+#ifdef DEBUG
cout << "(2) detected, have detectorResult " << detectorResult.object_ << "\n" << flush;
+#endif
+
ArrayRef<Ref<ResultPoint> > points(detectorResult->getPoints());
+
+#ifdef DEBUG
cout << "(3) extracted points " << &points << "\n" << flush;
cout << "found " << points->size() << " points:\n";
for (size_t i = 0; i < points->size(); i++) {
}
cout << "bits:\n";
cout << *(detectorResult->getBits()) << "\n";
+#endif
+
Ref<DecoderResult> decoderResult(decoder_.decode(detectorResult->getBits()));
+#ifdef DEBUG
cout << "(4) decoded, have decoderResult " << decoderResult.object_ << "\n" << flush;
+#endif
+
Ref<Result> result(new Result(decoderResult->getText(),
decoderResult->getRawBytes(),
points,
BarcodeFormat_QR_CODE));
+#ifdef DEBUG
cout << "(5) created result " << result.object_ << ", returning\n" << flush;
+#endif
+
return result;
}