android - NV21 ByteArray to array2d<rgb_pixel> -


hi i'm trying implement dlib facial landmark detection in android. know, need many fps can get. there 2 issues face,

  • conversion chain
  • resizing

currently, getting data preview callback set camera. outputs byte[] of nv21 image. since dlib dont know image , know array2d<dlib::rgb_pixel>, need conform data it. implementation uses bitmap, , when try use there code, have chain of conversion byte[]->bmp->array2d, want implement byte[]->array2d conversion.

now, need leverage performance of dlib manipulating size of image fed in it. use-case though doesn't involve small faces can down-scale input image boost performance, lets successful on making byte[]->array2d conversion, how can resize image? resizing in bitmap though have many fast implementations need cut bitmap involvement extract more fps. have option on resizing byte[] or converted 1 array2d, again... how? im guessing resizing after conversion because operating on native , not on java.

edit

the down-scaling should take byte[](not dlib::arrray2d) form input since need on down-scaled byte[].

so final problem implement on jni

byte[] resize(bytearray img, size targetsize); 

and

dlib::array2d<rgb_pixel> convert(bytearray img); 

performing resizing in java bad because of poor compiler optimization. performant option cpu-wise write specialized nv12 resize in c++, convert rgb. swapping order may slower though, , easier write.

your other option on gpu using shaders. gpu way faster @ sort of thing, finnicky. might need cpu fallback anyway (if gpu isn't available whatever reason, not familiar android).


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -