1 #ifndef __FINDER_PATTERN_FINDER_H__
2 #define __FINDER_PATTERN_FINDER_H__
5 * FinderPatternFinder.h
8 * Created by Christian Brunschen on 13/05/2008.
9 * Copyright 2008 Google Inc. All rights reserved.
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
24 #include "FinderPattern.h"
25 #include "FinderPatternInfo.h"
26 #include "../../common/Counted.h"
27 #include "../../MonochromeBitmapSource.h"
33 using namespace common;
35 class FinderPatternFinder {
37 static int CENTER_QUORUM;
39 static int MAX_MODULES;
41 Ref<MonochromeBitmapSource> image_;
42 vector<Ref<FinderPattern> > possibleCenters_;
45 static float centerFromEnd(valarray<int> &stateCount, int end);
46 static bool foundPatternCross(valarray<int> &stateCount);
48 float crossCheckVertical(size_t startI, size_t centerJ, int maxCount,
49 int originalStateCountTotal);
50 float crossCheckHorizontal(size_t startJ, size_t centerI, int maxCount,
51 int originalStateCountTotal);
53 bool handlePossibleCenter(valarray<int> &stateCount, size_t i, size_t j);
55 bool haveMultiplyConfirmedCenters();
56 ArrayRef<Ref<FinderPattern> > selectBestPatterns();
57 static ArrayRef<Ref<FinderPattern> > orderBestPatterns
58 (ArrayRef<Ref<FinderPattern> > patterns);
61 static float distance(Ref<ResultPoint> p1, Ref<ResultPoint> p2);
62 FinderPatternFinder(Ref<MonochromeBitmapSource> image);
63 Ref<FinderPatternInfo> find();
68 #endif // __FINDER_PATTERN_FINDER_H__