1

I ran the object detection demo from Tensorflow for android and I noticed that the DESIRED_PREVIEW_SIZE in the DetectorActivity is static (640X480) and doesn't depend on the device screen size. When I changed that using these :

public static int getScreenWidth() {
    return Resources.getSystem().getDisplayMetrics().widthPixels;
}

public static int getScreenHeight() {
    return Resources.getSystem().getDisplayMetrics().heightPixels;
}

i noticed that with a bigger preview the detection got slower and preview is a little bit laggy when you move the phone. The problem is when I keep the 640x480 resolution and take a picture it's going to be too small. That's why I need a bigger preview size.

Any suggestions on how I can improve the speed of the camera preview with a dynamic size that suits phones with big screens? I thought of applying detection only on 1 of 2 frames for example to speed it up but apparently it won't work since the accuracy will drop...

user 007
  • 821
  • 10
  • 31
  • 1
    That's a good question! Unfortunately I don't know the right way to deal with differing preview and final picture sizes, but I would investigate if there is a way to take your final photo at a different size than the preview, rather than altering the preview size. – Pete Warden Jun 06 '18 at 21:45
  • thanks for the tip.. I'll give it a try and I'll post my results afterwards ! one other quick question .. why do we need to convert every Frame from YUV420SP to ARGB8888 before processing it ? doesn't that affect the inference time ? I created an other stackoverflow issue about it here is the [link](https://stackoverflow.com/questions/50720286/why-tensorflow-object-detection-api-uses-yuv420sp-to-argb8888-conversion) – user 007 Jun 07 '18 at 07:55
  • @user007 Did you find any solution? – praj Sep 03 '19 at 16:48
  • @PeteWarden any solution? – praj Sep 03 '19 at 17:21
  • @praj i totally forgot about this, and didn't post my results. I followed the tip from Pete and i got good results. The solution have the nothing to do with Tensorflow but with the camera itself. You need to figure out a way to set the preview at small resolution and take a photo in an other. – user 007 Sep 04 '19 at 08:28
  • @user007 any code will help me lot. – praj Sep 05 '19 at 07:06
  • @user007 Can you please provide an answer? It seems that there is a lot of people that have this issue. – HB. Nov 13 '19 at 08:42
  • @HB. i'm sorry i can't post the code since the project i was working on is not open source and i'm not allowed to share code snippets from it. – user 007 Nov 13 '19 at 10:46
  • @user007 I did not ask for code. An explanation has nothing to do with open source. – HB. Nov 13 '19 at 11:55
  • I ament able to comment but this post helped solve it for me: – jayShod Apr 18 '20 at 11:03

0 Answers0