Repository navigation
Conversation
The angle a camera can see is what maps a direction in the world onto a position on the preview, so anything drawn over the camera to point at something needs it - a marker on a landmark, an arrow towards a place, a pillar over where something was left. The library published nothing about its optics, so none of that could be placed: without the angle of view there is no way to turn "30 degrees to my right" into a screen coordinate. Worked out from the sensor's physical size and the focal length in front of it, with the maths in TransformMath beside the rest of the camera geometry, where it is unit tested against arithmetic that can be checked by hand and covered by the strict gate. Two things here are easy to get wrong and both are now pinned by tests. Zoom narrows the view by the tangent of the half-angle rather than by the ratio, so a 60-degree view at 2x is 32.2 degrees and not 30 - dividing would misplace a marker, and more badly the further from centre it is. And the first published focal length is the right one to measure, not the shortest: a zoom ratio of one means the lens the camera uses by default, which the array leads with, while the shortest belongs to the ultra-wide that the ratio reaches by going below one, so taking it and then applying the ratio counts it twice. All three backends answer. Camera2 reads the characteristics and goes through the same effective zoom ratio that setZoomLevel applies - both mechanisms, the ratio control and the active-array crop - so the reported angle cannot disagree with the request that produced the picture. The crop-zoom formula now has one definition instead of two. The legacy API reports the angle itself and only needs its zoom taken off. CameraX has no opinion on optics, so it reads the same two characteristics through Camera2CameraInfo and takes the ratio from its own zoom state. A camera that publishes neither returns 0 rather than having a plausible angle invented for it, and FakeCamera2 now publishes a sensor and lens so the backend path is asserted against known numbers. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The library's default flash mode is AUTO, so in a dim room every capture in the suite fires the flash - a dozen times over a full run across the classes and the three backends, which is unpleasant for whoever is holding the phone and makes the captures depend on the light in the room. Nothing here asserts on exposure. The shared open path turns the flash off, in one place so there is one place to look when a run starts flashing. That made the two flash-control tests tautological: both set OFF and asserted OFF, which a setter that did nothing would also pass. They now move the mode away from the harness's OFF and assert it took, then put it back. Choosing a mode lights nothing on its own - only a capture does, and neither test takes a picture. The torch test is the one that means to light the lamp, so it asks first: pass -Pandroid.testInstrumentationRunnerArguments.lamp=off and nothing in the suite lights up. The default is still to run it, because a torch nobody turns on is a torch nobody is testing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Groundwork for markers drawn over the preview: a pillar of light standing where something was left, an arrow towards a place, a label on a landmark. Two ways in, because there are two ways of knowing where something is. A direction is all a compass and a location can give, and it needs nothing but the camera's angle of view - which is why this lands now that the library reports one. Position goes as the tangent of the angle rather than in proportion to it, so half the angle of view away is the edge of the view and a quarter is not halfway out; doing that arithmetic at the call site is the mistake this exists to prevent. Up in the world is down a view's y axis, and the flip is here so a caller cannot forget it. A point in metres is what a tracked session gives, and it goes through that session's own matrices the way its renderer would. A point behind the camera is refused rather than projected: dividing by a negative w mirrors it through the centre, so something you have already walked past lands plausibly on the wall ahead. Occlusion is what makes a marker look like it is in the room rather than painted on the glass. The depth comparison carries a tolerance because a reading is noisy and taken a moment apart from the pose, and an exact comparison makes a marker flicker along every edge it is near; no reading at all shows the marker, since guessing either way is worse. visiblePillar walks a tall marker from the ground up and returns the stretch that is in front, so a pillar whose base is behind the sofa still shows its top - which is the whole point of it being tall. Nothing here draws anything. In the strict coverage gate with the rest of the geometry, because every mistake available here is silent: a marker at a wrong position still looks like a marker, it just points at the wrong thing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The only open issue on the repository is a 2017 report of recordings full of green lines, which is what MediaRecorder produces when it is handed a size or encoder configuration its camera cannot deliver. One way to do that is here: every quality checked hasProfile against the active camera and then fetched the profile with the single-argument overload, which returns the first back-facing camera's profile whatever camera is open. On the front camera that handed MediaRecorder another sensor's configuration. The issue was filed against Jelly Bean, which this library no longer supports, so this is not a fix for that report - but it is the same mistake, still present, on every front-camera recording where the two cameras publish different profiles. The camera2 path already guards the equivalent by filtering sizes through CamcorderProfile before offering them. setMaxDuration was also being called twice. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third of four stacked PRs, based on
pr/2-metadata. Groundwork for drawing markers over the preview — an arrow towards a place, a label on a landmark, a pillar of light standing where something was left.setZoomLevelapplies, both the ratio control and the active-array crop, so the reported angle cannot disagree with the request that produced the picture.WorldOverlay. Two ways in, because there are two ways of knowing where something is. A bearing plus the angle of view needs nothing else. A point in metres goes through a tracked session's own matrices, and a point behind the camera is refused rather than projected — dividing by a negativewmirrors it through the centre and would draw something you have already walked past onto the wall ahead. Occlusion compares how far away the marker is against how far away the scene is, with a tolerance, because a depth reading is noisy and taken a moment apart from the pose; no reading at all shows the marker, since guessing either way is worse.visiblePillarwalks a tall marker from the ground up and returns the stretch that is in front, so a pillar whose base is behind the sofa still shows its top. It draws nothing — what a marker looks like is the app's business.-Pandroid.testInstrumentationRunnerArguments.lamp=offgives a completely dark run.hasProfile(activeCamera, …)and then fetched the profile with the single-argument overload, which returns the first back-facing camera's profile whatever camera is open — so front-camera recordings were handed another sensor's configuration. Found by triaging the repository's only open issue, a 2017 report of recordings full of green lines; the issue predates this library's minSdk, but it is the same mistake and it was still present.