CameraXObjectDetection
CameraXObjectDetection copied to clipboard
Why transform the ViewFinder on the update of different physical display?
Thanks for the amazing sample code (simple yet fully work + :heart: the auto resize preview)
I'm not super familiar with Display API but I notice that in this line you will update/transform the ViewFinder on the update event of different Display than that of the ViewFinder. What is the reason behind this?
this code based on https://github.com/android/camera/blob/master/CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/utils/AutoFitPreviewBuilder.kt#L61
It aims to support 180 degree device orientation changes. I tried some orientation changes with Pixel 3, but I couldn't find the situation that this callback be called. 😵
@yanzm I see, just have time to the official sample and I see the code.
Just try to debug and I think the reason the callback is not called is that this line will result in a call to this line so on first update of the Preview, your DisplayListener is already unregistered 😕, and it is never re-registered again. My work around is instead of registering the listener here, I would do it here when the viewFinder is attached again. Will try to ask in official repo about this.
Even though, doing this will have the callback is called correctly, but the display Id is always the same. I guess you need to attach the phone to another display via the cable or dock (my environment doesn't have a spare display :(, please try).
Still want to hear the answer about different displayId so I will try to ask in android/camera repo. My guess is when any other display is updated, the camera preview need to be adjusted for whatever reason ...