| 243 | |
| 244 | template <typename Lo, typename Hi> |
| 245 | void StoreBox(const OutListCPU<int, 1> &out1, |
| 246 | const OutListCPU<int, 1> &out2, |
| 247 | RandomObjectBBox::OutputFormat format, |
| 248 | int sample_idx, Lo &&start, Hi &&end) { |
| 249 | assert(dali::size(start) == dali::size(end)); |
| 250 | int ndim = dali::size(start); |
| 251 | switch (format) { |
| 252 | case RandomObjectBBox::Out_Box: |
| 253 | for (int i = 0; i < ndim; i++) { |
| 254 | out1.data[sample_idx][i] = start[i]; |
| 255 | out1.data[sample_idx][i + ndim] = end[i]; |
| 256 | } |
| 257 | break; |
| 258 | case RandomObjectBBox::Out_AnchorShape: |
| 259 | for (int i = 0; i < ndim; i++) { |
| 260 | out1.data[sample_idx][i] = start[i]; |
| 261 | out2.data[sample_idx][i] = end[i] - start[i]; |
| 262 | } |
| 263 | break; |
| 264 | case RandomObjectBBox::Out_StartEnd: |
| 265 | for (int i = 0; i < ndim; i++) { |
| 266 | out1.data[sample_idx][i] = start[i]; |
| 267 | out2.data[sample_idx][i] = end[i]; |
| 268 | } |
| 269 | break; |
| 270 | default: |
| 271 | assert(!"Unreachable code"); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | template <typename Box> |
| 276 | void StoreBox(const OutListCPU<int, 1> &out1, |