1 #ifndef _NNDEPLOY_OCR_DETECTOR_DRAWBOX_H_
2 #define _NNDEPLOY_OCR_DETECTOR_DRAWBOX_H_
18 key_ =
"nndeploy::ocr::DrawDetectorBox";
20 "Draw ocr boxes on input cv::Mat image based on detection "
21 "results[cv::Mat->cv::Mat]";
22 this->setInputTypeInfo<cv::Mat>();
23 this->setInputTypeInfo<OCRResult>();
24 this->setOutputTypeInfo<cv::Mat>();
27 std::vector<dag::Edge *> outputs)
28 : Node(name, inputs, outputs) {
29 key_ =
"nndeploy::ocr::DrawDetectorBox";
31 "Draw ocr boxes on input cv::Mat image based on detection "
32 "results[cv::Mat->cv::Mat]";
33 this->setInputTypeInfo<cv::Mat>();
34 this->setInputTypeInfo<OCRResult>();
35 this->setOutputTypeInfo<cv::Mat>();
40 cv::Mat *input_mat = inputs_[0]->get<cv::Mat>(
this);
41 if (input_mat ==
nullptr) {
47 if (result ==
nullptr) {
53 int origin_w = int(input_mat->cols);
54 int origin_h = int(input_mat->rows);
56 cv::RNG rng(0xFFFFFFFF);
57 cv::Scalar_<int> randColor[CNUM];
58 cv::Mat *output_mat =
new cv::Mat();
59 input_mat->copyTo(*output_mat);
60 std::vector<std::vector<std::vector<int>>> boxes_recovered;
62 for (
auto &arr : result->
boxes_) {
63 std::vector<std::vector<int>> one_box;
64 for (
int i = 0; i < 8; i += 2) {
65 one_box.push_back({arr[i], arr[i + 1]});
67 boxes_recovered.push_back(one_box);
76 for (
int i = 0; i < boxes_recovered.size(); i++) {
77 std::array<int, 8> new_box;
79 for (
auto &vec : boxes_recovered[i]) {
84 cv::Point rook_points[4];
85 for (
int m = 0; m < 4; m++) {
86 rook_points[m] = cv::Point(
int(new_box[m * 2]),
87 int(new_box[m * 2 + 1])
91 const cv::Point *ppt[1] = {rook_points};
93 cv::polylines(*output_mat, ppt, npt, 1,
true, cv::Scalar(0, 255, 0), 2);
95 outputs_[0]->set(output_mat,
false);
DrawDetectorBox(const std::string &name)
virtual ~DrawDetectorBox()
virtual base::Status run()
Run node (pure virtual function)
PostProcessor util_post_processor_
DrawDetectorBox(const std::string &name, std::vector< dag::Edge * > inputs, std::vector< dag::Edge * > outputs)
std::vector< std::array< int, 8 > > boxes_
std::vector< std::vector< std::vector< int > > > FilterTagDetRes(std::vector< std::vector< std::vector< int >>> boxes, const std::array< int, 4 > &det_img_info)
#define NNDEPLOY_LOGE(fmt,...)
#define NNDEPLOY_CC_API
api
@ kStatusCodeErrorInvalidParam