Dnn.blobFromImage returns an empty result

I am porting python code in java, using opencv java and trying to use blob from image from a image loaded into a Mat object. But the returning blob is an all 0.0 Mat with correct dimensions.

from the reference screenshot of the debugger, the program is stopped before creating the tensor
input is the 640x640 8uc3 image
blob is the returned blob
rbuffer is where i found out the returned Mat is all 0s

please replace the useless screenshot with a TEXT version of your code, thank you

The code doesn’t have the runtime values watches,

But here is the snippet,

    var scores_list: List<FloatArray> = emptyList()
    var bboxes_list: List<FloatArray> = emptyList()
    var kpss_list: List<FloatArray> = emptyList()
    var bitmapfile= BitmapFactory.decodeStream(inputStream)

    var scaledimage=Bitmap.createScaledBitmap(bitmapfile, 640, 640, false)
    var input  = Mat()
    val floatImage= Mat()
    var bmp32: Bitmap = scaledimage.copy(Bitmap.Config.ARGB_8888, true)
    Utils.bitmapToMat(bmp32, input)


    input.convertTo(floatImage, CvType.CV_32FC3, 1.0 / 255.0);

    var blob = Dnn.blobFromImage(floatImage ,(1.0f/input_std).toDouble(), Size(640.0, 640.0
    ) , Scalar(input_mean,input_mean,input_mean) ,FALSE , TRUE)

    val a = Math.toIntExact( blob.total())
    Log.d("retina","blob channels "+ blob.channels()+ " type "+ blob.type() + " size "+blob.size()+ " dim "+blob.dims())

    //blob.convertTo(blob  , CvType.CV_32F)

    val rbuffer = FloatArray( a )

    blob.get(0, 0, rbuffer)
    Log.d("retina","rbuffer "+ rbuffer.toString())

    val shape= longArrayOf(1, 3, 640,640)
    val inputTensor = OnnxTensor.createTensor(
    val output = ortSession.run(Collections.singletonMap(input_name, inputTensor),
        setOf("448", "471", "494", "451", "474", "497", "454", "477", "500")


    //var v0=    (output?.get(0)?.info)
    //var ls = [type(item) for item in net_outs]
    output?.forEachIndexed { index, e ->
        Log.d("retina ",index.toString()+" "+e.value.info.toString())

i dont think, your blob is really empty.

please use blob.size(0), blob.size(1), blob.size(2), blob.size(3)

to determine the dimensions

   input.convertTo(floatImage, CvType.CV_32FC3, 1.0 / 255.0);

please check, if your mean/std vals in [0…1] or [0…255].

The blob is a 4-d array
,Problem is solved by changing

blob.get(0, 0, imbuffer)
blob.get(intArrayOf(0,0,0,0), rbuffer)

imbuffer would be a all 0 buffer,
rbuffer would be the correct buffer