Adapted from src/util/TensorDataUtils.hpp
| 80 | |
| 81 | // Adapted from src/util/TensorDataUtils.hpp |
| 82 | inline static nvcv::Tensor CreateTensor(int numImages, int imgWidth, int imgHeight, const nvcv::ImageFormat &imgFormat) |
| 83 | { |
| 84 | if (imgFormat == NVCV_IMAGE_FORMAT_NV12 || imgFormat == NVCV_IMAGE_FORMAT_NV12_ER |
| 85 | || imgFormat == NVCV_IMAGE_FORMAT_NV21 || imgFormat == NVCV_IMAGE_FORMAT_NV21_ER) |
| 86 | { |
| 87 | if (imgHeight % 2 != 0 || imgWidth % 2 != 0) |
| 88 | { |
| 89 | throw std::invalid_argument("Invalid height"); |
| 90 | } |
| 91 | |
| 92 | int height420 = (imgHeight * 3) / 2; |
| 93 | |
| 94 | return nvcv::Tensor(numImages, {imgWidth, height420}, nvcv::ImageFormat(NVCV_IMAGE_FORMAT_Y8)); |
| 95 | } |
| 96 | else |
| 97 | { |
| 98 | return nvcv::Tensor(numImages, {imgWidth, imgHeight}, imgFormat); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | template<typename BT> |
| 103 | inline void CvtColor(nvbench::state &state, nvbench::type_list<BT>) |
no test coverage detected