| 914 | } |
| 915 | |
| 916 | DetectorResults Detect(const BitMatrix& image, bool tryHarder, bool tryRotate, bool isPure) |
| 917 | { |
| 918 | #ifdef __cpp_impl_coroutine |
| 919 | if (isPure) { |
| 920 | co_yield DetectPure(image); |
| 921 | } else { |
| 922 | bool found = false; |
| 923 | for (auto&& r : DetectNew(image, tryHarder, tryRotate)) { |
| 924 | found = true; |
| 925 | co_yield std::move(r); |
| 926 | } |
| 927 | if (!found && tryHarder) { |
| 928 | if (auto r = DetectPure(image); r.isValid()) |
| 929 | co_yield std::move(r); |
| 930 | else if(auto r = DetectOld(image); r.isValid()) |
| 931 | co_yield std::move(r); |
| 932 | } |
| 933 | } |
| 934 | #else |
| 935 | if (isPure) |
| 936 | return DetectPure(image); |
| 937 | |
| 938 | auto result = DetectNew(image, tryHarder, tryRotate); |
| 939 | if (!result.isValid() && tryHarder) |
| 940 | result = DetectPure(image); |
| 941 | if (!result.isValid() && tryHarder) |
| 942 | result = DetectOld(image); |
| 943 | return result; |
| 944 | #endif |
| 945 | } |
| 946 | |
| 947 | } // namespace ZXing::DataMatrix |