val blob = Dnn.blobFromImage(
frame, 1.0/255/0,
Size(62.0, 62.0))
here blob dimension is of : 1*3*62*62
i want the dimension in shape: 1*62*62*3
what you want here, woulld not be posssible as a reshape, memory has to be reorderhed (which Dnn.blobFromImage
does …).
why do you need it this way ? (uncommon for cnn’s)
do you want to run a specific network ?
using opencv’s Dnn class ?
NCHW <> NHWC conversions are very common.
“traditionally” images are loaded (N)HWC.
DNNs prefer NCHW. yours should too, as already stated.
OpenCV’s blobfromimage/images does that implicitly. and so does the imagesfromblob function.
Returns
4-dimensional Mat with NCHW dimensions order.
https://docs.opencv.org/3.4/d6/d0f/group__dnn.html#ga29f34df9376379a603acd8df581ac8d7
@berak @crackwitz thanks for your answer.
- Actually in android i was using a model in onnx format which requires the blob input dimension of type (1* 62 * 62 *3)which is NHWC.
- But as you stated that Dnn’s prefer NCHW and if i reshape the blob then my blob input might release the memory. Currently blob dimension: (NCHW(1 * 3 * 62 * 62)).
- So i want to way to convert the blob from (NCHW -to → NHWC). I have input image so if their is other method which can give me blob of type (NHWC) that would also works.
- Currently i also tried with Core.TransposeND(input_mat,order,output_mat). But that also won’t work and it released the memory of input_mat.
std::vector<int> order = {0, 2, 3, 1};
Mat inp, out; // inp: NCHW, out: NHWC
transposeND(inp, order, out);