Disable physical focus trigger and orange ring display when AI background mode is active
This commit is contained in:
@@ -757,35 +757,37 @@ class MainActivity : AppCompatActivity() {
|
||||
userSelectedClassFocus = mask[maskY * mW + maskX].toInt()
|
||||
}
|
||||
|
||||
// 1. Gửi lệnh Focus vật lý và đo sáng qua CameraX API (CONTROL_AF_MODE_AUTO, CONTROL_AF_REGIONS, CONTROL_AE_REGIONS)
|
||||
val cameraCtrl = this@MainActivity.cameraControl
|
||||
if (cameraCtrl != null) {
|
||||
try {
|
||||
val factory = binding.viewFinder.meteringPointFactory
|
||||
val point = factory.createPoint(event.x, event.y)
|
||||
val action = androidx.camera.core.FocusMeteringAction.Builder(point, androidx.camera.core.FocusMeteringAction.FLAG_AF or androidx.camera.core.FocusMeteringAction.FLAG_AE)
|
||||
.setAutoCancelDuration(4, java.util.concurrent.TimeUnit.SECONDS)
|
||||
.build()
|
||||
cameraCtrl.startFocusAndMetering(action)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
// 1. Gửi lệnh Focus vật lý và đo sáng qua CameraX API (chỉ khi không sử dụng tính năng AI tách/xóa nền)
|
||||
if (currentBackgroundMode != BackgroundMode.AI_BLUR) {
|
||||
val cameraCtrl = this@MainActivity.cameraControl
|
||||
if (cameraCtrl != null) {
|
||||
try {
|
||||
val factory = binding.viewFinder.meteringPointFactory
|
||||
val point = factory.createPoint(event.x, event.y)
|
||||
val action = androidx.camera.core.FocusMeteringAction.Builder(point, androidx.camera.core.FocusMeteringAction.FLAG_AF or androidx.camera.core.FocusMeteringAction.FLAG_AE)
|
||||
.setAutoCancelDuration(4, java.util.concurrent.TimeUnit.SECONDS)
|
||||
.build()
|
||||
cameraCtrl.startFocusAndMetering(action)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hiện vòng tròn lấy nét màu cam tại vị trí chạm
|
||||
val focusRing = binding.viewFocusRing
|
||||
focusRing.x = event.x - focusRing.width / 2f
|
||||
focusRing.y = event.y - focusRing.height / 2f
|
||||
focusRing.visibility = android.view.View.VISIBLE
|
||||
focusRing.alpha = 1f
|
||||
focusRing.scaleX = 1.4f
|
||||
focusRing.scaleY = 1.4f
|
||||
focusRing.animate()
|
||||
.scaleX(1f).scaleY(1f)
|
||||
.alpha(0f)
|
||||
.setDuration(900)
|
||||
.withEndAction { focusRing.visibility = android.view.View.GONE }
|
||||
.start()
|
||||
// Hiện vòng tròn lấy nét màu cam tại vị trí chạm
|
||||
val focusRing = binding.viewFocusRing
|
||||
focusRing.x = event.x - focusRing.width / 2f
|
||||
focusRing.y = event.y - focusRing.height / 2f
|
||||
focusRing.visibility = android.view.View.VISIBLE
|
||||
focusRing.alpha = 1f
|
||||
focusRing.scaleX = 1.4f
|
||||
focusRing.scaleY = 1.4f
|
||||
focusRing.animate()
|
||||
.scaleX(1f).scaleY(1f)
|
||||
.alpha(0f)
|
||||
.setDuration(900)
|
||||
.withEndAction { focusRing.visibility = android.view.View.GONE }
|
||||
.start()
|
||||
}
|
||||
|
||||
v.performClick()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user