• R/O
  • HTTP
  • SSH
  • HTTPS

mangle: Commit

a01e


Commit MetaInfo

Revision64204503fe4c081c8308a2e78eed76a974da489b (tree)
Time2021-11-25 23:59:52
AuthorMRSa <mrsa@myad...>
CommiterMRSa

Log Message

cameraXの少し更新。

Change Summary

Incremental Difference

--- a/app/build.gradle
+++ b/app/build.gradle
@@ -34,17 +34,17 @@ dependencies {
3434 implementation fileTree(dir: "libs", include: ["*.jar"])
3535 implementation 'androidx.exifinterface:exifinterface:1.3.3'
3636 implementation "androidx.core:core-ktx:1.7.0"
37- implementation 'androidx.appcompat:appcompat:1.3.1'
38- implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
37+ implementation 'androidx.appcompat:appcompat:1.4.0'
38+ implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
3939 implementation 'androidx.preference:preference-ktx:1.1.1'
4040 implementation 'com.google.android.material:material:1.4.0'
4141
42- def camerax_version = "1.1.0-alpha10"
42+ def camerax_version = "1.1.0-alpha11"
4343 implementation "androidx.camera:camera-core:$camerax_version"
4444 implementation "androidx.camera:camera-camera2:$camerax_version"
4545 implementation "androidx.camera:camera-lifecycle:$camerax_version"
4646
47- def camerax_view_version = "1.0.0-alpha30"
47+ def camerax_view_version = "1.0.0-alpha31"
4848 implementation "androidx.camera:camera-extensions:$camerax_view_version"
4949 implementation "androidx.camera:camera-view:$camerax_view_version"
5050
--- a/app/src/main/java/jp/osdn/gokigen/gokigenassets/camera/vendor/camerax/operation/CameraControl.kt
+++ b/app/src/main/java/jp/osdn/gokigen/gokigenassets/camera/vendor/camerax/operation/CameraControl.kt
@@ -159,55 +159,10 @@ class CameraControl(private val activity : AppCompatActivity, private val prefer
159159 val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()
160160 val imageCapture = fileControl.prepare()
161161 val option1 = preference.getCameraOption1() // プレビューサイズを設定する
162- val previewSize = if (option1.isNotBlank()) {
163- when (option1) {
164- "_8K" -> Size(4320, 7680)
165- "_6K" -> Size(3384, 6016)
166- "_4K" -> Size(4096, 2160)
167- "_WQHD" -> Size(2560, 1440)
168- "_2K" -> Size(2048, 1080)
169- "_FHD" -> Size(1920, 1080)
170- "_SXGA" -> Size(1280, 1024) // SXGA : 1600x1200 @ Pixel3a
171- "_XGA" -> Size(1024, 768) // XGA : 1600x1200 @ Pixel3a
172- "_SVGA" -> Size(800, 600) // SVGA : 1280x960 @ Pixel3a
173- "_VGA" -> Size(640, 480) // SVGA : 1280x960 @ Pixel3a
174- "8K" -> Size(7680, 4320)
175- "6K" -> Size(6016, 3384)
176- "4K" -> Size(2160, 4096)
177- "WQHD" -> Size(1440, 2560)
178- "2K" -> Size(1080, 2048)
179- "FHD" -> Size(1080, 1920)
180- "SXGA" -> Size(1024, 1280)
181- "XGA" -> Size(768, 1024)
182- "SVGA" -> Size(600, 800)
183- "VGA" -> Size(480, 640)
184- else -> Size(480, 640) // VGA : 1024x768 @ Pixel3a
185- }
186- }
187- else
188- {
189- Size(640, 480)
190- }
162+ val option2 = preference.getCameraOption2() // テスト用オプション...
191163 try
192164 {
193- val imageAnalyzer = if (option1.isNotBlank()) {
194- ImageAnalysis.Builder()
195- .setTargetResolution(previewSize)
196- .setTargetRotation(getImageRotation())
197- .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
198- .build()
199- .also {
200- it.setAnalyzer(cameraExecutor, liveViewListener)
201- }
202- } else {
203- ImageAnalysis.Builder()
204- .setTargetRotation(getImageRotation())
205- .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
206- .build()
207- .also {
208- it.setAnalyzer(cameraExecutor, liveViewListener)
209- }
210- }
165+ val imageAnalyzer = getImageAnalysis(option1, option2)
211166 cameraProvider.unbindAll()
212167 cameraXCamera = cameraProvider.bindToLifecycle(activity, cameraSelector, imageCapture, imageAnalyzer)
213168 cameraXCameraControl.setCameraControl(cameraXCamera)
@@ -223,6 +178,85 @@ class CameraControl(private val activity : AppCompatActivity, private val prefer
223178 }, ContextCompat.getMainExecutor(activity))
224179 }
225180
181+ private fun getImageAnalysis(option1 : String, option2 : String) : ImageAnalysis
182+ {
183+ Log.v(TAG, " getImageAnalysis(option1 = '$option1', option2 = '$option2') ")
184+ val previewSize = if (option1.isNotBlank()) {
185+ when (option1) {
186+ "_8K" -> Size(4320, 7680)
187+ "_6K" -> Size(3384, 6016)
188+ "_4K" -> Size(4096, 2160)
189+ "_WQHD" -> Size(2560, 1440)
190+ "_2K" -> Size(2048, 1080)
191+ "_FHD" -> Size(1920, 1080)
192+ "_SXGA" -> Size(1280, 1024) // SXGA : 1600x1200 @ Pixel3a
193+ "_XGA" -> Size(1024, 768) // XGA : 1600x1200 @ Pixel3a
194+ "_SVGA" -> Size(800, 600) // SVGA : 1280x960 @ Pixel3a
195+ "_VGA" -> Size(640, 480) // SVGA : 1280x960 @ Pixel3a
196+ "8K" -> Size(7680, 4320)
197+ "6K" -> Size(6016, 3384)
198+ "4K" -> Size(2160, 4096)
199+ "WQHD" -> Size(1440, 2560)
200+ "2K" -> Size(1080, 2048)
201+ "FHD" -> Size(1080, 1920)
202+ "SXGA" -> Size(1024, 1280)
203+ "XGA" -> Size(768, 1024)
204+ "SVGA" -> Size(600, 800)
205+ "VGA" -> Size(480, 640)
206+ else -> Size(480, 640) // VGA : 1024x768 @ Pixel3a
207+ }
208+ }
209+ else
210+ {
211+ Size(640, 480)
212+ }
213+ //val useImageFormatOption = false
214+ return (//if (!useImageFormatOption) {
215+ if (option1.isNotBlank()) {
216+ ImageAnalysis.Builder()
217+ .setTargetResolution(previewSize)
218+ .setTargetRotation(getImageRotation())
219+ .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
220+ .build()
221+ .also {
222+ it.setAnalyzer(cameraExecutor, liveViewListener)
223+ }
224+ } else {
225+ ImageAnalysis.Builder()
226+ .setTargetRotation(getImageRotation())
227+ .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
228+ .build()
229+ .also {
230+ it.setAnalyzer(cameraExecutor, liveViewListener)
231+ }
232+ }
233+ //}
234+ /*else
235+ {
236+ if (option1.isNotBlank()) {
237+ ImageAnalysis.Builder()
238+ .setTargetResolution(previewSize)
239+ .setTargetRotation(getImageRotation())
240+ .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
241+ .setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_RGBA_8888)
242+ .build()
243+ .also {
244+ it.setAnalyzer(cameraExecutor, liveViewListener)
245+ }
246+ } else {
247+ ImageAnalysis.Builder()
248+ .setTargetRotation(getImageRotation())
249+ .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
250+ .setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_RGBA_8888)
251+ .build()
252+ .also {
253+ it.setAnalyzer(cameraExecutor, liveViewListener)
254+ }
255+ }
256+ }*/
257+ )
258+ }
259+
226260 @SuppressLint("UnsafeOptInUsageError")
227261 private fun setCaptureRequestOptions(cameraControl : androidx.camera.core.CameraControl)
228262 {
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,6 @@
11 // Top-level build file where you can add configuration options common to all sub-projects/modules.
22 buildscript {
3- ext.kotlin_version = "1.5.31"
3+ ext.kotlin_version = "1.6.0"
44 repositories {
55 google()
66 mavenCentral()
Show on old repository browser