Fixed
Status Update
Comments
er...@google.com <er...@google.com> #2
Hi Ed, Thank you so much for these suggestions. I've been reviewing them and merging them in. Hopefully it should be live. I've included a thank you note too in the article.
vi...@google.com <vi...@google.com> #3
Great! Thanks a lot, I'll look for the live updates soon!
ma...@photomath.com <ma...@photomath.com> #4
Thank you for the information and provided docs!
The proposed APIs look ok for the given use-cases but have the actual coordinate transformation quite hidden/abstracted away since it is not the primary focus of these APIs.
The actual coordinate conversions that need to happen behind the scenes are the exact ones I was initially referring to. This is definitely a point where they can be exposed to enable more explicit use by users that need them for use-cases outside of the metering point/zoom APIs.
Maybe making the coordinate conversion element an explicit object instead of having it fused with the MeteringPointFactory would alow for more flexibility:
CoordinateConverter cc = new TextureViewCoordinateConverter(textureView);
// or
CoordinateConverter cc = new DisplayOrientedCoordinateConverter(viewWidth, viewHeight);
// rest of the metering code is similar to the proposal doc:
MeteringPointFactory factory = new MeteringPointFactory(cc);
MeteringPoint point = factory.createPoint(x, y);
MeteringAction action = MeteringAction.Builder.from(point).build(); CameraX.getCameraControl(lensFacing).startFocusAndMetering(action);
// but, now users can use the coordinate converter directly if they want:
PointF outputPoint = cc.convertPreviewPointToOutput(x1, y1);
// or
PointF previewPoint = cc.convertOutputPointToPreview(x2, y2);
The CoordinateConverter interface would deal with converting from/to preview/output coordinate space. MeteringPointFactory and other similar special-purpose objects would use the CoordinateConverter internally in order to embedd the correct information into MeteringPoint etc.
The proposed APIs look ok for the given use-cases but have the actual coordinate transformation quite hidden/abstracted away since it is not the primary focus of these APIs.
The actual coordinate conversions that need to happen behind the scenes are the exact ones I was initially referring to. This is definitely a point where they can be exposed to enable more explicit use by users that need them for use-cases outside of the metering point/zoom APIs.
Maybe making the coordinate conversion element an explicit object instead of having it fused with the MeteringPointFactory would alow for more flexibility:
CoordinateConverter cc = new TextureViewCoordinateConverter(textureView);
// or
CoordinateConverter cc = new DisplayOrientedCoordinateConverter(viewWidth, viewHeight);
// rest of the metering code is similar to the proposal doc:
MeteringPointFactory factory = new MeteringPointFactory(cc);
MeteringPoint point = factory.createPoint(x, y);
MeteringAction action = MeteringAction.Builder.from(point).build(); CameraX.getCameraControl(lensFacing).startFocusAndMetering(action);
// but, now users can use the coordinate converter directly if they want:
PointF outputPoint = cc.convertPreviewPointToOutput(x1, y1);
// or
PointF previewPoint = cc.convertOutputPointToPreview(x2, y2);
The CoordinateConverter interface would deal with converting from/to preview/output coordinate space. MeteringPointFactory and other similar special-purpose objects would use the CoordinateConverter internally in order to embedd the correct information into MeteringPoint etc.
er...@google.com <er...@google.com> #5
Thanks for the feedback! we'll take this under consideration.
sc...@google.com <sc...@google.com>
sc...@google.com <sc...@google.com> #6
Thanks for the suggestion. While developing the tap-to-focus API, I was also thinking that the coordinates conversion could be needed in scenarios other than just tap-to-focus.
So your feedback provides an excellent chance to discuss over these requirements.
MeteringPoint is actually doing the coordinates conversion mainly. The XY in MeteringPoint represents the normalized X/Y (ranging [0..1]) in sensor orientation. By default it uses Preview aspect ratio, but you can also set the aspect ratio of other use case like ImageAnalysis / ImageCapture.
Having the MeteringPoint ready for converting any point to an unambiguous normalized sensor point makes it a good intermediate form to covert to other point in ImageCapture or others. The CoordinateConverter you proposed is a good abstraction I think, but it lacks the definition of what the output is.
Also having a intermediate form allows us to more flexibility. Below is the simple diagram showing how it works.
xy in TextureView/Preview xy in Prevew
xy in ImageAnalysis ==> MeteringPoint (normalized sensor point) ==> xy in ImageCapture
xy in ImageCapture xy in ImageAnalysis
Next part we need to consider is the image rotation problem
Currently MeteringPointFactory like TextureViewMeteringPointFactory or DisplayOrienedMeteringPointFactory already take care of the rotation handling of converting point to MeteringPoint (first half of the above diagram) . To be precise, the XY is assumed in the display orientation like XY in an android View. TextureViewMeteringPointFactory or DisplayOrienedMeteringPointFactory can help convert the display oriented XY into the normalized sensor XY. If you source image has different orientation, then SensorOrientedMeteringPointFactory should be used and apps has the duty to convert their xy into sensor oriented space.
The second half of the diagram is what we need to design further. Below are what we need to consider :
(1) Destination surface aspect ratio
(2) Destination rotation
I am thinking maybe have a method in UseCase is worth considering . for example.
PointF pt = useCase.convertMeteringPointByTargetRotation(MeteringPoint) // need a better name
This way we can leverage the setTargetRotation and aspect ratio of the UseCase surface to do the conversion
Scott
So your feedback provides an excellent chance to discuss over these requirements.
MeteringPoint is actually doing the coordinates conversion mainly. The XY in MeteringPoint represents the normalized X/Y (ranging [0..1]) in sensor orientation. By default it uses Preview aspect ratio, but you can also set the aspect ratio of other use case like ImageAnalysis / ImageCapture.
Having the MeteringPoint ready for converting any point to an unambiguous normalized sensor point makes it a good intermediate form to covert to other point in ImageCapture or others. The CoordinateConverter you proposed is a good abstraction I think, but it lacks the definition of what the output is.
Also having a intermediate form allows us to more flexibility. Below is the simple diagram showing how it works.
xy in TextureView/Preview xy in Prevew
xy in ImageAnalysis ==> MeteringPoint (normalized sensor point) ==> xy in ImageCapture
xy in ImageCapture xy in ImageAnalysis
Next part we need to consider is the image rotation problem
Currently MeteringPointFactory like TextureViewMeteringPointFactory or DisplayOrienedMeteringPointFactory already take care of the rotation handling of converting point to MeteringPoint (first half of the above diagram) . To be precise, the XY is assumed in the display orientation like XY in an android View. TextureViewMeteringPointFactory or DisplayOrienedMeteringPointFactory can help convert the display oriented XY into the normalized sensor XY. If you source image has different orientation, then SensorOrientedMeteringPointFactory should be used and apps has the duty to convert their xy into sensor oriented space.
The second half of the diagram is what we need to design further. Below are what we need to consider :
(1) Destination surface aspect ratio
(2) Destination rotation
I am thinking maybe have a method in UseCase is worth considering . for example.
PointF pt = useCase.convertMeteringPointByTargetRotation(MeteringPoint) // need a better name
This way we can leverage the setTargetRotation and aspect ratio of the UseCase surface to do the conversion
Scott
ma...@photomath.com <ma...@photomath.com> #7
Hello,
I definetly agree that these are all the conversion directions that would need to be supported:
xy in TextureView/Preview xy in Prevew
xy in ImageAnalysis ==> MeteringPoint ==> xy in ImageCapture
xy in ImageCapture xy in ImageAnalysis
however currently, as I understand, all MeteringPoint factories are based on Preview/screen coordinate systems. How would one create a ImageAnalysis/ImageCapture source of MeteringPoint? Would this also be a creation method on UseCase?
What you have proposed makes sense to me but only for the
xy in Prevew
xy in TextureView/Preview ==> MeteringPoint (normalized sensor point) ==> xy in ImageCapture
xy in ImageAnalysis
scenario.
Marko
I definetly agree that these are all the conversion directions that would need to be supported:
xy in TextureView/Preview xy in Prevew
xy in ImageAnalysis ==> MeteringPoint ==> xy in ImageCapture
xy in ImageCapture xy in ImageAnalysis
however currently, as I understand, all MeteringPoint factories are based on Preview/screen coordinate systems. How would one create a ImageAnalysis/ImageCapture source of MeteringPoint? Would this also be a creation method on UseCase?
What you have proposed makes sense to me but only for the
xy in Prevew
xy in TextureView/Preview ==> MeteringPoint (normalized sensor point) ==> xy in ImageCapture
xy in ImageAnalysis
scenario.
Marko
sc...@google.com <sc...@google.com> #8
Hi Marko,
You are correct that DisplayOrientedMeteringPointFactory / TextureViewMeteringPointFactory are only used to covert Preview/Screen coordinate into MeteringPoint coordinates. But we still has SensorOrientedMeteringPointFactory which is used to convert a point which is already in sensor orientation into the MeteringPoint (normalized sensor point).
For ImageAnalysis, the image in Analyzer is in sensor orientation , so SensorOrientedMeteringPoint can be used directly to do the conversion.
For ImageCapture, the captured image is rotated by rotationDegrees which is the rotation to apply to the image to match the display orientation.
So inside ImageCapture we can use rotationDegrees to restore it back to the sensor oriented coordinates.
Scott
You are correct that DisplayOrientedMeteringPointFactory / TextureViewMeteringPointFactory are only used to covert Preview/Screen coordinate into MeteringPoint coordinates. But we still has SensorOrientedMeteringPointFactory which is used to convert a point which is already in sensor orientation into the MeteringPoint (normalized sensor point).
For ImageAnalysis, the image in Analyzer is in sensor orientation , so SensorOrientedMeteringPoint can be used directly to do the conversion.
For ImageCapture, the captured image is rotated by rotationDegrees which is the rotation to apply to the image to match the display orientation.
So inside ImageCapture we can use rotationDegrees to restore it back to the sensor oriented coordinates.
Scott
ma...@photomath.com <ma...@photomath.com> #9
Ok, that makes sense now. Thank you for clarifying it!
Since all of the UseCase objects contain the required information, it does seem natural to have them be the final points of trasformation, as you have suggested in your previous post.
Since all of the UseCase objects contain the required information, it does seem natural to have them be the final points of trasformation, as you have suggested in your previous post.
se...@google.com <se...@google.com> #10
What's the ETA for providing a MeteringPointFactory that works with PreviewView? The migration of Lens is blocked on that.
sc...@google.com <sc...@google.com> #11
Hi Severin,
It should be merged no later than next week. We've prioritized this feature. will keep you posted.
It should be merged no later than next week. We've prioritized this feature. will keep you posted.
sc...@google.com <sc...@google.com> #12
Hi Severin / Eric,
I created another internal bug b/149442903 to track this item. (MeteringPointFactory on PreviewView) .
I created another internal bug
se...@google.com <se...@google.com> #13
Thanks Scott, will follow the other tracking bug.
xi...@google.com <xi...@google.com> #14
I will use this bug to track the progress.
ap...@google.com <ap...@google.com> #15
Project: platform/frameworks/support
Branch: androidx-main
commit dbc9694302f89ccfbfe3b03b019ee782aaa4a25c
Author: Xi Zhang <xizh@google.com>
Date: Thu Mar 11 10:02:05 2021
Bugfix: loosen the tolerance to match aspect ratio
The tolerance should be higher. For example, for width, the rounding error can be instrododuced by both the left and the right of the crop rect.
- Increase the tolerance to 1. (.5+.5)
- Do not crash the code for mismatch. The transform util will return incorrect result and log a warning. It should not be a crashable offence.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: I76e14a147e99fcd11b9dd138b8896cfc2e298946
M camera/camera-view/src/androidTest/java/androidx/camera/view/PreviewTransformationDeviceTest.kt
A camera/camera-view/src/androidTest/java/androidx/camera/view/TransformUtilsDeviceTest.java
M camera/camera-view/src/androidTest/java/androidx/camera/view/transform/CoordinateTransformDeviceTest.kt
M camera/camera-view/src/main/java/androidx/camera/view/TransformUtils.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/CoordinateTransform.java
https://android-review.googlesource.com/1629421
Branch: androidx-main
commit dbc9694302f89ccfbfe3b03b019ee782aaa4a25c
Author: Xi Zhang <xizh@google.com>
Date: Thu Mar 11 10:02:05 2021
Bugfix: loosen the tolerance to match aspect ratio
The tolerance should be higher. For example, for width, the rounding error can be instrododuced by both the left and the right of the crop rect.
- Increase the tolerance to 1. (.5+.5)
- Do not crash the code for mismatch. The transform util will return incorrect result and log a warning. It should not be a crashable offence.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: I76e14a147e99fcd11b9dd138b8896cfc2e298946
M camera/camera-view/src/androidTest/java/androidx/camera/view/PreviewTransformationDeviceTest.kt
A camera/camera-view/src/androidTest/java/androidx/camera/view/TransformUtilsDeviceTest.java
M camera/camera-view/src/androidTest/java/androidx/camera/view/transform/CoordinateTransformDeviceTest.kt
M camera/camera-view/src/main/java/androidx/camera/view/TransformUtils.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/CoordinateTransform.java
ap...@google.com <ap...@google.com> #16
Project: platform/frameworks/support
Branch: androidx-main
commit dc5d79817c1b0cd6d7bfca9efb7e5ffd85cd3202
Author: Xi Zhang <xizh@google.com>
Date: Thu Mar 11 17:44:07 2021
New API: transform util for saved files.
- Add a FileTransformFactory that handles 3 formats of saved files: InputStream, File and Uri.
- Applying exif info is too much code and will be done in the next CL.
- Update test app to draw a tile over saved file.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: Iad4198ac66fe911cc33d358072607d94ee280c75
M camera/camera-view/src/androidTest/AndroidManifest.xml
A camera/camera-view/src/androidTest/java/androidx/camera/view/transform/FileTransformFactoryDeviceTest.kt
A camera/camera-view/src/main/java/androidx/camera/view/transform/FileTransformFactory.java
M camera/integration-tests/viewtestapp/build.gradle
M camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/TransformFragment.java
M camera/integration-tests/viewtestapp/src/main/res/layout-land/transform_view.xml
M camera/integration-tests/viewtestapp/src/main/res/layout/transform_view.xml
https://android-review.googlesource.com/1634801
Branch: androidx-main
commit dc5d79817c1b0cd6d7bfca9efb7e5ffd85cd3202
Author: Xi Zhang <xizh@google.com>
Date: Thu Mar 11 17:44:07 2021
New API: transform util for saved files.
- Add a FileTransformFactory that handles 3 formats of saved files: InputStream, File and Uri.
- Applying exif info is too much code and will be done in the next CL.
- Update test app to draw a tile over saved file.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: Iad4198ac66fe911cc33d358072607d94ee280c75
M camera/camera-view/src/androidTest/AndroidManifest.xml
A camera/camera-view/src/androidTest/java/androidx/camera/view/transform/FileTransformFactoryDeviceTest.kt
A camera/camera-view/src/main/java/androidx/camera/view/transform/FileTransformFactory.java
M camera/integration-tests/viewtestapp/build.gradle
M camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/TransformFragment.java
M camera/integration-tests/viewtestapp/src/main/res/layout-land/transform_view.xml
M camera/integration-tests/viewtestapp/src/main/res/layout/transform_view.xml
ap...@google.com <ap...@google.com> #17
Project: platform/frameworks/support
Branch: androidx-main
commit 1eb584a90ad7b66ee1b34cd685b2f80433d2d0b0
Author: Xi Zhang <xizh@google.com>
Date: Tue Mar 23 10:11:06 2021
Transform util: apply the exif info of the saved file.
- Put the exif tag -> transform code in TransformUtil.java.
- Apply additional tranform when the flag is set.
- Update test app to add a button that captures an image and apply the exif info to the content.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: I2020a909424f6f9cb37652808aa4c5eebb4f261b
M camera/camera-view/src/androidTest/java/androidx/camera/view/transform/FileTransformFactoryDeviceTest.kt
M camera/camera-view/src/main/java/androidx/camera/view/TransformUtils.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/FileTransformFactory.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/OutputTransform.java
A camera/camera-view/src/test/java/androidx/camera/view/TransformUtilsTest.java
M camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/TransformFragment.java
M camera/integration-tests/viewtestapp/src/main/res/layout-land/transform_view.xml
M camera/integration-tests/viewtestapp/src/main/res/layout/transform_view.xml
M camera/integration-tests/viewtestapp/src/main/res/values/strings.xml
https://android-review.googlesource.com/1651536
Branch: androidx-main
commit 1eb584a90ad7b66ee1b34cd685b2f80433d2d0b0
Author: Xi Zhang <xizh@google.com>
Date: Tue Mar 23 10:11:06 2021
Transform util: apply the exif info of the saved file.
- Put the exif tag -> transform code in TransformUtil.java.
- Apply additional tranform when the flag is set.
- Update test app to add a button that captures an image and apply the exif info to the content.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: I2020a909424f6f9cb37652808aa4c5eebb4f261b
M camera/camera-view/src/androidTest/java/androidx/camera/view/transform/FileTransformFactoryDeviceTest.kt
M camera/camera-view/src/main/java/androidx/camera/view/TransformUtils.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/FileTransformFactory.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/OutputTransform.java
A camera/camera-view/src/test/java/androidx/camera/view/TransformUtilsTest.java
M camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/TransformFragment.java
M camera/integration-tests/viewtestapp/src/main/res/layout-land/transform_view.xml
M camera/integration-tests/viewtestapp/src/main/res/layout/transform_view.xml
M camera/integration-tests/viewtestapp/src/main/res/values/strings.xml
ap...@google.com <ap...@google.com> #18
Project: platform/frameworks/support
Branch: androidx-main
commit 441ec9909f4e4dd82922b48a352ccaad8dcf8e28
Author: Xi Zhang <xizh@google.com>
Date: Thu Apr 01 16:47:02 2021
Cleanup: use (-1, -1) - (1, 1) as normalized space.
It's easier to work with. e.g. rotation and scaling do not need to specify a pivot point since the pivot point is (0, 0). Also it's consistent with OpenGL.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: I14bb3a6f93c7d89d809c14200043034e52f30f4e
M camera/camera-view/src/androidTest/java/androidx/camera/view/transform/ImageProxyTransformFactoryTest.kt
M camera/camera-view/src/main/java/androidx/camera/view/PreviewTransformation.java
M camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
M camera/camera-view/src/main/java/androidx/camera/view/TransformUtils.java
M camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/TransformFragment.java
https://android-review.googlesource.com/1662695
Branch: androidx-main
commit 441ec9909f4e4dd82922b48a352ccaad8dcf8e28
Author: Xi Zhang <xizh@google.com>
Date: Thu Apr 01 16:47:02 2021
Cleanup: use (-1, -1) - (1, 1) as normalized space.
It's easier to work with. e.g. rotation and scaling do not need to specify a pivot point since the pivot point is (0, 0). Also it's consistent with OpenGL.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: I14bb3a6f93c7d89d809c14200043034e52f30f4e
M camera/camera-view/src/androidTest/java/androidx/camera/view/transform/ImageProxyTransformFactoryTest.kt
M camera/camera-view/src/main/java/androidx/camera/view/PreviewTransformation.java
M camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
M camera/camera-view/src/main/java/androidx/camera/view/TransformUtils.java
M camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/TransformFragment.java
ap...@google.com <ap...@google.com> #19
Project: platform/frameworks/support
Branch: androidx-main
commit 68f61216ae44f497f0f4227d982972daf169d543
Author: Xi Zhang <xizh@google.com>
Date: Thu Apr 01 17:05:56 2021
Cleanup transform util code
- Remove the usage of Matrix#setPolyToPoly. It's less readable and causes issue for Robolectirc. We will later do the same thing to PreviewTransformation.java.
- Turn instrument tests into unit tests, since now Robolectric can be used.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: Icd9dd66167cbf85389222d12963e2c579be7aca0
M camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
M camera/camera-view/src/main/java/androidx/camera/view/TransformUtils.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/FileTransformFactory.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/ImageProxyTransformFactory.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/OutputTransform.java
M camera/camera-view/src/test/java/androidx/camera/view/transform/CoordinateTransformTest.kt
M camera/camera-view/src/test/java/androidx/camera/view/transform/ImageProxyTransformFactoryTest.kt
M camera/camera-view/src/test/java/androidx/camera/view/transform/TransformTestUtils.java
https://android-review.googlesource.com/1663103
Branch: androidx-main
commit 68f61216ae44f497f0f4227d982972daf169d543
Author: Xi Zhang <xizh@google.com>
Date: Thu Apr 01 17:05:56 2021
Cleanup transform util code
- Remove the usage of Matrix#setPolyToPoly. It's less readable and causes issue for Robolectirc. We will later do the same thing to PreviewTransformation.java.
- Turn instrument tests into unit tests, since now Robolectric can be used.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: Icd9dd66167cbf85389222d12963e2c579be7aca0
M camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
M camera/camera-view/src/main/java/androidx/camera/view/TransformUtils.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/FileTransformFactory.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/ImageProxyTransformFactory.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/OutputTransform.java
M camera/camera-view/src/test/java/androidx/camera/view/transform/CoordinateTransformTest.kt
M camera/camera-view/src/test/java/androidx/camera/view/transform/ImageProxyTransformFactoryTest.kt
M camera/camera-view/src/test/java/androidx/camera/view/transform/TransformTestUtils.java
ap...@google.com <ap...@google.com> #20
Project: platform/frameworks/support
Branch: androidx-main
commit b8dd89b1a134810248ed01adb67ee51743402b62
Author: Xi Zhang <xizh@google.com>
Date: Mon Apr 05 14:53:56 2021
Cleanup: remove all usage of Matrix#setPolyToPoly
Matrix#setPolyToPloy cannot be tested with Robolectrics, and also less readable.
- Replace setPolyToPoly with the new TransformUtil#getRectToRect method.
- Convert the instrument tests to unit tests.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: I01d6eeccdc2efd63782c0a48f36e1b6778ef8874
M camera/camera-view/src/main/java/androidx/camera/view/PreviewTransformation.java
M camera/camera-view/src/main/java/androidx/camera/view/TransformUtils.java
D camera/camera-view/src/test/java/androidx/camera/view/PreviewTransformationTest.java
M camera/camera-view/src/test/java/androidx/camera/view/PreviewTransformationTest.kt
https://android-review.googlesource.com/1664991
Branch: androidx-main
commit b8dd89b1a134810248ed01adb67ee51743402b62
Author: Xi Zhang <xizh@google.com>
Date: Mon Apr 05 14:53:56 2021
Cleanup: remove all usage of Matrix#setPolyToPoly
Matrix#setPolyToPloy cannot be tested with Robolectrics, and also less readable.
- Replace setPolyToPoly with the new TransformUtil#getRectToRect method.
- Convert the instrument tests to unit tests.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: I01d6eeccdc2efd63782c0a48f36e1b6778ef8874
M camera/camera-view/src/main/java/androidx/camera/view/PreviewTransformation.java
M camera/camera-view/src/main/java/androidx/camera/view/TransformUtils.java
D camera/camera-view/src/test/java/androidx/camera/view/PreviewTransformationTest.java
M camera/camera-view/src/test/java/androidx/camera/view/PreviewTransformationTest.kt
ap...@google.com <ap...@google.com> #21
Project: platform/frameworks/support
Branch: androidx-main
commit 492425c12936fd4c02f33d13aac1204689d5e03b
Author: Xi Zhang <xizh@google.com>
Date: Wed Apr 07 07:51:55 2021
Make transform util API public.
This util is a experimental API that transforms coordinates between Preview, ImageAnalysis and ImageCapture. Example usage: transforming the coodinates detected in ImageAnalysis use case and highlight the detected object in preview.
- Add the missing getter to the factory classes.
- Add more mapping methods for CoordinateTransform.
- Unhide transform APIs.
- Generate api.txt
Relnote: Add a utility that transforms coordinates between use cases. Example usage: transforming the coodinates detected in ImageAnalysis use case and highlight the detected object in preview.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: I63ab10c16350de0e22d2722902987242943018c0
M camera/camera-view/api/public_plus_experimental_current.txt
M camera/camera-view/src/androidTest/java/androidx/camera/view/transform/FileTransformFactoryDeviceTest.kt
M camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/CoordinateTransform.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/FileTransformFactory.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/ImageProxyTransformFactory.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/OutputTransform.java
M camera/camera-view/src/test/java/androidx/camera/view/transform/CoordinateTransformTest.kt
M camera/camera-view/src/test/java/androidx/camera/view/transform/ImageProxyTransformFactoryTest.kt
M camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/TransformFragment.java
https://android-review.googlesource.com/1666192
Branch: androidx-main
commit 492425c12936fd4c02f33d13aac1204689d5e03b
Author: Xi Zhang <xizh@google.com>
Date: Wed Apr 07 07:51:55 2021
Make transform util API public.
This util is a experimental API that transforms coordinates between Preview, ImageAnalysis and ImageCapture. Example usage: transforming the coodinates detected in ImageAnalysis use case and highlight the detected object in preview.
- Add the missing getter to the factory classes.
- Add more mapping methods for CoordinateTransform.
- Unhide transform APIs.
- Generate api.txt
Relnote: Add a utility that transforms coordinates between use cases. Example usage: transforming the coodinates detected in ImageAnalysis use case and highlight the detected object in preview.
Bug: 137515129
Test: manual test and ./gradlew bOS
Change-Id: I63ab10c16350de0e22d2722902987242943018c0
M camera/camera-view/api/public_plus_experimental_current.txt
M camera/camera-view/src/androidTest/java/androidx/camera/view/transform/FileTransformFactoryDeviceTest.kt
M camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/CoordinateTransform.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/FileTransformFactory.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/ImageProxyTransformFactory.java
M camera/camera-view/src/main/java/androidx/camera/view/transform/OutputTransform.java
M camera/camera-view/src/test/java/androidx/camera/view/transform/CoordinateTransformTest.kt
M camera/camera-view/src/test/java/androidx/camera/view/transform/ImageProxyTransformFactoryTest.kt
M camera/integration-tests/viewtestapp/src/main/java/androidx/camera/integration/view/TransformFragment.java
Description
We believe that such an API should also be a core responsibility of the library. It has to deal with differences between aspect ratio, scale mode and crop mode between the preview frames and the capture frames in order for the coordinate conversion to be correct. It needs to work both ways: one needs to be able to select elements in the preview space and convert them to the capture output space to be used for processing, ROI croping etc., but also from the capture space into preview space in order to be able to display results of processing on the screen in the correct positions (detected objects/faces, recognized characters etc.).