Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
146 Views

Create Blob for input from float Mat

Jump to solution

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

Accepted Solutions
Highlighted
Beginner
146 Views

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);

View solution in original post

0 Kudos
1 Reply
Highlighted
Beginner
147 Views

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);

View solution in original post

0 Kudos