mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-21 17:13:09 +08:00
Replace more GenericVector by std::vector for src/ccstruct
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
122daf1d64
commit
c03ffda45a
@ -542,11 +542,10 @@ void TBLOB::GetPreciseBoundingBox(TBOX *precise_box) const {
|
||||
// x-coord starting at box.left().
|
||||
// Eg x_coords[0] is a collection of the x-coords of edges at y=bottom.
|
||||
// Eg x_coords[1] is a collection of the x-coords of edges at y=bottom + 1.
|
||||
void TBLOB::GetEdgeCoords(const TBOX &box, GenericVector<GenericVector<int>> *x_coords,
|
||||
GenericVector<GenericVector<int>> *y_coords) const {
|
||||
GenericVector<int> empty;
|
||||
x_coords->init_to_size(box.height(), empty);
|
||||
y_coords->init_to_size(box.width(), empty);
|
||||
void TBLOB::GetEdgeCoords(const TBOX &box, std::vector<GenericVector<int>> *x_coords,
|
||||
std::vector<GenericVector<int>> *y_coords) const {
|
||||
x_coords->resize(box.height());
|
||||
y_coords->resize(box.width());
|
||||
CollectEdges(box, nullptr, nullptr, x_coords, y_coords);
|
||||
// Sort the output vectors.
|
||||
for (int i = 0; i < x_coords->size(); ++i)
|
||||
@ -585,8 +584,8 @@ static void SegmentLLSQ(const FCOORD &pt1, const FCOORD &pt2, LLSQ *accumulator)
|
||||
// are clipped to ([0,x_limit], [0,y_limit]).
|
||||
// See GetEdgeCoords above for a description of x_coords, y_coords.
|
||||
static void SegmentCoords(const FCOORD &pt1, const FCOORD &pt2, int x_limit, int y_limit,
|
||||
GenericVector<GenericVector<int>> *x_coords,
|
||||
GenericVector<GenericVector<int>> *y_coords) {
|
||||
std::vector<GenericVector<int>> *x_coords,
|
||||
std::vector<GenericVector<int>> *y_coords) {
|
||||
FCOORD step(pt2);
|
||||
step -= pt1;
|
||||
int start = ClipToRange(IntCastRounded(std::min(pt1.x(), pt2.x())), 0, x_limit);
|
||||
@ -639,8 +638,8 @@ static void SegmentBBox(const FCOORD &pt1, const FCOORD &pt2, TBOX *bbox) {
|
||||
// indices into x_coords, y_coords are offset by box.botleft().
|
||||
static void CollectEdgesOfRun(const EDGEPT *startpt, const EDGEPT *lastpt, const DENORM &denorm,
|
||||
const TBOX &box, TBOX *bounding_box, LLSQ *accumulator,
|
||||
GenericVector<GenericVector<int>> *x_coords,
|
||||
GenericVector<GenericVector<int>> *y_coords) {
|
||||
std::vector<GenericVector<int>> *x_coords,
|
||||
std::vector<GenericVector<int>> *y_coords) {
|
||||
const C_OUTLINE *outline = startpt->src_outline;
|
||||
int x_limit = box.width() - 1;
|
||||
int y_limit = box.height() - 1;
|
||||
@ -727,8 +726,8 @@ static void CollectEdgesOfRun(const EDGEPT *startpt, const EDGEPT *lastpt, const
|
||||
// normalization.
|
||||
// For a description of x_coords, y_coords, see GetEdgeCoords above.
|
||||
void TBLOB::CollectEdges(const TBOX &box, TBOX *bounding_box, LLSQ *llsq,
|
||||
GenericVector<GenericVector<int>> *x_coords,
|
||||
GenericVector<GenericVector<int>> *y_coords) const {
|
||||
std::vector<GenericVector<int>> *x_coords,
|
||||
std::vector<GenericVector<int>> *y_coords) const {
|
||||
// Iterate the outlines.
|
||||
for (const TESSLINE *ol = outlines; ol != nullptr; ol = ol->next) {
|
||||
// Iterate the polygon.
|
||||
|
@ -391,8 +391,8 @@ struct TBLOB {
|
||||
// x-coord starting at box.left().
|
||||
// Eg x_coords[0] is a collection of the x-coords of edges at y=bottom.
|
||||
// Eg x_coords[1] is a collection of the x-coords of edges at y=bottom + 1.
|
||||
void GetEdgeCoords(const TBOX &box, GenericVector<GenericVector<int>> *x_coords,
|
||||
GenericVector<GenericVector<int>> *y_coords) const;
|
||||
void GetEdgeCoords(const TBOX &box, std::vector<GenericVector<int>> *x_coords,
|
||||
std::vector<GenericVector<int>> *y_coords) const;
|
||||
|
||||
TESSLINE *outlines; // List of outlines in blob.
|
||||
|
||||
@ -403,8 +403,8 @@ private: // TODO(rays) Someday the data members will be private too.
|
||||
// normalization.
|
||||
// For a description of x_coords, y_coords, see GetEdgeCoords above.
|
||||
void CollectEdges(const TBOX &box, TBOX *bounding_box, LLSQ *llsq,
|
||||
GenericVector<GenericVector<int>> *x_coords,
|
||||
GenericVector<GenericVector<int>> *y_coords) const;
|
||||
std::vector<GenericVector<int>> *x_coords,
|
||||
std::vector<GenericVector<int>> *y_coords) const;
|
||||
|
||||
private:
|
||||
// DENORM indicating the transformations that this blob has undergone so far.
|
||||
|
@ -153,8 +153,8 @@ void DENORM::SetupNormalization(const BLOCK *block, const FCOORD *rotation,
|
||||
// pre-initialized to be the same size as box. Each element will contain the
|
||||
// minimum of x and y run-length as shown above.
|
||||
static void ComputeRunlengthImage(const TBOX &box,
|
||||
const GenericVector<GenericVector<int>> &x_coords,
|
||||
const GenericVector<GenericVector<int>> &y_coords,
|
||||
const std::vector<GenericVector<int>> &x_coords,
|
||||
const std::vector<GenericVector<int>> &y_coords,
|
||||
GENERIC_2D_ARRAY<int> *minruns) {
|
||||
int width = box.width();
|
||||
int height = box.height();
|
||||
@ -264,8 +264,8 @@ static void ComputeEdgeDensityProfiles(const TBOX &box, const GENERIC_2D_ARRAY<i
|
||||
// See comments on the helper functions above for more details.
|
||||
void DENORM::SetupNonLinear(const DENORM *predecessor, const TBOX &box, float target_width,
|
||||
float target_height, float final_xshift, float final_yshift,
|
||||
const GenericVector<GenericVector<int>> &x_coords,
|
||||
const GenericVector<GenericVector<int>> &y_coords) {
|
||||
const std::vector<GenericVector<int>> &x_coords,
|
||||
const std::vector<GenericVector<int>> &y_coords) {
|
||||
Clear();
|
||||
predecessor_ = predecessor;
|
||||
// x_map_ and y_map_ store a mapping from input x and y coordinate to output
|
||||
|
@ -2,7 +2,6 @@
|
||||
* File: normalis.h (Formerly denorm.h)
|
||||
* Description: Code for the DENORM class.
|
||||
* Author: Ray Smith
|
||||
* Created: Thu Apr 23 09:22:43 BST 1992
|
||||
*
|
||||
* (C) Copyright 1992, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -20,6 +19,7 @@
|
||||
#ifndef NORMALIS_H
|
||||
#define NORMALIS_H
|
||||
|
||||
#include <vector>
|
||||
#include <tesseract/export.h>
|
||||
|
||||
struct Pix;
|
||||
@ -193,8 +193,8 @@ public:
|
||||
// The second-level vectors must all be sorted in ascending order.
|
||||
void SetupNonLinear(const DENORM *predecessor, const TBOX &box, float target_width,
|
||||
float target_height, float final_xshift, float final_yshift,
|
||||
const GenericVector<GenericVector<int>> &x_coords,
|
||||
const GenericVector<GenericVector<int>> &y_coords);
|
||||
const std::vector<GenericVector<int>> &x_coords,
|
||||
const std::vector<GenericVector<int>> &y_coords);
|
||||
|
||||
// Transforms the given coords one step forward to normalized space, without
|
||||
// using any block rotation or predecessor.
|
||||
|
@ -144,8 +144,8 @@ void Classify::SetupBLCNDenorms(const TBLOB &blob, bool nonlinear_norm, DENORM *
|
||||
128.0f, 128.0f);
|
||||
// Setup the denorm for character normalization.
|
||||
if (nonlinear_norm) {
|
||||
GenericVector<GenericVector<int>> x_coords;
|
||||
GenericVector<GenericVector<int>> y_coords;
|
||||
std::vector<GenericVector<int>> x_coords;
|
||||
std::vector<GenericVector<int>> y_coords;
|
||||
TBOX box;
|
||||
blob.GetPreciseBoundingBox(&box);
|
||||
box.pad(1, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user