Announcement

Collapse
No announcement yet.

Phone Orientation for TensorFlow

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • mikets
    replied
    Or if you don't do debugging through logcat and want to use telemetry instead:
    Code:
            List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
            if (updatedRecognitions != null)
            {
                for (int i = 0; i < updatedRecognitions.size(); i++)
                {
                    Recognition object = updatedRecognitions.get(i);
                    float x = object.getTop();
                    float y = object.getImageWidth() - object.getRight();
                    float width = object.getHeight();
                    float height = object.getWidth();
                    telemetry.addData("x", x);
                    telemetry.addData("y", y);
                    telemetry.addData("width", width);
                    telemetry.addData("height", height);
                }
                telemetry.update();
            }

    Leave a comment:


  • mikets
    replied
    Here is a sample code showing you how to transpose and print out one of the corrected landscape coordinates:
    Code:
            List<Recognition> updatedRecognitions = tfod.getUpdatedRecognitions();
            if (updatedRecognitions != null)
            {
                for (int i = 0; i < updatedRecognitions.size(); i++)
                {
                    Recognition object = updatedRecognitions.get(i);
                    float x = object.getTop();
                    float y = object.getImageWidth() - object.getRight();
                    float width = object.getHeight();
                    float height = object.getWidth();
                    System.out.printf("[%d]: x=%.0f, y=%.0f, width=%.0f, height=%.0f\n", i, x, y, width, height);
                }
            }

    Leave a comment:


  • anjali_g
    replied
    What do x, y, width, and height refer to in the context of Vuforia parameters? The getUpdatedRecognitions list does not include these variables, so I'm not sure how you found the coordinates reported by getUpdatedRecognitions.

    We are trying to set the orientation to landscape instead of portrait (the default for Tensor Flow).

    Leave a comment:


  • mikets
    replied
    If your phone is in landscape the other way, then the code would be:
    Code:
    x = getImageHeight() - getBottom();
    y = getLeft();
    width = getHeight();
    height = getWidth();

    Leave a comment:


  • mikets
    replied
    Additional info: the above code only works if the top of your phone is pointing to the left when you are holding the phone in landscape orientation with the back camera facing away from you. If you have other orientations, you may need to adjust the code slightly. But again, not very complicated.

    Leave a comment:


  • mikets
    replied
    Sorry, I meant to say:
    Code:
    x = getTop(); y = getImageWidth() - getRight(); width = getHeight(); height = getWidth();

    Leave a comment:


  • mikets
    replied
    It's very simple to transpose the coordinates.
    Code:
    x = getTop();
    y = getImageWidth() - getRight();
    width = getImageHeight();
    height = getImageWidth();

    Leave a comment:


  • FLARE
    replied
    You actually answered our question with your questions! We had phones locked in portrait mode, but getLeft() was picking up information about the y axis instead of x. So now we have a few options to look into - unlock portrait mode or use a different method to get the locations. Thanks!

    Leave a comment:


  • mikets
    replied
    I don't understand your question. Are you asking how you can transpose the coordinates of one phone to match the other in software? Or are you asking how you can detect which phone you are using? Are your phone in portrait mode or landscape mode? Or are you asking if there is a phone setting to set the camera orientation? Or are you asking if there is a Vuforia parameter setting that sets the camera orientation? We have found out that TensorFlow/Vuforia is operating in Portrait mode. There could be a "setting" that I may use to tell TensorFlow/Vuforia about the phone orientation but I am not aware of it. That's why we fix it in software. We transpose the coordinates reported by getUpdatedRecognitions to the proper orientation before consumption.

    Leave a comment:


  • FLARE
    started a topic Phone Orientation for TensorFlow

    Phone Orientation for TensorFlow

    We finally tracked down a problem we have been struggling with for TensorFlow, but don't know how to fix it... We have 2 sets of phones, and they work in opposite orientation when detecting minerals. For example on set 1, the camera must be to the left & for set 2 the camera must be to the right.

    How do I get to the setting to make these these match?
    Thanks!
Working...
X