Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos in several files #14812

Merged
merged 2 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 30 additions & 29 deletions deploy/android_demo/app/src/main/cpp/ocr_clipper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ void PolyTree::Clear() {
for (PolyNodes::size_type i = 0; i < AllNodes.size(); ++i)
delete AllNodes[i];
AllNodes.resize(0);
Childs.resize(0);
Children.resize(0);
}
//------------------------------------------------------------------------------

PolyNode *PolyTree::GetFirst() const {
if (!Childs.empty())
return Childs[0];
if (!Children.empty())
return Children[0];
else
return 0;
}
Expand All @@ -161,7 +161,7 @@ PolyNode *PolyTree::GetFirst() const {
int PolyTree::Total() const {
int result = (int)AllNodes.size();
// with negative offsets, ignore the hidden outer polygon ...
if (result > 0 && Childs[0] != AllNodes[0])
if (result > 0 && Children[0] != AllNodes[0])
result--;
return result;
}
Expand All @@ -173,20 +173,20 @@ int PolyTree::Total() const {
PolyNode::PolyNode() : Parent(0), Index(0), m_IsOpen(false) {}
//------------------------------------------------------------------------------

int PolyNode::ChildCount() const { return (int)Childs.size(); }
int PolyNode::ChildCount() const { return (int)Children.size(); }
//------------------------------------------------------------------------------

void PolyNode::AddChild(PolyNode &child) {
unsigned cnt = (unsigned)Childs.size();
Childs.push_back(&child);
unsigned cnt = (unsigned)Children.size();
Children.push_back(&child);
child.Parent = this;
child.Index = cnt;
}
//------------------------------------------------------------------------------

PolyNode *PolyNode::GetNext() const {
if (!Childs.empty())
return Childs[0];
if (!Children.empty())
return Children[0];
else
return GetNextSiblingUp();
}
Expand All @@ -195,10 +195,10 @@ PolyNode *PolyNode::GetNext() const {
PolyNode *PolyNode::GetNextSiblingUp() const {
if (!Parent) // protects against PolyTree.GetNextSiblingUp()
return 0;
else if (Index == Parent->Childs.size() - 1)
else if (Index == Parent->Children.size() - 1)
return Parent->GetNextSiblingUp();
else
return Parent->Childs[Index + 1];
return Parent->Children[Index + 1];
}
//------------------------------------------------------------------------------

Expand Down Expand Up @@ -3080,7 +3080,7 @@ void Clipper::BuildResult2(PolyTree &polytree) {
}

// fixup PolyNode links etc ...
polytree.Childs.reserve(m_PolyOuts.size());
polytree.Children.reserve(m_PolyOuts.size());
for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++) {
OutRec *outRec = m_PolyOuts[i];
if (!outRec->PolyNd)
Expand Down Expand Up @@ -3613,8 +3613,8 @@ ClipperOffset::~ClipperOffset() { Clear(); }

void ClipperOffset::Clear() {
for (int i = 0; i < m_polyNodes.ChildCount(); ++i)
delete m_polyNodes.Childs[i];
m_polyNodes.Childs.clear();
delete m_polyNodes.Children[i];
m_polyNodes.Children.clear();
m_lowest.X = -1;
}
//------------------------------------------------------------------------------
Expand Down Expand Up @@ -3656,7 +3656,8 @@ void ClipperOffset::AddPath(const Path &path, JoinType joinType,
if (m_lowest.X < 0)
m_lowest = IntPoint(m_polyNodes.ChildCount() - 1, k);
else {
IntPoint ip = m_polyNodes.Childs[(int)m_lowest.X]->Contour[(int)m_lowest.Y];
IntPoint ip =
m_polyNodes.Children[(int)m_lowest.X]->Contour[(int)m_lowest.Y];
if (newNode->Contour[k].Y > ip.Y ||
(newNode->Contour[k].Y == ip.Y && newNode->Contour[k].X < ip.X))
m_lowest = IntPoint(m_polyNodes.ChildCount() - 1, k);
Expand All @@ -3675,16 +3676,16 @@ void ClipperOffset::FixOrientations() {
// fixup orientations of all closed paths if the orientation of the
// closed path with the lowermost vertex is wrong ...
if (m_lowest.X >= 0 &&
!Orientation(m_polyNodes.Childs[(int)m_lowest.X]->Contour)) {
!Orientation(m_polyNodes.Children[(int)m_lowest.X]->Contour)) {
for (int i = 0; i < m_polyNodes.ChildCount(); ++i) {
PolyNode &node = *m_polyNodes.Childs[i];
PolyNode &node = *m_polyNodes.Children[i];
if (node.m_endtype == etClosedPolygon ||
(node.m_endtype == etClosedLine && Orientation(node.Contour)))
ReversePath(node.Contour);
}
} else {
for (int i = 0; i < m_polyNodes.ChildCount(); ++i) {
PolyNode &node = *m_polyNodes.Childs[i];
PolyNode &node = *m_polyNodes.Children[i];
if (node.m_endtype == etClosedLine && !Orientation(node.Contour))
ReversePath(node.Contour);
}
Expand Down Expand Up @@ -3741,13 +3742,13 @@ void ClipperOffset::Execute(PolyTree &solution, double delta) {
clpr.ReverseSolution(true);
clpr.Execute(ctUnion, solution, pftNegative, pftNegative);
// remove the outer PolyNode rectangle ...
if (solution.ChildCount() == 1 && solution.Childs[0]->ChildCount() > 0) {
PolyNode *outerNode = solution.Childs[0];
solution.Childs.reserve(outerNode->ChildCount());
solution.Childs[0] = outerNode->Childs[0];
solution.Childs[0]->Parent = outerNode->Parent;
if (solution.ChildCount() == 1 && solution.Children[0]->ChildCount() > 0) {
PolyNode *outerNode = solution.Children[0];
solution.Children.reserve(outerNode->ChildCount());
solution.Children[0] = outerNode->Children[0];
solution.Children[0]->Parent = outerNode->Parent;
for (int i = 1; i < outerNode->ChildCount(); ++i)
solution.AddChild(*outerNode->Childs[i]);
solution.AddChild(*outerNode->Children[i]);
} else
solution.Clear();
}
Expand All @@ -3762,7 +3763,7 @@ void ClipperOffset::DoOffset(double delta) {
if (NEAR_ZERO(delta)) {
m_destPolys.reserve(m_polyNodes.ChildCount());
for (int i = 0; i < m_polyNodes.ChildCount(); i++) {
PolyNode &node = *m_polyNodes.Childs[i];
PolyNode &node = *m_polyNodes.Children[i];
if (node.m_endtype == etClosedPolygon)
m_destPolys.push_back(node.Contour);
}
Expand Down Expand Up @@ -3794,7 +3795,7 @@ void ClipperOffset::DoOffset(double delta) {

m_destPolys.reserve(m_polyNodes.ChildCount() * 2);
for (int i = 0; i < m_polyNodes.ChildCount(); i++) {
PolyNode &node = *m_polyNodes.Childs[i];
PolyNode &node = *m_polyNodes.Children[i];
m_srcPoly = node.Contour;

int len = (int)m_srcPoly.size();
Expand Down Expand Up @@ -4321,7 +4322,7 @@ void AddPolyNodeToPaths(const PolyNode &polynode, NodeType nodetype,
if (!polynode.Contour.empty() && match)
paths.push_back(polynode.Contour);
for (int i = 0; i < polynode.ChildCount(); ++i)
AddPolyNodeToPaths(*polynode.Childs[i], nodetype, paths);
AddPolyNodeToPaths(*polynode.Children[i], nodetype, paths);
}
//------------------------------------------------------------------------------

Expand All @@ -4344,8 +4345,8 @@ void OpenPathsFromPolyTree(PolyTree &polytree, Paths &paths) {
paths.reserve(polytree.Total());
// Open paths are top level only, so ...
for (int i = 0; i < polytree.ChildCount(); ++i)
if (polytree.Childs[i]->IsOpen())
paths.push_back(polytree.Childs[i]->Contour);
if (polytree.Children[i]->IsOpen())
paths.push_back(polytree.Children[i]->Contour);
}
//------------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions deploy/android_demo/app/src/main/cpp/ocr_clipper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class PolyNode {

virtual ~PolyNode(){};
Path Contour;
PolyNodes Childs;
PolyNodes Children;
PolyNode *Parent;

PolyNode *GetNext() const;
Expand All @@ -170,7 +170,7 @@ class PolyNode {

private:
// PolyNode& operator =(PolyNode& other);
unsigned Index; // node index in Parent.Childs
unsigned Index; // node index in Parent.Children
bool m_IsOpen;
JoinType m_jointype;
EndType m_endtype;
Expand Down
8 changes: 4 additions & 4 deletions deploy/android_demo/app/src/main/cpp/ocr_ppredictor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct OCR_Config {
};

/**
* PolyGone Result
* Polygons Result
*/
struct OCRPredictResult {
std::vector<int> word_index;
Expand All @@ -39,8 +39,8 @@ struct ClsPredictResult {
};
/**
* OCR there are 2 models
* 1. First model(det),select polygones to show where are the texts
* 2. crop from the origin images, use these polygones to infer
* 1. First model(det),select polygons to show where are the texts
* 2. crop from the origin images, use these polygons to infer
*/
class OCR_PPredictor : public PPredictor_Interface {
public:
Expand Down Expand Up @@ -77,7 +77,7 @@ class OCR_PPredictor : public PPredictor_Interface {

private:
/**
* calcul Polygone from the result image of first model
* calculate polygons from the result image of first model
* @param pred
* @param output_height
* @param output_width
Expand Down
4 changes: 2 additions & 2 deletions deploy/cpp_infer/include/clipper.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class PolyNode {
PolyNode() noexcept;
virtual ~PolyNode() {}
Path Contour;
PolyNodes Childs;
PolyNodes Children;
PolyNode *Parent;
PolyNode *GetNext() const noexcept;
bool IsHole() const noexcept;
Expand All @@ -165,7 +165,7 @@ class PolyNode {

private:
// PolyNode& operator =(PolyNode& other);
unsigned Index; // node index in Parent.Childs
unsigned Index; // node index in Parent.Children
bool m_IsOpen;
JoinType m_jointype;
EndType m_endtype;
Expand Down
Loading