From 48568aa4cd9e838e52b2733868f9bd9180c0b574 Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Fri, 9 Jul 2021 08:30:34 +0000 Subject: [PATCH] fix bugs --- deploy/cpp_infer/CMakeLists.txt | 1 - deploy/cpp_infer/src/clipper.cpp | 22 +++++++++++----------- deploy/cpp_infer/src/config.cpp | 6 +++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/deploy/cpp_infer/CMakeLists.txt b/deploy/cpp_infer/CMakeLists.txt index bdcfefee..4f2dc88a 100644 --- a/deploy/cpp_infer/CMakeLists.txt +++ b/deploy/cpp_infer/CMakeLists.txt @@ -13,7 +13,6 @@ SET(TENSORRT_DIR "" CACHE PATH "Compile demo with TensorRT") set(DEMO_NAME "ocr_system") - macro(safe_set_static_flag) foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE diff --git a/deploy/cpp_infer/src/clipper.cpp b/deploy/cpp_infer/src/clipper.cpp index b35c25f2..5f5d2216 100644 --- a/deploy/cpp_infer/src/clipper.cpp +++ b/deploy/cpp_infer/src/clipper.cpp @@ -668,7 +668,7 @@ void DisposeOutPts(OutPt *&pp) { //------------------------------------------------------------------------------ inline void InitEdge(TEdge *e, TEdge *eNext, TEdge *ePrev, const IntPoint &Pt) { - std::memset(e, 0, sizeof(TEdge)); + std::memset(e, int(0), sizeof(TEdge)); e->Next = eNext; e->Prev = ePrev; e->Curr = Pt; @@ -1895,17 +1895,17 @@ void Clipper::InsertLocalMinimaIntoAEL(const cInt botY) { TEdge *rb = lm->RightBound; OutPt *Op1 = 0; - if (!lb) { + if (!lb || !rb) { // nb: don't insert LB into either AEL or SEL InsertEdgeIntoAEL(rb, 0); SetWindingCount(*rb); if (IsContributing(*rb)) Op1 = AddOutPt(rb, rb->Bot); - } else if (!rb) { - InsertEdgeIntoAEL(lb, 0); - SetWindingCount(*lb); - if (IsContributing(*lb)) - Op1 = AddOutPt(lb, lb->Bot); + //} else if (!rb) { + // InsertEdgeIntoAEL(lb, 0); + // SetWindingCount(*lb); + // if (IsContributing(*lb)) + // Op1 = AddOutPt(lb, lb->Bot); InsertScanbeam(lb->Top.Y); } else { InsertEdgeIntoAEL(lb, 0); @@ -2547,13 +2547,13 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) { if (dir == dLeftToRight) { maxIt = m_Maxima.begin(); while (maxIt != m_Maxima.end() && *maxIt <= horzEdge->Bot.X) - maxIt++; + ++maxIt; if (maxIt != m_Maxima.end() && *maxIt >= eLastHorz->Top.X) maxIt = m_Maxima.end(); } else { maxRit = m_Maxima.rbegin(); while (maxRit != m_Maxima.rend() && *maxRit > horzEdge->Bot.X) - maxRit++; + ++maxRit; if (maxRit != m_Maxima.rend() && *maxRit <= eLastHorz->Top.X) maxRit = m_Maxima.rend(); } @@ -2576,13 +2576,13 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) { while (maxIt != m_Maxima.end() && *maxIt < e->Curr.X) { if (horzEdge->OutIdx >= 0 && !IsOpen) AddOutPt(horzEdge, IntPoint(*maxIt, horzEdge->Bot.Y)); - maxIt++; + ++maxIt; } } else { while (maxRit != m_Maxima.rend() && *maxRit > e->Curr.X) { if (horzEdge->OutIdx >= 0 && !IsOpen) AddOutPt(horzEdge, IntPoint(*maxRit, horzEdge->Bot.Y)); - maxRit++; + ++maxRit; } } }; diff --git a/deploy/cpp_infer/src/config.cpp b/deploy/cpp_infer/src/config.cpp index 303c3c12..a0ac1d08 100644 --- a/deploy/cpp_infer/src/config.cpp +++ b/deploy/cpp_infer/src/config.cpp @@ -21,10 +21,10 @@ std::vector OCRConfig::split(const std::string &str, std::vector res; if ("" == str) return res; - char *strs = new char[str.length() + 1]; + char strs[str.length() + 1]; std::strcpy(strs, str.c_str()); - char *d = new char[delim.length() + 1]; + char d[delim.length() + 1]; std::strcpy(d, delim.c_str()); char *p = std::strtok(strs, d); @@ -61,4 +61,4 @@ void OCRConfig::PrintConfigInfo() { std::cout << "=======End of Paddle OCR inference config======" << std::endl; } -} // namespace PaddleOCR \ No newline at end of file +} // namespace PaddleOCR