View my account

Cannot detect D435i on Android always

Comments

7 comments

  • MartyX Grover

    Hi Yixun Liu  Assuming that your app can run without the camera permissions checking code that the Capture example has, the next step you could try is to add the camera attach / detach device listener code from Capture into your script (lines 130-141).

    https://github.com/IntelRealSense/librealsense/blob/master/wrappers/android/examples/capture/src/main/java/com/intel/realsense/capture/MainActivity.java#L130

    0
    Comment actions Permalink
  • Yixun Liu

    Thanks for your reply.

    I do have the camera attach/detach code and it works. If I detach the camera I will see a warning and if I attach the camera the warning does not show.

    I comment out the following code since my device has Android 11.

    The difference from the example is except for the Depth camera I also use the tablet's camera. Before detecting the depth camera I start streaming of the tablet's camera. Does this cause the issue?

    Thank you so much!

    Best,

    Yixun 

    // Android 9 also requires camera permissions
    //if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.O &&
    // ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
    //ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, PERMISSIONS_REQUEST_CAMERA);
    //return;
    //}


    0
    Comment actions Permalink
  • MartyX Grover

    If the original Capture example detects the D435i camera consistently but your version that adds streaming from the Android device's own RGB camera causes problems then it is certainly worth focusing on that aspect of the project as a priority.

    I note that you seem to have removed the config.enableStream instructions in your version of the script.  Stream configuration instructions enable you to specify exactly which streams should be enabled.  If custom configuration instructions are absent then the D435i camera will use its default configuration (Depth + RGB). 

    https://github.com/IntelRealSense/librealsense/wiki/API-How-To#start-streaming-with-default-configuration

    So if you only want the Depth stream of the RealSense camera to be accessed and you are not using the RealSense camera's RGB then I suggest putting the config instructions back in your script but only including the Depth stream definition and leaving the Color one out so that RGB is ignored.

    https://github.com/IntelRealSense/librealsense/blob/master/wrappers/android/examples/capture/src/main/java/com/intel/realsense/capture/MainActivity.java#L163

    0
    Comment actions Permalink
  • Yixun Liu

    I add config.enableStream and comment out the follow code:

    config.enableStream(StreamType.COLOR, 640, 480);

    But it still does not work.

    I did some tests. I use a checkbox to start

    initDepthCamera() 

    rather than doing it in onResume.

    As I check the checkbox I call initDepthCamera and as I uncheck the checkbok I call stop(). The first time I check the checkbox the camera cannot be detected. But it can be detected as I check the box second time.

    Hope this information can help you to find the reason.

    Thank you so much!

     

    0
    Comment actions Permalink
  • MartyX Grover

    Is your initDepthCamera() code based on the init() code in the Capture example, which states in the comment notes: "RsContext.init must be called once in the application lifetime before any interaction with physical RealSense devices.  For multi activities applications use the application context instead of the activity context".

    https://github.com/IntelRealSense/librealsense/blob/master/wrappers/android/examples/capture/src/main/java/com/intel/realsense/capture/MainActivity.java#L102

    0
    Comment actions Permalink
  • Yixun Liu

    initDepthCamera() is the same with init(). I just rename it.

    I tried both application context and activity context, but no difference.

    It is weird that I have to call initDepthCamera() twice to make the depth camera detected.

    0
    Comment actions Permalink
  • MartyG

    After the camera has been detected on the second attempt, does the stop-start mechanism consistently behave correctly after that, or is there a pattern of starting only on the 2nd, 4th, 6th etc attempt?

    0
    Comment actions Permalink

Please sign in to leave a comment.