Skip to content

GpuMat as input/output to cv::dnn::Net #16433

@YashasSamaga

Description

@YashasSamaga

System information (version)

  • OpenCV => 4.2.0
APIs that need changes

Suitable APIs for GpuMat input:

  1. void setInput(InputArray blob, const String& name = "", double scalefactor = 1.0, const Scalar& mean = Scalar());

Suitable APIs for GpuMat output:

  1. void forward(OutputArrayOfArrays outputBlobs, const String& outputName = String());
  2. void forward(OutputArrayOfArrays outputBlobs, const std::vector<String>& outBlobNames);

Modifications to support GpuMat:

  1. void blobFromImage(InputArray image, OutputArray blob, double scalefactor=1.0, const Size& size = Size(), const Scalar& mean = Scalar(), bool swapRB=false, bool crop=false, int ddepth=CV_32F);

Might also require a new API that would allow a stream to be specified (required if blobFromImage needs to be performed asynchronously).

The CUDA backend uses fully packed tensors everywhere and expects a fully packed tensor as input. GpuMat given as input might be using a 2D memory layout which may not be contiguous. blobFromImage must return a contiguous copy of the input.

The outputs of the CUDA backend are also in fully packed tensors. Hence, for further optimal use of the output (in the case it's an image) would require a transformation to 2D memory layout.

Problems:
  1. GpuMat cannot store an arbitrary number of dimensions. How can the batch of images be passed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCcategory: dnncategory: gpu/cuda (contrib)OpenCV 4.0+: moved to opencv_contribeffort: few weeksContribution / porting of a new/existed algorithm. With samples / tests / docs / tutorialsfeaturefutureThis issue can't be fixed during restrictions of the compatibility requirements

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions