nvImageCodec icon indicating copy to clipboard operation
nvImageCodec copied to clipboard

region-of-interest decoding

Open grez72 opened this issue 10 months ago • 1 comments

Is this a new feature, an improvement, or a change to existing functionality?

New Feature

How would you describe the priority of this feature request

Must have (e.g. nvImageCodec adoption is impossible due to lack in functionality).

Please provide a clear description of problem this feature solves

I'm working with high-resolution images, but only need to decode a region-of-interest on any given pass over an image in my pipeline. The alternative is to decode entire images, then crop them, but this is far too slow when working with very high resolution images.

Feature Description

I see many of the decoders (e.g., nvjpeg2k/cuda_decoder.cpp) have an enable_roi flag and image_info.region parameters. I'm proposing to expose this functionality through the Python API. Ideally I would be able to decode a different region of interest for each image in a batch.

Describe your ideal solution

decoder = nvimgcodec.Decoder()

# region tuple (start_x, start_y, end_x, end_y) or list of tuples
rois = [ (0,0,150,150), (100,100,250,250)]

# decode regions of interest (one roi per image)
data_list = [img1_data, img2_data]
cropped_images = decoder.decode(data_list, region_of_interest=rois)

# or using read
file_list = [filepath_img1, filepath_img2]
cropped_images = decoder.read(data_list, region_of_interest=rois)

Describe any alternatives you have considered

I've looked into using nvidia-dali (nvidia.dali.fn.decoders.image_crop) but it doesn't fit into my current pipeline, which requires a stand-alone decoding solution (like nvImageCodec).

Additional context

No response

Check for duplicates

  • [X] I have searched the open bugs/issues and have found no duplicates for this bug report

grez72 avatar Apr 16 '24 11:04 grez72