| 146 | } |
| 147 | |
| 148 | void RunTest(bool ltrb, bool ratio, bool skip_empty, bool polygon_masks = false, |
| 149 | bool polygon_masks_legacy = false) { |
| 150 | const auto expected_size = |
| 151 | skip_empty ? NonEmptyImages(polygon_masks) : SmallCocoSize(polygon_masks); |
| 152 | |
| 153 | OpSpec spec = BasicCocoReaderOpSpec(polygon_masks, false, polygon_masks_legacy); |
| 154 | |
| 155 | std::string tmpl = "/tmp/coco_reader_test_XXXXXX"; |
| 156 | std::string tmp_dir = mkdtemp(&tmpl[0]); |
| 157 | |
| 158 | OpSpec spec1 = spec; |
| 159 | spec1 = spec1.AddArg("annotations_file", annotations_filename_) |
| 160 | .AddArg("skip_empty", skip_empty) |
| 161 | .AddArg("ltrb", ltrb) |
| 162 | .AddArg("ratio", ratio) |
| 163 | .AddArg("save_preprocessed_annotations", true) |
| 164 | .AddArg("save_preprocessed_annotations_dir", tmp_dir); |
| 165 | |
| 166 | Pipeline pipe1(expected_size, 1, 0); |
| 167 | pipe1.AddOperator(spec1, "coco_reader"); |
| 168 | RunTestForPipeline(pipe1, ltrb, ratio, skip_empty, expected_size, polygon_masks, |
| 169 | polygon_masks_legacy); |
| 170 | |
| 171 | OpSpec spec2 = spec; |
| 172 | spec2.AddArg("preprocessed_annotations", tmp_dir); |
| 173 | |
| 174 | Pipeline pipe2(expected_size, 1, 0); |
| 175 | pipe2.AddOperator(spec2, "coco_reader"); |
| 176 | RunTestForPipeline(pipe2, ltrb, ratio, skip_empty, expected_size, polygon_masks, |
| 177 | polygon_masks_legacy); |
| 178 | |
| 179 | RemoveAll(tmp_dir.c_str()); |
| 180 | } |
| 181 | |
| 182 | void CheckInstances(Workspace &ws, bool ltrb, bool ratio, bool skip_empty, |
| 183 | int expected_size, bool polygon_masks, bool polygon_masks_legacy) { |
no test coverage detected