#pragma once #include #include #include #include #include namespace ice { // ── CCPD 角点解析 ── struct CCPDMeta { cv::Point2f corners[4]; // TL, TR, BR, BL bool valid = false; }; CCPDMeta parse_ccpd_filename(const std::string& filename); // ── 合成车牌池 ── struct PlateEntry { cv::Mat image; // BGR std::string plate_number; // 车牌号 (e.g. "粤Z1234港") }; class PlatePool { public: void load(const std::string& dir); void load_bin(const std::string& bin_path); const PlateEntry& random(const std::string& plate_type, std::mt19937& rng); size_t count(const std::string& plate_type) const; private: std::unordered_map> pools_; }; // ── 管线核心 ── struct SwapConfig { std::string plate_type; std::string output_dir; int h_shift = 0, s_scale = 100, v_scale = 100; bool fast_mode = false; }; // 单张处理 (pre-parsed meta 避免重复解析) bool process_single(const std::string& img_path, const SwapConfig& cfg, PlatePool& pool, std::mt19937& rng, const CCPDMeta* pre_meta = nullptr); // 透视提取车牌ROI cv::Mat extract_plate_roi(const cv::Mat& img, const cv::Point2f corners[4], int plate_w, int plate_h); // 色温匹配 cv::Mat match_plate_color(const cv::Mat& synthetic, const cv::Mat& orig_roi, const std::string& bg_color); // 底板色校正 cv::Mat fix_bg_color(const cv::Mat& plate, const std::string& bg_color, int h_shift, int s_scale, int v_scale); // 透视回贴: 返回 (warped, mask) std::pair warp_plate_back(const cv::Mat& plate, const cv::Point2f dst_corners[4], cv::Size output_size); // 羽化贴合 cv::Mat feather_blend(const cv::Mat& original, const cv::Mat& warped, const cv::Mat& mask, int edge_width = 8); // 噪声匹配 cv::Mat match_noise(const cv::Mat& blended, const cv::Mat& original, const cv::Mat& mask); // 退化模拟 cv::Mat degrade_plate(const cv::Mat& plate); // ── 工具 ── cv::Mat imread_unicode(const std::string& path); bool imwrite_unicode(const std::string& path, const cv::Mat& img, const std::vector& params = {}); } // namespace ice