Skip to content

Commit 6958ec1

Browse files
committed
Added new samples + fixed VideoPlayer.kt
1 parent 6546ca0 commit 6958ec1

67 files changed

Lines changed: 5130 additions & 591 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,18 @@ Filter the catalog by **All / CameraX / Camera2** on the home screen.
3434
| --- | --- | --- |
3535
| Take a Photo | CameraX / Camera2 | Preview, tap-to-focus, capture a still |
3636
| Take a Video | CameraX (Recorder) / Camera2 (MediaRecorder) | Record video to `DCIM/Camera` |
37+
| Pause/Resume | CameraX (Recorder) | Pause and resume a recording mid-capture |
3738
| Slow Motion | Camera2 | High-speed (constrained) recording |
38-
| QR Scanner | CameraX + ML Kit | Real-time barcode/QR detection with overlay |
39+
| QR Scanner | CameraX / Camera2 + ML Kit | Real-time barcode/QR detection with overlay |
3940
| Image Labeling | CameraX + ML Kit | Real-time on-device labels via `ImageAnalysis` |
41+
| Luminosity | CameraX | Scene-brightness meter from the `ImageAnalysis` Y plane |
42+
| Green Screen | CameraX + ML Kit | Concurrent cameras: segment the front-camera subject over the live back camera |
4043
| Extensions | CameraX / Camera2 | Night / Bokeh / HDR / Face Retouch / Auto |
44+
| Ultra HDR | CameraX | Gain-map Ultra HDR (`JPEG_R`) still capture |
45+
| Effects | CameraX | Live color filters (grayscale, sepia, invert, …) via `ImageAnalysis` + `ColorMatrix` |
4146
| Viewfinder Effects | Camera2 | Real-time frame processing on the live preview |
47+
| Concurrent Camera | CameraX | Front + back preview at once (picture-in-picture) |
48+
| RAW / DNG | Camera2 | `RAW_SENSOR` → DNG via `DngCreator`, then an in-app viewer/editor (re-expose, re-white-balance) |
4249
| Zoom & Torch | CameraX / Camera2 | Zoom ratio slider + torch toggle |
4350
| Exposure | CameraX | Exposure-compensation slider |
4451
| Manual Controls | Camera2 | Manual ISO / shutter / focus distance |

