Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Change blobFromImage dimensions order

Hello everyone,

I faced a problem with C++ blobFromImage function. I trained a CNN-network in Keras which takes a 4-d blob as input (common practice, nothing special). The problem is that my blob order is NHWC (where Channle size is always 6) but blobFromImage returns only NCHW. There is no any trouble to reshape numpy-blob in python but I haven't found any solution for C++.

Is there any way to create blob of NHWC in C++ or reshape blobFromImage result to NHWC?

Change blobFromImage dimensions order

Hello everyone,

I faced a problem with C++ blobFromImage function. I trained a CNN-network in Keras which takes a 4-d blob as input (common practice, nothing special). The problem is that my blob order is NHWC (where Channle size is always 6) but blobFromImage returns only NCHW. There is no any trouble to reshape numpy-blob in python but I haven't found any solution for C++.

Is there any way to create blob of NHWC in C++ or reshape blobFromImage result to NHWC?

EDIT:

Due to berak's comment I combined two images and tried to retrieve them but something went wrong. lena.jpg doesn't seem to feel well after retrieval.

Original. image description

Retrieved. image description

Change blobFromImage dimensions order

Hello everyone,

I faced a problem with C++ blobFromImage function. I trained a CNN-network in Keras which takes a 4-d blob as input (common practice, nothing special). The problem is that my blob order is NHWC (where Channle size is always 6) but blobFromImage returns only NCHW. There is no any trouble to reshape numpy-blob in python but I haven't found any solution for C++.

Is there any way to create blob of NHWC in C++ or reshape blobFromImage result to NHWC?

EDIT:

Due After spending whole day solving the problem I finally got correct result. It turned out that my input images were CV_8U but my blob held CV_32F, so I simply converted inputs to berak's comment I combined two images CV_32F and tried to retrieve them but something went wrong. lena.jpg doesn't seem to feel well after retrieval.

Original. image description

Retrieved. image descriptionit worked! Thanks @berak for help.