Implement 34_FIX_BG.md: restore high-quality AI background replacement and blur blending for captured photos in the background thread, while maintaining lag-free early bypass for viewfinder preview
This commit is contained in:
@@ -1722,9 +1722,17 @@ class MainActivity : AppCompatActivity() {
|
||||
capturedImage: android.graphics.Bitmap,
|
||||
isStreamMode: Boolean = false
|
||||
): android.graphics.Bitmap {
|
||||
// Chỉ chạy các thuật toán xử lý phân đoạn AI hoặc mờ phần mềm khi bật chế độ AI_BLUR
|
||||
if (currentBackgroundMode != BackgroundMode.AI_BLUR) {
|
||||
return capturedImage
|
||||
if (isStreamMode) {
|
||||
// Khi xem trước (Viewfinder stream): chỉ chạy AI khi thực sự thay nền (AI_BLUR) để tránh lag
|
||||
if (currentBackgroundMode != BackgroundMode.AI_BLUR) {
|
||||
return capturedImage
|
||||
}
|
||||
} else {
|
||||
// Khi chụp lưu ảnh (isStreamMode = false): chạy AI khi chèn hình nền HOẶC khi có xóa phông (blurIntensity > 0)
|
||||
val isBgActive = (selectedBgAssetPath != null) || (blurIntensity > 0f)
|
||||
if (!isBgActive) {
|
||||
return capturedImage
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAiSupported) {
|
||||
|
||||
Reference in New Issue
Block a user