| 1950 | } |
| 1951 | |
| 1952 | bool PipelineParser::parse_sub_recognition( |
| 1953 | const json::value& input, |
| 1954 | Recognition::SubRecognition& output, |
| 1955 | const DefaultPipelineMgr& default_mgr) |
| 1956 | { |
| 1957 | using namespace Recognition; |
| 1958 | using namespace MAA_VISION_NS; |
| 1959 | |
| 1960 | // If input is a string, treat it as a node name reference |
| 1961 | if (input.is_string()) { |
| 1962 | output = input.as_string(); |
| 1963 | return true; |
| 1964 | } |
| 1965 | |
| 1966 | // Otherwise, parse as inline sub-recognition |
| 1967 | InlineSubRecognition inline_reco; |
| 1968 | |
| 1969 | Type parent_type = Type::DirectHit; |
| 1970 | Param parent_param = DirectHitParam { }; |
| 1971 | |
| 1972 | if (!parse_recognition(input, inline_reco.type, inline_reco.param, parent_type, parent_param, default_mgr)) { |
| 1973 | return false; |
| 1974 | } |
| 1975 | |
| 1976 | if (!get_and_check_value(input, "sub_name", inline_reco.sub_name, std::string { })) { |
| 1977 | LogError << "failed to get_and_check_value sub_name" << VAR(input); |
| 1978 | return false; |
| 1979 | } |
| 1980 | if (inline_reco.sub_name.empty()) { |
| 1981 | inline_reco.sub_name = Recognition::kTypeNameMap.at(inline_reco.type); |
| 1982 | } |
| 1983 | |
| 1984 | output = std::move(inline_reco); |
| 1985 | return true; |
| 1986 | } |
| 1987 | |
| 1988 | bool PipelineParser::parse_anchor( |
| 1989 | const json::value& input, |