Hi, I am trying to run a custom model which expects input image shape to be : float32[1,3,320,320] and i am converting JavaCV mat to bytebuffer using following code
Mat floatMat = new Mat();
resized.convertTo(floatMat, opencv_core.CV_32FC3);
FloatBuffer floatBuffer = floatMat.createBuffer();
float[] floatArray = new float[floatBuffer.capacity()];
floatBuffer.get(floatArray);
ByteBuffer byteBufferInverted = ByteBuffer.allocateDirect(floatArray.length*4);
byteBufferInverted.order(ByteOrder.nativeOrder());
byteBufferInverted.asFloatBuffer().put(floatArray);
Object[] inputs = new Object[]{byteBufferInverted};
Map<Integer, Object> outputMapOcrCraft = new HashMap<>();
outputMapOcrCraft.put(0, outputOcrCraftY);
outputMapOcrCraft.put(1, outputOcrCraftFeature);
ocrCraftTflite.runForMultipleInputsOutputs(inputs, outputMapOcrCraft);
I am getting the wrong output as floatMat shape is [320,320,3]. I am stuck in how to convert [320,320,3] to [3,320,320], how to achieve the above mentioned?
Hi, I am trying to run a custom model which expects input image shape to be : float32[1,3,320,320] and i am converting JavaCV mat to bytebuffer using following code
I am getting the wrong output as floatMat shape is [320,320,3]. I am stuck in how to convert [320,320,3] to [3,320,320], how to achieve the above mentioned?