CudaMemcpy Image Data with Conversion from Hwc to Chw
Imagine That We Have Some Opencv Usual Image Mat: Cv: :Mat Usual_Image = Cv: :Imread(. ..) This Image Stored as Hwc/Nhwc Array in Memory. If That Possible to...
Imagine that we have some OpenCV usual image Mat:
cv::Mat usual_image = cv::imread(...)
This image stored as HWC/NHWC array in memory.
If that possible to copy this image as CHW/NCHW (separated channel arrays, in sense) into cuda memory without super high cost cv::split?
Just for visualization HWC and CHW:
1 Answer
The fastest way to do this will be to copy the image as-is to the GPU, then write a GPU kernel to split the data into 3 buffers.
A slower alternative would be to use 3 calls to cudaMemcpy2D to copy the data from host to device, one call per plane.