Skip to content

Missing function to copy cv::Umat to cv::ocl::Image2D without allocating space on device #19140

@JulienMaille

Description

@JulienMaille

I'm experimenting with using OpenCV to launch my own openCL kernels.
Everything works fine so far, I followed this example: https://stackoverflow.com/a/28644721

However it seems that passing a UMat to the kernel as a const image2d_t requires

cv::ocl::Image2D image(umat_src);

But this will both allocate memory and perform the UMat to Image2D copy:

handle = clCreateImage2D(context, CL_MEM_READ_WRITE, &format, src.cols, src.rows, 0, NULL, &err);

CV_OCL_CHECK(clEnqueueCopyBufferToImage(queue, devData, handle, 0, origin, region, 0, NULL, 0));

But if you want to process data in a loop and call the kernel multiple times, then Image2D constructor will keep allocating memory and device until it is full. A copy function would solve this.
Or am I doing it wrong?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions