// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __DETECTOR_H__ #define __DETECTOR_H__ /* * Detector.h * zxing * * Created by Luiz Silva on 09/02/2010. * Copyright 2010 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. */ #include #include #include #include #include namespace zxing { namespace datamatrix { class ResultPointsAndTransitions: public Counted { private: Ref to_; Ref from_; int transitions_; public: ResultPointsAndTransitions(); ResultPointsAndTransitions(Ref from, Ref to, int transitions); Ref getFrom(); Ref getTo(); int getTransitions(); }; class Detector: public Counted { private: Ref image_; protected: Ref sampleGrid(Ref image, int dimensionX, int dimensionY, Ref transform); void insertionSort(std::vector >& vector); Ref correctTopRightRectangular(Ref bottomLeft, Ref bottomRight, Ref topLeft, Ref topRight, int dimensionTop, int dimensionRight); Ref correctTopRight(Ref bottomLeft, Ref bottomRight, Ref topLeft, Ref topRight, int dimension); bool isValid(Ref p); int distance(Ref a, Ref b); Ref transitionsBetween(Ref from, Ref to); int min(int a, int b) { return a > b ? b : a; } /** * Ends up being a bit faster than round(). This merely rounds its * argument to the nearest int, where x.5 rounds up. */ int round(float d) { return (int) (d + 0.5f); } public: Ref getImage(); Detector(Ref image); virtual Ref createTransform(Ref topLeft, Ref topRight, Ref bottomLeft, Ref bottomRight, int dimensionX, int dimensionY); Ref detect(); private: int compare(Ref a, Ref b); }; } } #endif // __DETECTOR_H__