‎app/build.gradle.kts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ dependencies {
8787
implementation(project(":samples:camerax-extensions"))
8888
implementation(project(":samples:camerax-zoomandtorch"))
8989
implementation(project(":samples:camerax-exposure"))
90+
implementation(project(":samples:camerax-luminosity"))
91+
implementation(project(":samples:camerax-ultrahdr"))
92+
implementation(project(":samples:camerax-concurrentcamera"))
93+
implementation(project(":samples:camerax-videopauseresume"))
94+
implementation(project(":samples:camerax-effects"))
95+
implementation(project(":samples:camerax-greenscreen"))
9096

9197
// Camera2 Samples
9298
implementation(project(":samples:camera2-takeaphoto"))
@@ -96,6 +102,8 @@ dependencies {
96102
implementation(project(":samples:camera2-hdrviewfinder"))
97103
implementation(project(":samples:camera2-zoomandtorch"))
98104
implementation(project(":samples:camera2-manualcontrols"))
105+
implementation(project(":samples:camera2-qrscanner"))
106+
implementation(project(":samples:camera2-rawcapture"))
99107

100108
testImplementation(libs.junit)
101109
androidTestImplementation(libs.androidx.junit)

‎app/src/main/java/com/android/camera/catalog/domain/SampleCatalog.kt‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,24 @@ import com.android.camera.coretheme.extendedColorScheme
2424
import com.android.camera2.extensions.Camera2ExtensionsScreen
2525
import com.android.camera2.hdrviewfinder.Camera2HdrViewfinderScreen
2626
import com.android.camera2.manualcontrols.Camera2ManualControlsScreen
27+
import com.android.camera2.qrscanner.Camera2QrScannerScreen
28+
import com.android.camera2.rawcapture.Camera2RawCaptureScreen
2729
import com.android.camera2.slowmotion.Camera2SlowMotionScreen
2830
import com.android.camera2.takeaphoto.Camera2TakeAPhotoScreen
2931
import com.android.camera2.takeavideo.Camera2TakeAVideoScreen
3032
import com.android.camera2.zoomandtorch.Camera2ZoomAndTorchScreen
33+
import com.android.camerax.concurrentcamera.CameraXConcurrentCameraScreen
34+
import com.android.camerax.effects.CameraXEffectsScreen
3135
import com.android.camerax.exposure.CameraXExposureScreen
3236
import com.android.camerax.extensions.CameraXExtensionsScreen
37+
import com.android.camerax.greenscreen.CameraXGreenScreenScreen
3338
import com.android.camerax.imagelabeling.CameraXImageLabelingScreen
39+
import com.android.camerax.luminosity.CameraXLuminosityScreen
3440
import com.android.camerax.qrscanner.CameraXQrScannerScreen
3541
import com.android.camerax.takeaphoto.CameraXTakeAPhotoScreen
3642
import com.android.camerax.takeavideo.CameraXTakeAVideoScreen
43+
import com.android.camerax.ultrahdr.CameraXUltraHdrScreen
44+
import com.android.camerax.videopauseresume.CameraXVideoPauseResumeScreen
3745
import com.android.camerax.zoomandtorch.CameraXZoomAndTorchScreen
3846

3947
val sampleCatalog =
@@ -145,6 +153,66 @@ val sampleCatalog =
145153
sampleEntryScreen = { Camera2ManualControlsScreen() },
146154
type = SampleType.CAMERA2,
147155
),
156+
SampleCatalogItem(
157+
title = R.string.camerax_luminosity_list_title,
158+
description = R.string.camerax_luminosity_list_description,
159+
route = "CameraXLuminosityScreen",
160+
sampleEntryScreen = { CameraXLuminosityScreen() },
161+
type = SampleType.CAMERAX,
162+
tags = listOf(SampleTags.ANALYSIS),
163+
),
164+
SampleCatalogItem(
165+
title = R.string.camera2_qrscanner_list_title,
166+
description = R.string.camera2_qrscanner_list_description,
167+
route = "Camera2QrScannerScreen",
168+
sampleEntryScreen = { Camera2QrScannerScreen() },
169+
type = SampleType.CAMERA2,
170+
tags = listOf(SampleTags.ML_KIT),
171+
),
172+
SampleCatalogItem(
173+
title = R.string.camerax_ultrahdr_list_title,
174+
description = R.string.camerax_ultrahdr_list_description,
175+
route = "CameraXUltraHdrScreen",
176+
sampleEntryScreen = { CameraXUltraHdrScreen() },
177+
type = SampleType.CAMERAX,
178+
),
179+
SampleCatalogItem(
180+
title = R.string.camerax_concurrentcamera_list_title,
181+
description = R.string.camerax_concurrentcamera_list_description,
182+
route = "CameraXConcurrentCameraScreen",
183+
sampleEntryScreen = { CameraXConcurrentCameraScreen() },
184+
type = SampleType.CAMERAX,
185+
),
186+
SampleCatalogItem(
187+
title = R.string.camerax_videopauseresume_list_title,
188+
description = R.string.camerax_videopauseresume_list_description,
189+
route = "CameraXVideoPauseResumeScreen",
190+
sampleEntryScreen = { CameraXVideoPauseResumeScreen() },
191+
type = SampleType.CAMERAX,
192+
tags = listOf(SampleTags.VIDEO),
193+
),
194+
SampleCatalogItem(
195+
title = R.string.camera2_rawcapture_list_title,
196+
description = R.string.camera2_rawcapture_list_description,
197+
route = "Camera2RawCaptureScreen",
198+
sampleEntryScreen = { Camera2RawCaptureScreen() },
199+
type = SampleType.CAMERA2,
200+
),
201+
SampleCatalogItem(
202+
title = R.string.camerax_effects_list_title,
203+
description = R.string.camerax_effects_list_description,
204+
route = "CameraXEffectsScreen",
205+
sampleEntryScreen = { CameraXEffectsScreen() },
206+
type = SampleType.CAMERAX,
207+
),
208+
SampleCatalogItem(
209+
title = R.string.camerax_greenscreen_list_title,
210+
description = R.string.camerax_greenscreen_list_description,
211+
route = "CameraXGreenScreenScreen",
212+
sampleEntryScreen = { CameraXGreenScreenScreen() },
213+
type = SampleType.CAMERAX,
214+
tags = listOf(SampleTags.ML_KIT, SampleTags.ANALYSIS),
215+
),
148216
// To create a new sample entry, add a new SampleCatalogItem here.
149217
)
150218

