CPP: tidied file header includes (#14621)
parent
ea710300b1
commit
ebd08eb385
|
@ -47,14 +47,9 @@
|
|||
// use_deprecated: Enables temporary support for the obsolete functions
|
||||
//#define use_deprecated
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <ostream>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ClipperLib {
|
||||
|
|
|
@ -14,11 +14,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "paddle_api.h"
|
||||
#include "paddle_inference_api.h"
|
||||
|
||||
#include <include/preprocess_op.h>
|
||||
#include <include/utility.h>
|
||||
#include <memory>
|
||||
|
||||
namespace paddle_infer {
|
||||
class Predictor;
|
||||
}
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -14,11 +14,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "paddle_api.h"
|
||||
#include "paddle_inference_api.h"
|
||||
|
||||
#include <include/postprocess_op.h>
|
||||
#include <include/preprocess_op.h>
|
||||
#include <memory>
|
||||
|
||||
namespace paddle_infer {
|
||||
class Predictor;
|
||||
}
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -14,11 +14,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "paddle_api.h"
|
||||
#include "paddle_inference_api.h"
|
||||
|
||||
#include <include/preprocess_op.h>
|
||||
#include <include/utility.h>
|
||||
#include <memory>
|
||||
|
||||
namespace paddle_infer {
|
||||
class Predictor;
|
||||
}
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -14,16 +14,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <include/ocr_cls.h>
|
||||
#include <include/ocr_det.h>
|
||||
#include <include/ocr_rec.h>
|
||||
#include <include/utility.h>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
class PPOCR {
|
||||
public:
|
||||
explicit PPOCR() noexcept;
|
||||
virtual ~PPOCR() {}
|
||||
virtual ~PPOCR();
|
||||
|
||||
std::vector<std::vector<OCRPredictResult>>
|
||||
ocr(const std::vector<cv::Mat> &img_list, bool det = true, bool rec = true,
|
||||
|
@ -47,9 +45,8 @@ protected:
|
|||
std::vector<OCRPredictResult> &ocr_results) noexcept;
|
||||
|
||||
private:
|
||||
std::unique_ptr<DBDetector> detector_;
|
||||
std::unique_ptr<Classifier> classifier_;
|
||||
std::unique_ptr<CRNNRecognizer> recognizer_;
|
||||
struct PPOCR_PRIVATE;
|
||||
PPOCR_PRIVATE *pri_;
|
||||
};
|
||||
|
||||
} // namespace PaddleOCR
|
||||
|
|
|
@ -15,15 +15,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <include/paddleocr.h>
|
||||
#include <include/structure_layout.h>
|
||||
#include <include/structure_table.h>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
class PaddleStructure : public PPOCR {
|
||||
public:
|
||||
explicit PaddleStructure() noexcept;
|
||||
~PaddleStructure() = default;
|
||||
~PaddleStructure();
|
||||
|
||||
std::vector<StructurePredictResult> structure(const cv::Mat &img,
|
||||
bool layout = false,
|
||||
|
@ -34,12 +32,12 @@ public:
|
|||
void benchmark_log(int img_num) noexcept;
|
||||
|
||||
private:
|
||||
struct STRUCTURE_PRIVATE;
|
||||
STRUCTURE_PRIVATE *pri_;
|
||||
|
||||
std::vector<double> time_info_table = {0, 0, 0};
|
||||
std::vector<double> time_info_layout = {0, 0, 0};
|
||||
|
||||
std::unique_ptr<StructureTableRecognizer> table_model_;
|
||||
std::unique_ptr<StructureLayoutRecognizer> layout_model_;
|
||||
|
||||
void layout(const cv::Mat &img,
|
||||
std::vector<StructurePredictResult> &structure_result) noexcept;
|
||||
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "include/clipper.h"
|
||||
#include "include/utility.h"
|
||||
#include <include/utility.h>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -14,12 +14,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -14,11 +14,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "paddle_api.h"
|
||||
#include "paddle_inference_api.h"
|
||||
|
||||
#include <include/postprocess_op.h>
|
||||
#include <include/preprocess_op.h>
|
||||
#include <memory>
|
||||
|
||||
namespace paddle_infer {
|
||||
class Predictor;
|
||||
}
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -14,11 +14,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "paddle_api.h"
|
||||
#include "paddle_inference_api.h"
|
||||
|
||||
#include <include/postprocess_op.h>
|
||||
#include <include/preprocess_op.h>
|
||||
#include <memory>
|
||||
|
||||
namespace paddle_infer {
|
||||
class Predictor;
|
||||
}
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -14,21 +14,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -33,16 +33,13 @@
|
|||
* used has retained a Delphi flavour. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include <include/clipper.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
#include "include/clipper.h"
|
||||
|
||||
namespace ClipperLib {
|
||||
|
||||
|
|
|
@ -11,16 +11,15 @@
|
|||
// 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 "opencv2/core.hpp"
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
|
||||
#include <include/args.h>
|
||||
#include <include/paddleocr.h>
|
||||
#include <include/paddlestructure.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
using namespace PaddleOCR;
|
||||
|
||||
void check_params() {
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include <include/ocr_cls.h>
|
||||
#include <paddle_inference_api.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <numeric>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include <include/ocr_det.h>
|
||||
#include <paddle_inference_api.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <numeric>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include <include/ocr_rec.h>
|
||||
#include <paddle_inference_api.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -13,15 +13,24 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include <include/args.h>
|
||||
#include <include/ocr_cls.h>
|
||||
#include <include/ocr_det.h>
|
||||
#include <include/ocr_rec.h>
|
||||
#include <include/paddleocr.h>
|
||||
|
||||
#include "auto_log/autolog.h"
|
||||
#include <auto_log/autolog.h>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
PPOCR::PPOCR() noexcept {
|
||||
struct PPOCR::PPOCR_PRIVATE {
|
||||
std::unique_ptr<DBDetector> detector_;
|
||||
std::unique_ptr<Classifier> classifier_;
|
||||
std::unique_ptr<CRNNRecognizer> recognizer_;
|
||||
};
|
||||
|
||||
PPOCR::PPOCR() noexcept : pri_(new PPOCR_PRIVATE) {
|
||||
if (FLAGS_det) {
|
||||
this->detector_.reset(new DBDetector(
|
||||
this->pri_->detector_.reset(new DBDetector(
|
||||
FLAGS_det_model_dir, FLAGS_use_gpu, FLAGS_gpu_id, FLAGS_gpu_mem,
|
||||
FLAGS_cpu_threads, FLAGS_enable_mkldnn, FLAGS_limit_type,
|
||||
FLAGS_limit_side_len, FLAGS_det_db_thresh, FLAGS_det_db_box_thresh,
|
||||
|
@ -30,13 +39,13 @@ PPOCR::PPOCR() noexcept {
|
|||
}
|
||||
|
||||
if (FLAGS_cls && FLAGS_use_angle_cls) {
|
||||
this->classifier_.reset(new Classifier(
|
||||
this->pri_->classifier_.reset(new Classifier(
|
||||
FLAGS_cls_model_dir, FLAGS_use_gpu, FLAGS_gpu_id, FLAGS_gpu_mem,
|
||||
FLAGS_cpu_threads, FLAGS_enable_mkldnn, FLAGS_cls_thresh,
|
||||
FLAGS_use_tensorrt, FLAGS_precision, FLAGS_cls_batch_num));
|
||||
}
|
||||
if (FLAGS_rec) {
|
||||
this->recognizer_.reset(new CRNNRecognizer(
|
||||
this->pri_->recognizer_.reset(new CRNNRecognizer(
|
||||
FLAGS_rec_model_dir, FLAGS_use_gpu, FLAGS_gpu_id, FLAGS_gpu_mem,
|
||||
FLAGS_cpu_threads, FLAGS_enable_mkldnn, FLAGS_rec_char_dict_path,
|
||||
FLAGS_use_tensorrt, FLAGS_precision, FLAGS_rec_batch_num,
|
||||
|
@ -44,6 +53,8 @@ PPOCR::PPOCR() noexcept {
|
|||
}
|
||||
}
|
||||
|
||||
PPOCR::~PPOCR() { delete this->pri_; }
|
||||
|
||||
std::vector<std::vector<OCRPredictResult>>
|
||||
PPOCR::ocr(const std::vector<cv::Mat> &img_list, bool det, bool rec,
|
||||
bool cls) noexcept {
|
||||
|
@ -52,11 +63,11 @@ PPOCR::ocr(const std::vector<cv::Mat> &img_list, bool det, bool rec,
|
|||
if (!det) {
|
||||
std::vector<OCRPredictResult> ocr_result;
|
||||
ocr_result.resize(img_list.size());
|
||||
if (cls && this->classifier_) {
|
||||
if (cls && this->pri_->classifier_) {
|
||||
this->cls(img_list, ocr_result);
|
||||
for (int i = 0; i < img_list.size(); ++i) {
|
||||
if (ocr_result[i].cls_label % 2 == 1 &&
|
||||
ocr_result[i].cls_score > this->classifier_->cls_thresh) {
|
||||
ocr_result[i].cls_score > this->pri_->classifier_->cls_thresh) {
|
||||
cv::rotate(img_list[i], img_list[i], 1);
|
||||
}
|
||||
}
|
||||
|
@ -90,11 +101,11 @@ std::vector<OCRPredictResult> PPOCR::ocr(const cv::Mat &img, bool det, bool rec,
|
|||
img_list.emplace_back(std::move(crop_img));
|
||||
}
|
||||
// cls
|
||||
if (cls && this->classifier_) {
|
||||
if (cls && this->pri_->classifier_) {
|
||||
this->cls(img_list, ocr_result);
|
||||
for (int i = 0; i < img_list.size(); ++i) {
|
||||
if (ocr_result[i].cls_label % 2 == 1 &&
|
||||
ocr_result[i].cls_score > this->classifier_->cls_thresh) {
|
||||
ocr_result[i].cls_score > this->pri_->classifier_->cls_thresh) {
|
||||
cv::rotate(img_list[i], img_list[i], 1);
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +122,7 @@ void PPOCR::det(const cv::Mat &img,
|
|||
std::vector<std::vector<std::vector<int>>> boxes;
|
||||
std::vector<double> det_times;
|
||||
|
||||
this->detector_->Run(img, boxes, det_times);
|
||||
this->pri_->detector_->Run(img, boxes, det_times);
|
||||
|
||||
for (int i = 0; i < boxes.size(); ++i) {
|
||||
OCRPredictResult res;
|
||||
|
@ -130,7 +141,7 @@ void PPOCR::rec(const std::vector<cv::Mat> &img_list,
|
|||
std::vector<std::string> rec_texts(img_list.size(), std::string());
|
||||
std::vector<float> rec_text_scores(img_list.size(), 0);
|
||||
std::vector<double> rec_times;
|
||||
this->recognizer_->Run(img_list, rec_texts, rec_text_scores, rec_times);
|
||||
this->pri_->recognizer_->Run(img_list, rec_texts, rec_text_scores, rec_times);
|
||||
// output rec results
|
||||
for (int i = 0; i < rec_texts.size(); ++i) {
|
||||
ocr_results[i].text = std::move(rec_texts[i]);
|
||||
|
@ -146,7 +157,7 @@ void PPOCR::cls(const std::vector<cv::Mat> &img_list,
|
|||
std::vector<int> cls_labels(img_list.size(), 0);
|
||||
std::vector<float> cls_scores(img_list.size(), 0);
|
||||
std::vector<double> cls_times;
|
||||
this->classifier_->Run(img_list, cls_labels, cls_scores, cls_times);
|
||||
this->pri_->classifier_->Run(img_list, cls_labels, cls_scores, cls_times);
|
||||
// output cls results
|
||||
for (int i = 0; i < cls_labels.size(); ++i) {
|
||||
ocr_results[i].cls_label = cls_labels[i];
|
||||
|
|
|
@ -14,21 +14,28 @@
|
|||
|
||||
#include <include/args.h>
|
||||
#include <include/paddlestructure.h>
|
||||
#include <include/structure_layout.h>
|
||||
#include <include/structure_table.h>
|
||||
|
||||
#include "auto_log/autolog.h"
|
||||
#include <auto_log/autolog.h>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
PaddleStructure::PaddleStructure() noexcept {
|
||||
struct PaddleStructure::STRUCTURE_PRIVATE {
|
||||
std::unique_ptr<StructureTableRecognizer> table_model_;
|
||||
std::unique_ptr<StructureLayoutRecognizer> layout_model_;
|
||||
};
|
||||
|
||||
PaddleStructure::PaddleStructure() noexcept : pri_(new STRUCTURE_PRIVATE) {
|
||||
if (FLAGS_layout) {
|
||||
this->layout_model_.reset(new StructureLayoutRecognizer(
|
||||
this->pri_->layout_model_.reset(new StructureLayoutRecognizer(
|
||||
FLAGS_layout_model_dir, FLAGS_use_gpu, FLAGS_gpu_id, FLAGS_gpu_mem,
|
||||
FLAGS_cpu_threads, FLAGS_enable_mkldnn, FLAGS_layout_dict_path,
|
||||
FLAGS_use_tensorrt, FLAGS_precision, FLAGS_layout_score_threshold,
|
||||
FLAGS_layout_nms_threshold));
|
||||
}
|
||||
if (FLAGS_table) {
|
||||
this->table_model_.reset(new StructureTableRecognizer(
|
||||
this->pri_->table_model_.reset(new StructureTableRecognizer(
|
||||
FLAGS_table_model_dir, FLAGS_use_gpu, FLAGS_gpu_id, FLAGS_gpu_mem,
|
||||
FLAGS_cpu_threads, FLAGS_enable_mkldnn, FLAGS_table_char_dict_path,
|
||||
FLAGS_use_tensorrt, FLAGS_precision, FLAGS_table_batch_num,
|
||||
|
@ -36,6 +43,8 @@ PaddleStructure::PaddleStructure() noexcept {
|
|||
}
|
||||
}
|
||||
|
||||
PaddleStructure::~PaddleStructure() { delete this->pri_; }
|
||||
|
||||
std::vector<StructurePredictResult>
|
||||
PaddleStructure::structure(const cv::Mat &srcimg, bool layout, bool table,
|
||||
bool ocr) noexcept {
|
||||
|
@ -73,7 +82,7 @@ void PaddleStructure::layout(
|
|||
const cv::Mat &img,
|
||||
std::vector<StructurePredictResult> &structure_result) noexcept {
|
||||
std::vector<double> layout_times;
|
||||
this->layout_model_->Run(img, structure_result, layout_times);
|
||||
this->pri_->layout_model_->Run(img, structure_result, layout_times);
|
||||
|
||||
this->time_info_layout[0] += layout_times[0];
|
||||
this->time_info_layout[1] += layout_times[1];
|
||||
|
@ -89,8 +98,8 @@ void PaddleStructure::table(const cv::Mat &img,
|
|||
std::vector<double> structure_times;
|
||||
std::vector<cv::Mat> img_list(1, img);
|
||||
|
||||
this->table_model_->Run(img_list, structure_html_tags, structure_scores,
|
||||
structure_boxes, structure_times);
|
||||
this->pri_->table_model_->Run(img_list, structure_html_tags, structure_scores,
|
||||
structure_boxes, structure_times);
|
||||
|
||||
this->time_info_table[0] += structure_times[0];
|
||||
this->time_info_table[1] += structure_times[1];
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <include/clipper.h>
|
||||
#include <include/postprocess_op.h>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include <include/structure_layout.h>
|
||||
#include <paddle_inference_api.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include <include/structure_table.h>
|
||||
#include <paddle_inference_api.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <numeric>
|
||||
|
||||
namespace PaddleOCR {
|
||||
|
||||
|
|
|
@ -14,9 +14,10 @@
|
|||
|
||||
#include <dirent.h>
|
||||
#include <include/utility.h>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
Loading…
Reference in New Issue