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()
|
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)
|
// 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)
|
||||||
val cameraCtrl = this@MainActivity.cameraControl
|
if (currentBackgroundMode != BackgroundMode.AI_BLUR) {
|
||||||
if (cameraCtrl != null) {
|
val cameraCtrl = this@MainActivity.cameraControl
|
||||||
try {
|
if (cameraCtrl != null) {
|
||||||
val factory = binding.viewFinder.meteringPointFactory
|
try {
|
||||||
val point = factory.createPoint(event.x, event.y)
|
val factory = binding.viewFinder.meteringPointFactory
|
||||||
val action = androidx.camera.core.FocusMeteringAction.Builder(point, androidx.camera.core.FocusMeteringAction.FLAG_AF or androidx.camera.core.FocusMeteringAction.FLAG_AE)
|
val point = factory.createPoint(event.x, event.y)
|
||||||
.setAutoCancelDuration(4, java.util.concurrent.TimeUnit.SECONDS)
|
val action = androidx.camera.core.FocusMeteringAction.Builder(point, androidx.camera.core.FocusMeteringAction.FLAG_AF or androidx.camera.core.FocusMeteringAction.FLAG_AE)
|
||||||
.build()
|
.setAutoCancelDuration(4, java.util.concurrent.TimeUnit.SECONDS)
|
||||||
cameraCtrl.startFocusAndMetering(action)
|
.build()
|
||||||
} catch (e: Exception) {
|
cameraCtrl.startFocusAndMetering(action)
|
||||||
e.printStackTrace()
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Hiện vòng tròn lấy nét màu cam tại vị trí chạm
|
// Hiện vòng tròn lấy nét màu cam tại vị trí chạm
|
||||||
val focusRing = binding.viewFocusRing
|
val focusRing = binding.viewFocusRing
|
||||||
focusRing.x = event.x - focusRing.width / 2f
|
focusRing.x = event.x - focusRing.width / 2f
|
||||||
focusRing.y = event.y - focusRing.height / 2f
|
focusRing.y = event.y - focusRing.height / 2f
|
||||||
focusRing.visibility = android.view.View.VISIBLE
|
focusRing.visibility = android.view.View.VISIBLE
|
||||||
focusRing.alpha = 1f
|
focusRing.alpha = 1f
|
||||||
focusRing.scaleX = 1.4f
|
focusRing.scaleX = 1.4f
|
||||||
focusRing.scaleY = 1.4f
|
focusRing.scaleY = 1.4f
|
||||||
focusRing.animate()
|
focusRing.animate()
|
||||||
.scaleX(1f).scaleY(1f)
|
.scaleX(1f).scaleY(1f)
|
||||||
.alpha(0f)
|
.alpha(0f)
|
||||||
.setDuration(900)
|
.setDuration(900)
|
||||||
.withEndAction { focusRing.visibility = android.view.View.GONE }
|
.withEndAction { focusRing.visibility = android.view.View.GONE }
|
||||||
.start()
|
.start()
|
||||||
|
}
|
||||||
|
|
||||||
v.performClick()
|
v.performClick()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user