2011-11-16 13:40:46 +00:00
|
|
|
#ifndef __WHITERECTANGLEDETECTOR_H__
|
|
|
|
#define __WHITERECTANGLEDETECTOR_H__
|
|
|
|
|
|
|
|
/*
|
|
|
|
* WhiteRectangleDetector.h
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Created by Luiz Silva on 09/02/2010.
|
|
|
|
* Copyright 2010 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 <vector>
|
|
|
|
#include <zxing/ReaderException.h>
|
|
|
|
#include <zxing/ResultPoint.h>
|
|
|
|
#include <zxing/common/BitMatrix.h>
|
|
|
|
#include <zxing/common/Counted.h>
|
|
|
|
#include <zxing/ResultPoint.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace zxing {
|
|
|
|
|
|
|
|
class WhiteRectangleDetector : public Counted {
|
|
|
|
private:
|
|
|
|
static int INIT_SIZE;
|
|
|
|
static int CORR;
|
|
|
|
Ref<BitMatrix> image_;
|
|
|
|
int width_;
|
|
|
|
int height_;
|
2012-05-13 20:47:37 +00:00
|
|
|
int leftInit_;
|
|
|
|
int rightInit_;
|
|
|
|
int downInit_;
|
|
|
|
int upInit_;
|
2011-11-16 13:40:46 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
WhiteRectangleDetector(Ref<BitMatrix> image);
|
2012-05-13 20:47:37 +00:00
|
|
|
WhiteRectangleDetector(Ref<BitMatrix> image, int initSize, int x, int y);
|
2011-11-16 13:40:46 +00:00
|
|
|
std::vector<Ref<ResultPoint> > detect();
|
|
|
|
|
|
|
|
private:
|
|
|
|
int round(float a);
|
|
|
|
Ref<ResultPoint> getBlackPointOnSegment(float aX, float aY, float bX, float bY);
|
|
|
|
int distanceL2(float aX, float aY, float bX, float bY);
|
|
|
|
std::vector<Ref<ResultPoint> > centerEdges(Ref<ResultPoint> y, Ref<ResultPoint> z,
|
|
|
|
Ref<ResultPoint> x, Ref<ResultPoint> t);
|
|
|
|
bool containsBlackPoint(int a, int b, int fixed, bool horizontal);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|