Skip to content

Commit

Permalink
Added std:: to vector
Browse files Browse the repository at this point in the history
  • Loading branch information
theraysmith committed Nov 30, 2016
1 parent 53003f9 commit 9d90567
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
6 changes: 3 additions & 3 deletions lstm/tfnetwork.cpp
Expand Up @@ -69,7 +69,7 @@ bool TFNetwork::DeSerialize(bool swap, TFile* fp) {
void TFNetwork::Forward(bool debug, const NetworkIO& input,
const TransposedArray* input_transpose,
NetworkScratch* scratch, NetworkIO* output) {
vector<std::pair<string, Tensor>> tf_inputs;
std::vector<std::pair<string, Tensor>> tf_inputs;
int depth = input_shape_.depth();
ASSERT_HOST(depth == input.NumFeatures());
// TODO(rays) Allow batching. For now batch_size = 1.
Expand Down Expand Up @@ -104,8 +104,8 @@ void TFNetwork::Forward(bool debug, const NetworkIO& input,
*eigen_htensor.data() = stride_map.Size(FD_HEIGHT);
tf_inputs.emplace_back(model_proto_.image_heights(), height_tensor);
}
vector<string> target_layers = {model_proto_.output_layer()};
vector<Tensor> outputs;
std::vector<string> target_layers = {model_proto_.output_layer()};
std::vector<Tensor> outputs;
Status s = session_->Run(tf_inputs, target_layers, {}, &outputs);
ASSERT_HOST(s.ok());
ASSERT_HOST(outputs.size() == 1);
Expand Down
25 changes: 14 additions & 11 deletions training/boxchar.cpp
Expand Up @@ -49,7 +49,8 @@ void BoxChar::AddBox(int x, int y, int width, int height) {
}

/* static */
void BoxChar::TranslateBoxes(int xshift, int yshift, vector<BoxChar*>* boxes) {
void BoxChar::TranslateBoxes(int xshift, int yshift,
std::vector<BoxChar*>* boxes) {
for (int i = 0; i < boxes->size(); ++i) {
BOX* box = (*boxes)[i]->box_;
if (box != NULL) {
Expand All @@ -62,7 +63,7 @@ void BoxChar::TranslateBoxes(int xshift, int yshift, vector<BoxChar*>* boxes) {
// Prepares for writing the boxes to a file by inserting newlines, spaces,
// and re-ordering so the boxes are strictly left-to-right.
/* static */
void BoxChar::PrepareToWrite(vector<BoxChar*>* boxes) {
void BoxChar::PrepareToWrite(std::vector<BoxChar*>* boxes) {
bool rtl_rules = ContainsMostlyRTL(*boxes);
bool vertical_rules = MostlyVertical(*boxes);
InsertNewlines(rtl_rules, vertical_rules, boxes);
Expand All @@ -78,7 +79,7 @@ void BoxChar::PrepareToWrite(vector<BoxChar*>* boxes) {
// Inserts newline (tab) characters into the vector at newline positions.
/* static */
void BoxChar::InsertNewlines(bool rtl_rules, bool vertical_rules,
vector<BoxChar*>* boxes) {
std::vector<BoxChar*>* boxes) {
int prev_i = -1;
int max_shift = 0;
for (int i = 0; i < boxes->size(); ++i) {
Expand Down Expand Up @@ -141,7 +142,7 @@ void BoxChar::InsertNewlines(bool rtl_rules, bool vertical_rules,
// Converts NULL boxes to space characters, with appropriate bounding boxes.
/* static */
void BoxChar::InsertSpaces(bool rtl_rules, bool vertical_rules,
vector<BoxChar*>* boxes) {
std::vector<BoxChar*>* boxes) {
// After InsertNewlines, any remaining null boxes are not newlines, and are
// singletons, so add a box to each remaining null box.
for (int i = 1; i + 1 < boxes->size(); ++i) {
Expand Down Expand Up @@ -197,7 +198,7 @@ void BoxChar::InsertSpaces(bool rtl_rules, bool vertical_rules,

// Reorders text in a right-to-left script in left-to-right order.
/* static */
void BoxChar::ReorderRTLText(vector<BoxChar*>* boxes) {
void BoxChar::ReorderRTLText(std::vector<BoxChar*>* boxes) {
// After adding newlines and spaces, this task is simply a matter of sorting
// by left each group of boxes between newlines.
BoxCharPtrSort sorter;
Expand All @@ -211,7 +212,7 @@ void BoxChar::ReorderRTLText(vector<BoxChar*>* boxes) {

// Returns true if the vector contains mostly RTL characters.
/* static */
bool BoxChar::ContainsMostlyRTL(const vector<BoxChar*>& boxes) {
bool BoxChar::ContainsMostlyRTL(const std::vector<BoxChar*>& boxes) {
int num_rtl = 0, num_ltr = 0;
for (int i = 0; i < boxes.size(); ++i) {
// Convert the unichar to UTF32 representation
Expand Down Expand Up @@ -240,7 +241,7 @@ bool BoxChar::ContainsMostlyRTL(const vector<BoxChar*>& boxes) {

// Returns true if the text is mostly laid out vertically.
/* static */
bool BoxChar::MostlyVertical(const vector<BoxChar*>& boxes) {
bool BoxChar::MostlyVertical(const std::vector<BoxChar*>& boxes) {
inT64 total_dx = 0, total_dy = 0;
for (int i = 1; i < boxes.size(); ++i) {
if (boxes[i - 1]->box_ != NULL && boxes[i]->box_ != NULL &&
Expand All @@ -259,7 +260,7 @@ bool BoxChar::MostlyVertical(const vector<BoxChar*>& boxes) {

// Returns the total length of all the strings in the boxes.
/* static */
int BoxChar::TotalByteLength(const vector<BoxChar*>& boxes) {
int BoxChar::TotalByteLength(const std::vector<BoxChar*>& boxes) {
int total_length = 0;
for (int i = 0; i < boxes.size(); ++i) total_length += boxes[i]->ch_.size();
return total_length;
Expand All @@ -269,7 +270,8 @@ int BoxChar::TotalByteLength(const vector<BoxChar*>& boxes) {
// The rotation is in radians clockwise about the given center.
/* static */
void BoxChar::RotateBoxes(float rotation, int xcenter, int ycenter,
int start_box, int end_box, vector<BoxChar*>* boxes) {
int start_box, int end_box,
std::vector<BoxChar*>* boxes) {
Boxa* orig = boxaCreate(0);
for (int i = start_box; i < end_box; ++i) {
BOX* box = (*boxes)[i]->box_;
Expand All @@ -289,13 +291,14 @@ void BoxChar::RotateBoxes(float rotation, int xcenter, int ycenter,
const int kMaxLineLength = 1024;
/* static */
void BoxChar::WriteTesseractBoxFile(const string& filename, int height,
const vector<BoxChar*>& boxes) {
const std::vector<BoxChar*>& boxes) {
string output = GetTesseractBoxStr(height, boxes);
File::WriteStringToFileOrDie(output, filename);
}

/* static */
string BoxChar::GetTesseractBoxStr(int height, const vector<BoxChar*>& boxes) {
string BoxChar::GetTesseractBoxStr(int height,
const std::vector<BoxChar*>& boxes) {
string output;
char buffer[kMaxLineLength];
for (int i = 0; i < boxes.size(); ++i) {
Expand Down
24 changes: 12 additions & 12 deletions training/pango_font_info.h
Expand Up @@ -80,7 +80,7 @@ class PangoFontInfo {
// If true, returns individual graphemes. Any whitespace characters in the
// original string are also included in the list.
bool CanRenderString(const char* utf8_word, int len,
vector<string>* graphemes) const;
std::vector<string>* graphemes) const;
bool CanRenderString(const char* utf8_word, int len) const;

// Retrieves the x_bearing and x_advance for the given utf8 character in the
Expand Down Expand Up @@ -169,29 +169,29 @@ class FontUtils {
// best_match is not NULL, the closest matching font is returned there.
static bool IsAvailableFont(const char* font_desc, string* best_match);
// Outputs description names of available fonts.
static const vector<string>& ListAvailableFonts();
static const std::vector<string>& ListAvailableFonts();

// Picks font among available fonts that covers and can render the given word,
// and returns the font description name and the decomposition of the word to
// graphemes. Returns false if no suitable font was found.
static bool SelectFont(const char* utf8_word, const int utf8_len,
string* font_name, vector<string>* graphemes);
string* font_name, std::vector<string>* graphemes);

// Picks font among all_fonts that covers and can render the given word,
// and returns the font description name and the decomposition of the word to
// graphemes. Returns false if no suitable font was found.
static bool SelectFont(const char* utf8_word, const int utf8_len,
const vector<string>& all_fonts,
string* font_name, vector<string>* graphemes);
const std::vector<string>& all_fonts,
string* font_name, std::vector<string>* graphemes);

// Returns a bitmask where the value of true at index 'n' implies that unicode
// value 'n' is renderable by at least one available font.
static void GetAllRenderableCharacters(vector<bool>* unichar_bitmap);
static void GetAllRenderableCharacters(std::vector<bool>* unichar_bitmap);
// Variant of the above function that inspects only the provided font names.
static void GetAllRenderableCharacters(const vector<string>& font_names,
vector<bool>* unichar_bitmap);
static void GetAllRenderableCharacters(const std::vector<string>& font_names,
std::vector<bool>* unichar_bitmap);
static void GetAllRenderableCharacters(const string& font_name,
vector<bool>* unichar_bitmap);
std::vector<bool>* unichar_bitmap);

// NOTE: The following utilities were written to be backward compatible with
// StringRender.
Expand All @@ -204,7 +204,7 @@ class FontUtils {
// The return string is a list of the acceptable fonts that were used.
static string BestFonts(
const TessHashMap<char32, inT64>& ch_map,
vector<std::pair<const char*, vector<bool> > >* font_flag);
std::vector<std::pair<const char*, std::vector<bool> > >* font_flag);

// FontScore returns the weighted renderability score of the given
// hash map character table in the given font. The unweighted score
Expand All @@ -213,13 +213,13 @@ class FontUtils {
// corresponding character (in order of iterating ch_map) can be rendered.
static int FontScore(const TessHashMap<char32, inT64>& ch_map,
const string& fontname, int* raw_score,
vector<bool>* ch_flags);
std::vector<bool>* ch_flags);

// PangoFontInfo is reinitialized, so clear the static list of fonts.
static void ReInit();

private:
static vector<string> available_fonts_; // cache list
static std::vector<string> available_fonts_; // cache list
};
} // namespace tesseract

Expand Down
8 changes: 4 additions & 4 deletions training/stringrenderer.h
Expand Up @@ -135,7 +135,7 @@ class StringRenderer {

// Get the boxchars of all clusters rendered thus far (or since the last call
// to ClearBoxes()).
const vector<BoxChar*>& GetBoxes() const;
const std::vector<BoxChar*>& GetBoxes() const;
// Get the rendered page bounding boxes of all pages created thus far (or
// since last call to ClearBoxes()).
Boxa* GetPageBoxes() const;
Expand Down Expand Up @@ -171,8 +171,8 @@ class StringRenderer {
void SetWordUnderlineAttributes(const string& page_text);
// Compute bounding boxes around grapheme clusters.
void ComputeClusterBoxes();
void CorrectBoxPositionsToLayout(vector<BoxChar*>* boxchars);
bool GetClusterStrings(vector<string>* cluster_text);
void CorrectBoxPositionsToLayout(std::vector<BoxChar*>* boxchars);
bool GetClusterStrings(std::vector<string>* cluster_text);
int FindFirstPageBreakOffset(const char* text, int text_length);

PangoFontInfo font_;
Expand Down Expand Up @@ -204,7 +204,7 @@ class StringRenderer {
int page_;
// Boxes and associated text for all pages rendered with RenderToImage() since
// the last call to ClearBoxes().
vector<BoxChar*> boxchars_;
std::vector<BoxChar*> boxchars_;
int box_padding_;
// Bounding boxes for pages since the last call to ClearBoxes().
Boxa* page_boxes_;
Expand Down

0 comments on commit 9d90567

Please sign in to comment.