2

I am making a camera app for which I needed 3D filters. I need 3D images as filters for which I have to use .obj files in canvas. Is there a possibility of using the .obj file on canvas?

I have been searching for 2 days now in search of a way to use the .obj file in Android Native all I get is Augmented Reality suggestions. ARCore Library is only supported for above API 7.0 (API level 24). Whereas my app supports Android 4.4 (API level 19)

What I need is that I can use filters like Snapchat. So do I have to go to the AR library or is there a way I can use .obj in Canvas? Please suggest!

Huzaifa Asif
  • 658
  • 1
  • 8
  • 24
  • I would advise more research on the topic of image processing. Related: [Opencv vs Opengl for image filters](https://stackoverflow.com/q/52382026/295004) – Morrison Chang May 14 '19 at 18:46
  • I have searched OpenGL as it is according to my needs but the issue remains, I am not able to use my custom 3D images in Canvas – Huzaifa Asif May 14 '19 at 18:51
  • Canvas isn't for that purpose. Any 3D object on Canvas would be rendered slower than one correctly written OpenGL ES. Note that in the Android documentation on Hardware Acceleration: [`drawVertices()` is UNSUPPORTED BY HARDWARE](https://developer.android.com/guide/topics/graphics/hardware-accel#unsupported) While a .obj file is nothing more than a text file with lots of vertices, and you may be able to do the processing with [Android Renderscript](https://developer.android.com/guide/topics/renderscript/compute), I can't see why anyone would want to render to Canvas. – Morrison Chang May 14 '19 at 19:02
  • Open GL ES does support 3D rendering but what i want is to use that 3D model in a camera preview which seems quite impossible using Open GL ES as i would have to use OpenGL preview for that. This is the only reason i'm interested in using Canvas as it is compatible with my camera preview. Though if you can suggest anything regarding OpenGL usage along with camera preview that would be helpful. Thanks! – Huzaifa Asif May 14 '19 at 19:08
  • I would advise looking at the [grafika project](https://github.com/google/grafika) specifically the `Texture from Camera` and `Show + Capture Camera` sample. These other links may help: [Render 3d Objects into Cameraview](https://stackoverflow.com/q/38227842/295004) and [How to draw objects on TextureView Camera stream preview and record the stream with objects?](https://stackoverflow.com/q/46560008/295004) But none of these have facial landmarks so OpenCV or MLKit is still your best bet. Good luck. – Morrison Chang May 14 '19 at 19:30
  • So i have found the solution for my issue by your help and the solution is that i would have to use the OpenGL overlay over my Texture View in Camera app if i want to use 3D images – Huzaifa Asif May 15 '19 at 08:58
  • 1
    I have the same issue did you have any demo related to this. i am using firebase ml face detection – Sonam Gupta Jan 10 '20 at 04:49
  • @SonamGupta i used Open CV for this purpose. ML kit is also good but it has some limitations. Whereas in Open CV you can make everything customizable. – Huzaifa Asif Jan 10 '20 at 12:24
  • @HuzaifaAsif how can i place .obj model in open CV as it only allow bitmap. I read your solution like overlay texture view but do not understand. Can you help me more – Sonam Gupta Jan 14 '20 at 12:45
  • Use Canvas for that purpose – Huzaifa Asif Jan 15 '20 at 09:12

0 Answers0