// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- /* * Detector.h * zxing * * Created by Lukas Stabe on 08/02/2012. * Copyright 2012 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __ZXING_AZTEC_DETECTOR_DETECTOR_H__ #define __ZXING_AZTEC_DETECTOR_DETECTOR_H__ #include #include #include #include #include #include namespace zxing { namespace aztec { class Point : public Counted { private: const int x; const int y; public: Ref toResultPoint() { return Ref(new ResultPoint(float(x), float(y))); } Point(int ax, int ay) : x(ax), y(ay) {} int getX() const { return x; } int getY() const { return y; } }; class Detector : public Counted { private: Ref image_; bool compact_; int nbLayers_; int nbDataBlocks_; int nbCenterLayers_; int shift_; void extractParameters(std::vector > bullEyeCornerPoints); ArrayRef< Ref > getMatrixCornerPoints(std::vector > bullEyeCornerPoints); static void correctParameterData(Ref parameterData, bool compact); std::vector > getBullEyeCornerPoints(Ref pCenter); Ref getMatrixCenter(); Ref sampleGrid(Ref image, Ref topLeft, Ref bottomLeft, Ref bottomRight, Ref topRight); void getParameters(Ref parameterData); Ref sampleLine(Ref p1, Ref p2, int size); bool isWhiteOrBlackRectangle(Ref p1, Ref p2, Ref p3, Ref p4); int getColor(Ref p1, Ref p2); Ref getFirstDifferent(Ref init, bool color, int dx, int dy); bool isValid(int x, int y); static float distance(Ref a, Ref b); public: Detector(Ref image); Ref detect(); }; } } #endif