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

Function WriteData

tests/cvcuda/system/TestOpCustomCrop.cpp:49–69  ·  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, NVCVRectI region)
50{
51 EXPECT_TRUE(data.layout() == NVCV_TENSOR_NHWC || data.layout() == NVCV_TENSOR_HWC);
52 EXPECT_LE(region.x + region.width, data.numCols());
53 EXPECT_LE(region.y + region.height, data.numRows());
54
55 int bytesPerChan = data.dtype().bitsPerChannel()[0] / 8;
56 int bytesPerPixel = data.numChannels() * bytesPerChan;
57 uint8_t *impPtrTop = (uint8_t *)data.sampleData(0);
58 uint8_t *impPtr = nullptr;
59 int numImages = data.numSamples();
60 int rowStride = data.rowStride();
61
62 EXPECT_NE(nullptr, impPtrTop);
63 for (int img = 0; img < numImages; img++)
64 {
65 impPtr = impPtrTop + (data.sampleStride() * img) + (region.x * bytesPerPixel) + (rowStride * region.y);
66 EXPECT_EQ(cudaSuccess,
67 cudaMemset2D((void *)impPtr, rowStride, val, region.width * bytesPerPixel, region.height));
68 }
69}
70
71static void setGoldBuffer(std::vector<uint8_t> &vect, const nvcv::TensorDataAccessStridedImagePlanar &data,
72 NVCVRectI region, 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