MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / WriteData

Function WriteData

tests/cvcuda/system/TestOpCenterCrop.cpp:49–72  ·  view source on GitHub ↗

Width is in bytes or pixels..

Source from the content-addressed store, hash-verified

47
48// Width is in bytes or pixels..
49static void WriteData(const nvcv::TensorDataAccessStridedImagePlanar &data, uint8_t val, int crop_rows,
50 int crop_columns)
51{
52 EXPECT_TRUE(data.layout() == NVCV_TENSOR_NHWC || data.layout() == NVCV_TENSOR_HWC);
53 EXPECT_LE(crop_columns, data.numCols());
54 EXPECT_LE(crop_rows, data.numRows());
55
56 int bytesPerChan = data.dtype().bitsPerChannel()[0] / 8;
57 int bytesPerPixel = data.numChannels() * bytesPerChan;
58 uint8_t *impPtrTop = (uint8_t *)data.sampleData(0);
59 uint8_t *impPtr = nullptr;
60 int numImages = data.numSamples();
61 int rowStride = data.rowStride();
62
63 EXPECT_NE(nullptr, impPtrTop);
64 int top_indices = (data.numRows() - crop_rows) / 2;
65 int left_indices = (data.numCols() - crop_columns) / 2;
66
67 for (int img = 0; img < numImages; img++)
68 {
69 impPtr = impPtrTop + (data.sampleStride() * img) + (left_indices * bytesPerPixel) + (top_indices * rowStride);
70 EXPECT_EQ(cudaSuccess, cudaMemset2D((void *)impPtr, rowStride, val, crop_columns * bytesPerPixel, crop_rows));
71 }
72}
73
74static void setGoldBuffer(std::vector<uint8_t> &vect, const nvcv::TensorDataAccessStridedImagePlanar &data,
75 int crop_rows, int crop_columns, uint8_t val)

Callers 1

TEST_PFunction · 0.70

Calls 10

sampleStrideMethod · 0.80
layoutMethod · 0.45
numColsMethod · 0.45
numRowsMethod · 0.45
bitsPerChannelMethod · 0.45
dtypeMethod · 0.45
numChannelsMethod · 0.45
sampleDataMethod · 0.45
numSamplesMethod · 0.45
rowStrideMethod · 0.45

Tested by

no test coverage detected