Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

Create Blob for input from float Mat

Rutger
Principiante
2.419 Vistas

Hi there!

I have a network to perform inference on with OpenVINO. The input data (images from file) should be normalized by subtracting mean and dividing by standard deviation, but the data comes from different sources and we normalize per source type, so the general "--mean_values" and "--scale_values" when converting the model to IR cannot be used since they hold constant values for all input images.

I think the way to go here is to do the normalization myself, which seems very easy since opencv allows for quick element-wise operations on Mat, but I have trouble with making a Blob of a float Mat to set as input for the InferRequest. I used wrapMat2Blob for uint8 Mats that imread returns, but I could not find a way to do something similar when the mat is of datatype float. Could anyone point me in the right direction on how to get this working? Thanks!

I'm working in C++ by the way :)

Kind regards,

Rutger

0 kudos
1 Solución
Rutger
Principiante
2.419 Vistas

Got it working with the following code, with input being a cv::Mat of type CV_32FC3

TensorDesc tDesc(
    Precision::FP32,
    { 1, (size_t)input.channels(), (size_t)input.size().height, (size_t)input.size().width },
    Layout::NHWC
);
Blob::Ptr imgBlob = make_shared_blob<float>(tDesc, (float*)input.data);

Ver la solución en mensaje original publicado

1 Responder
Rutger
Principiante
2.420 Vistas

Got it working with the following code, with input being a cv::Mat of type CV_32FC3

TensorDesc tDesc(
    Precision::FP32,
    { 1, (size_t)input.channels(), (size_t)input.size().height, (size_t)input.size().width },
    Layout::NHWC
);
Blob::Ptr imgBlob = make_shared_blob<float>(tDesc, (float*)input.data);
Responder