diff --git a/deploy/lite/config.txt b/deploy/lite/config.txt index 670b2ff00efd7bd289c34c460df4582dd72a2df6..23f0171d2025efb53aaced9ef3ae029089f2c7bd 100644 --- a/deploy/lite/config.txt +++ b/deploy/lite/config.txt @@ -2,4 +2,5 @@ max_side_len 960 det_db_thresh 0.3 det_db_box_thresh 0.5 det_db_unclip_ratio 1.6 -use_direction_classify 0 \ No newline at end of file +det_db_use_dilate 0 +use_direction_classify 1 \ No newline at end of file diff --git a/deploy/lite/ocr_db_crnn.cc b/deploy/lite/ocr_db_crnn.cc index 200d3464ef822b0f62dd451c47cb67704c1773f2..6cacfc82bab1055a669c6529ff425687b2f92b20 100644 --- a/deploy/lite/ocr_db_crnn.cc +++ b/deploy/lite/ocr_db_crnn.cc @@ -229,6 +229,7 @@ RunDetModel(std::shared_ptr predictor, cv::Mat img, std::map Config) { // Read img int max_side_len = int(Config["max_side_len"]); + int det_db_use_dilate = int(Config["det_db_use_dilate"]); cv::Mat srcimg; img.copyTo(srcimg); @@ -275,10 +276,14 @@ RunDetModel(std::shared_ptr predictor, cv::Mat img, const double maxvalue = 255; cv::Mat bit_map; cv::threshold(cbuf_map, bit_map, threshold, maxvalue, cv::THRESH_BINARY); - cv::Mat dilation_map; - cv::Mat dila_ele = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(2, 2)); - cv::dilate(bit_map, dilation_map, dila_ele); - auto boxes = BoxesFromBitmap(pred_map, dilation_map, Config); + if (det_db_use_dilate == 1) { + cv::Mat dilation_map; + cv::Mat dila_ele = + cv::getStructuringElement(cv::MORPH_RECT, cv::Size(2, 2)); + cv::dilate(bit_map, dilation_map, dila_ele); + bit_map = dilation_map; + } + auto boxes = BoxesFromBitmap(pred_map, bit_map, Config); std::vector>> filter_boxes = FilterTagDetRes(boxes, ratio_hw[0], ratio_hw[1], srcimg); @@ -375,8 +380,7 @@ int main(int argc, char **argv) { auto charactor_dict = ReadDict(dict_path); charactor_dict.insert(charactor_dict.begin(), "#"); // blank char for ctc charactor_dict.push_back(" "); -std: - cout << charactor_dict[0] << " " << charactor_dict[1] << std::endl; + cv::Mat srcimg = cv::imread(img_path, cv::IMREAD_COLOR); auto boxes = RunDetModel(det_predictor, srcimg, Config);