How to export CV Mat to 4D-npy/npz, hdf5 or zarr?

assuming, [1,3,256,256] means 3 color channels, i think, you wanted this instead (the opposite of that hwc_to_chw function :

Mat[] layer = new Mat[3];
layer[0] = new Mat(256, 256, MatType.CV_32FC1, rawOutput.Ptr(0, 0));
layer[1] = new Mat(256, 256, MatType.CV_32FC1, rawOutput.Ptr(0, 1));
layer[2] = new Mat(256, 256, MatType.CV_32FC1, rawOutput.Ptr(0, 2));

Mat res = new Mat;
Cv2.merge(layer, res); // res has "interleaved" channels

apart from that, a few questions:

  • “Using the onnx-format I got …” <–> “Now I want to switch to the onnx-format” – what, now ?
  • “As far as I understand the documentation it seems that NCHW is not supported at onnx as output layer.” – have a link ?
  • can you point us to some code / repo you’re trying to use ?
  • segmentation networks usually return masks (either a single channel labels mask, or a list of n per-class maps), – not color channels, what about it ?