‎app/src/main/res/values/strings.xml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@
2929
<string name="camerax_zoomandtorch_list_description">Control zoom ratio and the torch with CameraX.</string>
3030
<string name="camerax_exposure_list_title">CameraX • Exposure</string>
3131
<string name="camerax_exposure_list_description">Adjust exposure compensation with CameraX.</string>
32+
<string name="camerax_luminosity_list_title">CameraX • Luminosity</string>
33+
<string name="camerax_luminosity_list_description">Measure scene brightness from the ImageAnalysis stream.</string>
34+
<string name="camerax_ultrahdr_list_title">CameraX • Ultra HDR</string>
35+
<string name="camerax_ultrahdr_list_description">Capture a gain-map Ultra HDR JPEG still.</string>
36+
<string name="camerax_concurrentcamera_list_title">CameraX • Concurrent Camera</string>
37+
<string name="camerax_concurrentcamera_list_description">Preview the front and back cameras at the same time.</string>
38+
<string name="camerax_videopauseresume_list_title">CameraX • Pause/Resume</string>
39+
<string name="camerax_videopauseresume_list_description">Pause and resume a video recording mid-capture.</string>
40+
<string name="camerax_effects_list_title">CameraX • Effects</string>
41+
<string name="camerax_effects_list_description">Apply a live color filter to the camera (grayscale, sepia, invert, and more).</string>
42+
<string name="camerax_greenscreen_list_title">CameraX • Green Screen</string>
43+
<string name="camerax_greenscreen_list_description">Composite the segmented front-camera subject over the live back camera (concurrent + ML Kit).</string>
3244

3345
<!-- Camera2 samples -->
3446
<string name="camera2_takeaphoto_list_title">Camera2 • Take a Photo</string>
@@ -45,4 +57,8 @@
4557
<string name="camera2_zoomandtorch_list_description">Control zoom ratio and the torch with Camera2.</string>
4658
<string name="camera2_manualcontrols_list_title">Camera2 • Manual Controls</string>
4759
<string name="camera2_manualcontrols_list_description">Manual ISO, shutter speed and focus distance.</string>
60+
<string name="camera2_qrscanner_list_title">Camera2 • QR Scanner</string>
61+
<string name="camera2_qrscanner_list_description">Scan QR codes &amp; barcodes with Camera2 and ML Kit.</string>
62+
<string name="camera2_rawcapture_list_title">Camera2 • RAW/DNG</string>
63+
<string name="camera2_rawcapture_list_description">Capture a RAW sensor frame as a DNG, then view and re-edit it (exposure, white balance).</string>
4864
</resources>

‎core-camera/src/main/java/com/android/camera/core/camera2/Camera2Preview.kt‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,15 @@ fun Camera2Preview(
5656
factory = { ctx ->
5757
ViewfinderView(ctx).apply { controller.viewfinder = this }
5858
},
59-
update = { view -> controller.viewfinder = view },
59+
update = { view ->
60+
controller.viewfinder = view
61+
// If the view is (re)attached while the lifecycle is already RESUMED — e.g. returning to
62+
// the preview from another full-screen state — no ON_RESUME is emitted, so open here as
63+
// well. openCamera() is idempotent, so this is a no-op when the camera is already open.
64+
if (lifecycleOwner.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
65+
view.post { controller.openCamera() }
66+
}
67+
},
6068
modifier =
6169
modifier
6270
.fillMaxSize()

‎core-ui/build.gradle.kts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ dependencies {
7070
implementation(libs.ui.tooling.preview)
7171
debugImplementation(libs.ui.tooling)
7272

73-
// Captured-video preview
73+
// Captured-video preview: ExoPlayer + the standard PlayerView UI.
7474
implementation(libs.androidx.media3.exoplayer)
75-
implementation(libs.androidx.media3.ui.compose)
75+
implementation(libs.androidx.media3.ui)
7676

7777
// Re-exports :core-camera + :core-theme (and camera libs) to samples.
7878
api(project(":core-camera"))

0 commit comments

Comments
 (0)