feat: new MFSR (2)
This commit is contained in:
1 parent
ad5eee908d
commit
2ec368bc0e
13 files changed
+1383
-91
No files matched your search
@@ -47,7 +47,7 @@ data class CameraPreset(
|
||||
}
|
||||
|
||||
fun withSupportedCaptureCombination(): CameraPreset {
|
||||
val resolvedUseMFSR = useMFSR && !useRaw && !useMFNR
|
||||
val resolvedUseMFSR = useMFSR && !useMFNR
|
||||
return if (resolvedUseMFSR == useMFSR) {
|
||||
this
|
||||
} else {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -34,6 +34,10 @@ data class RawStackDiagnostics(
|
||||
val sampleStep: Int,
|
||||
val registration: RawStackRegistrationSummary? = null,
|
||||
val registrationQuality: RawStackRegistrationQualitySummary? = null,
|
||||
val superResolutionOutputMode: String? = null,
|
||||
val superResolutionFallbackReason: String? = null,
|
||||
val superResolutionDetailFrameCount: Int = 0,
|
||||
val superResolutionDetailWeightSum: Float = Float.NaN,
|
||||
val flowMagnitudePx: RawStackMetricDistribution = RawStackMetricDistribution.Empty,
|
||||
val alignmentResidual: RawStackMetricDistribution = RawStackMetricDistribution.Empty,
|
||||
val noiseNormalizedResidual: RawStackMetricDistribution = RawStackMetricDistribution.Empty,
|
||||
@@ -41,6 +45,12 @@ data class RawStackDiagnostics(
|
||||
val robustness: RawStackMetricDistribution = RawStackMetricDistribution.Empty,
|
||||
val tileMask: RawStackMetricDistribution = RawStackMetricDistribution.Empty,
|
||||
val accumulatorWeight: RawStackMetricDistribution = RawStackMetricDistribution.Empty,
|
||||
val postfilterResidual: RawStackMetricDistribution = RawStackMetricDistribution.Empty,
|
||||
val postfilterSmooth: RawStackMetricDistribution = RawStackMetricDistribution.Empty,
|
||||
val postfilterEffectiveSmooth: RawStackMetricDistribution = RawStackMetricDistribution.Empty,
|
||||
val postfilterWienerGain: RawStackMetricDistribution = RawStackMetricDistribution.Empty,
|
||||
val postfilterLscBoost: RawStackMetricDistribution = RawStackMetricDistribution.Empty,
|
||||
val postfilterLowWeightBoost: RawStackMetricDistribution = RawStackMetricDistribution.Empty,
|
||||
val rejectedTileRatio: Float = Float.NaN,
|
||||
val flowOutlierRatio: Float = Float.NaN,
|
||||
val highConfidenceTileRatio: Float = Float.NaN,
|
||||
@@ -53,10 +63,15 @@ data class RawStackDiagnostics(
|
||||
fun compactSummary(): String {
|
||||
val registrationSummary = registration?.compactSummary()?.let { "$it " }.orEmpty()
|
||||
val registrationQualitySummary = registrationQuality?.compactSummary()?.let { "$it " }.orEmpty()
|
||||
val superResolutionSummary = superResolutionOutputMode?.let { mode ->
|
||||
"srOut=$mode srReason=${superResolutionFallbackReason ?: "ok"} " +
|
||||
"srFrames=$superResolutionDetailFrameCount srWeight=${superResolutionDetailWeightSum.fmt()} "
|
||||
}.orEmpty()
|
||||
return "HWMF diag mode=$mode frames=$frameCount aligned=$alignedFrameCount " +
|
||||
"size=${width}x$height step=$sampleStep " +
|
||||
registrationSummary +
|
||||
registrationQualitySummary +
|
||||
superResolutionSummary +
|
||||
"flowMean=${flowMagnitudePx.mean.fmt()} flowP90=${flowMagnitudePx.p90.fmt()} " +
|
||||
"flowMax=${flowMagnitudePx.max.fmt()} flowOut=${flowOutlierRatio.percent()} " +
|
||||
"resP90=${alignmentResidual.p90.fmt()} resN90=${noiseNormalizedResidual.p90.fmt()} " +
|
||||
@@ -66,6 +81,11 @@ data class RawStackDiagnostics(
|
||||
"hiConf=${highConfidenceTileRatio.percent()} srAlign=${srAlignmentReadyRatio.percent()} " +
|
||||
"srDetail=${srDetailReadyRatio.percent()} " +
|
||||
"weightMean=${accumulatorWeight.mean.fmt()} weightP10=${accumulatorWeight.p10.fmt()} " +
|
||||
"postResP50=${postfilterResidual.p50.fmt()} postResP90=${postfilterResidual.p90.fmt()} " +
|
||||
"postSmoothMean=${postfilterSmooth.mean.fmt()} postSmoothP90=${postfilterSmooth.p90.fmt()} " +
|
||||
"postEffMean=${postfilterEffectiveSmooth.mean.fmt()} postEffP90=${postfilterEffectiveSmooth.p90.fmt()} " +
|
||||
"postWienerP50=${postfilterWienerGain.p50.fmt()} " +
|
||||
"postLsc=${postfilterLscBoost.mean.fmt()} postLowW=${postfilterLowWeightBoost.mean.fmt()} " +
|
||||
"lscMean=${lensShadingMeanGain.fmt()} lscEdge=${lensShadingEdgeMeanGain.fmt()} " +
|
||||
"elapsed=${elapsedMs}ms"
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ data class RawStackGlobalRegistrationCandidate(
|
||||
|
||||
data class RawStackRegistrationEstimate(
|
||||
val transform: RawStackPerspectiveTransform,
|
||||
val candidateTransform: RawStackPerspectiveTransform = transform,
|
||||
val sampleCount: Int,
|
||||
val usedSampleCount: Int,
|
||||
val inlierRatio: Float,
|
||||
@@ -123,6 +124,7 @@ object RawStackFrameRegistrationEstimator {
|
||||
}
|
||||
return RawStackRegistrationEstimate(
|
||||
transform = transform,
|
||||
candidateTransform = fittedTransform,
|
||||
sampleCount = sortedCandidates.size,
|
||||
usedSampleCount = 1,
|
||||
inlierRatio = best.coverage.coerceIn(0f, 1f),
|
||||
@@ -213,6 +215,7 @@ object RawStackFrameRegistrationEstimator {
|
||||
}
|
||||
return RawStackRegistrationEstimate(
|
||||
transform = transform,
|
||||
candidateTransform = fittedTransform,
|
||||
sampleCount = samples.size,
|
||||
usedSampleCount = usedCount,
|
||||
inlierRatio = inlierRatio,
|
||||
|
||||
@@ -184,6 +184,37 @@ data class RawStackRegistrationSetup(
|
||||
forceIdentityThreshold = confidenceConfig.forceIdentityThreshold,
|
||||
)
|
||||
}
|
||||
|
||||
fun requiredPyramidLevels(): Int {
|
||||
return if (ds64Enabled) {
|
||||
REGISTRATION_CONTEXT_LEVELS.first { it.name == "DS64" }.pyramidLevel + 1
|
||||
} else {
|
||||
REGISTRATION_CONTEXT_LEVELS.first { it.name == "DS16" }.pyramidLevel + 1
|
||||
}
|
||||
}
|
||||
|
||||
fun referenceContextSummary(): String {
|
||||
val levels = if (ds64Enabled) {
|
||||
REGISTRATION_CONTEXT_LEVELS
|
||||
} else {
|
||||
REGISTRATION_CONTEXT_LEVELS.filterNot { it.name == "DS64" }
|
||||
}
|
||||
return levels.joinToString("/") { it.name }
|
||||
}
|
||||
|
||||
companion object {
|
||||
private data class RegistrationContextLevel(
|
||||
val name: String,
|
||||
val pyramidLevel: Int,
|
||||
)
|
||||
|
||||
private val REGISTRATION_CONTEXT_LEVELS = listOf(
|
||||
RegistrationContextLevel("FULL", 0),
|
||||
RegistrationContextLevel("DS4", 2),
|
||||
RegistrationContextLevel("DS16", 4),
|
||||
RegistrationContextLevel("DS64", 6),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
data class RawStackRegistrationSummary(
|
||||
|
||||
@@ -71,6 +71,34 @@ data class RawStackBlendTuning(
|
||||
val sensorPrecisionReferenceSignal: Float = 0.18f,
|
||||
val lscNoiseGainMax: Float = 4.0f,
|
||||
val wienerBaseWeight: Float = 0.25f,
|
||||
val denoiseSignalLow: Float = 0.015f,
|
||||
val denoiseSignalHigh: Float = 0.14f,
|
||||
val denoiseLscGainStart: Float = 1.35f,
|
||||
val denoiseLscGainEnd: Float = 3.0f,
|
||||
val denoiseStaticRobustStart: Float = 0.54f,
|
||||
val denoiseStaticRobustEnd: Float = 0.92f,
|
||||
val denoiseStaticTileStart: Float = 0.42f,
|
||||
val denoiseStaticTileEnd: Float = 0.86f,
|
||||
val denoiseNonReferenceWeightBoost: Float = 1.75f,
|
||||
val denoiseNonReferenceWeightFloor: Float = 0.34f,
|
||||
val denoiseReferenceDarkWeightScale: Float = 0.72f,
|
||||
val denoiseRelaxedRegistrationConfidenceMin: Int = 80,
|
||||
val denoiseRelaxedRegistrationCoverageMin: Float = 0.90f,
|
||||
val denoiseRelaxedRegistrationMarginMin: Float = 0.008f,
|
||||
val denoiseRelaxedRegistrationScoreMax: Float = 0.045f,
|
||||
val denoiseRelaxedRegistrationTranslationMaxPx: Float = 8.0f,
|
||||
val denoiseStaticRegistrationMarginMin: Float = 0.004f,
|
||||
val denoiseStaticRegistrationTranslationMaxPx: Float = 1.25f,
|
||||
val denoiseSeedRegistrationMarginMin: Float = 0.004f,
|
||||
val denoiseSeedRegistrationConfidenceMin: Int = 80,
|
||||
val denoiseSeedRegistrationDeltaMaxPx: Float = 0.85f,
|
||||
val denoiseSeedTightRegistrationMarginMin: Float = 0.0005f,
|
||||
val denoiseSeedTightRegistrationDeltaMaxPx: Float = 0.20f,
|
||||
val denoiseSeedTightRegistrationTranslationMaxPx: Float = 1.0f,
|
||||
val denoiseConsistentRegistrationConfidenceMin: Int = 72,
|
||||
val denoiseConsistentRegistrationMarginMin: Float = 0.0018f,
|
||||
val denoiseConsistentRegistrationMinAccepted: Int = 2,
|
||||
val denoiseConsistentRegistrationDeltaMaxPx: Float = 1.35f,
|
||||
val highlightSuppressionStrength: Float = 0.62f,
|
||||
val highlightSuppressionStart: Float = 0.78f,
|
||||
val highlightSuppressionEnd: Float = 0.98f,
|
||||
@@ -86,6 +114,21 @@ data class RawStackPostfilterTuning(
|
||||
val detailKeepOffsetHigh: Float = 0.010f,
|
||||
val detailKeepSuppression: Float = 0.85f,
|
||||
val lscNoiseGainMax: Float = 4.0f,
|
||||
val noiseFloorVariance: Float = 0.000018f,
|
||||
val lowLightSignalLow: Float = 0.015f,
|
||||
val lowLightSignalHigh: Float = 0.16f,
|
||||
val lowLightSmoothBoost: Float = 1.15f,
|
||||
val lscSmoothGainStart: Float = 1.35f,
|
||||
val lscSmoothGainEnd: Float = 3.2f,
|
||||
val lscSmoothBoost: Float = 0.75f,
|
||||
val lowWeightStart: Float = 1.2f,
|
||||
val lowWeightEnd: Float = 4.5f,
|
||||
val lowWeightSmoothBoost: Float = 0.55f,
|
||||
val residualNoiseWeight: Float = 0.85f,
|
||||
val residualNoiseLowScale: Float = 1.5f,
|
||||
val residualNoiseHighScale: Float = 6.0f,
|
||||
val residualSmoothBoost: Float = 1.10f,
|
||||
val maxSmoothStrength: Float = 0.92f,
|
||||
val hdrRecoverySmoothSuppression: Float = 0.65f,
|
||||
)
|
||||
|
||||
@@ -103,5 +146,20 @@ data class RawStackSuperResolutionTuning(
|
||||
val splatRadius: Float = 1.0f,
|
||||
val minEffectiveWeight: Float = 0.35f,
|
||||
val holeFillPasses: Int = 2,
|
||||
val detailRestoreStrength: Float = 0.35f,
|
||||
val detailRestoreStrength: Float = 0.75f,
|
||||
val fallbackMinAlignedFrames: Int = 3,
|
||||
val fallbackMinDetailFrames: Int = 1,
|
||||
val fallbackMinDetailWeightSum: Float = 0.75f,
|
||||
val registrationConfidenceStart: Int = 100,
|
||||
val registrationConfidenceFull: Int = 170,
|
||||
val registrationMarginStart: Float = 0.012f,
|
||||
val registrationMarginFull: Float = 0.060f,
|
||||
val registrationCoverageStart: Float = 0.82f,
|
||||
val registrationCoverageFull: Float = 0.90f,
|
||||
val registrationSeedDistanceStartPx: Float = 0.50f,
|
||||
val registrationSeedDistanceEndPx: Float = 1.50f,
|
||||
val registrationConsistencyDistanceStartPx: Float = 1.25f,
|
||||
val registrationConsistencyDistanceEndPx: Float = 2.50f,
|
||||
val detailLowLightSuppression: Float = 0.70f,
|
||||
val detailLscSuppression: Float = 0.55f,
|
||||
)
|
||||
@@ -534,15 +534,9 @@ fun CameraScreen(
|
||||
var targetUseMFNR = preset?.useMFNR ?: false
|
||||
var targetUseMFSR = preset?.useMFSR ?: false
|
||||
|
||||
if (targetUseRaw) {
|
||||
targetUseMFSR = false
|
||||
}
|
||||
if (targetUseMFNR) {
|
||||
targetUseMFSR = false
|
||||
}
|
||||
if (targetUseMFSR && targetUseRaw) {
|
||||
targetUseMFSR = false
|
||||
}
|
||||
|
||||
return targetAspectRatio != state.aspectRatio ||
|
||||
targetUseRaw != useRaw ||
|
||||
@@ -1512,9 +1506,9 @@ fun CameraScreen(
|
||||
onMFNRToggle = {
|
||||
viewModel.setUseMFNR(it)
|
||||
},
|
||||
useHdrComposition = useHdrComposition,
|
||||
onHdrCompositionToggle = {
|
||||
viewModel.setUseHdrComposition(it)
|
||||
useMFSR = useMFSR,
|
||||
onMFSRToggle = {
|
||||
viewModel.setUseMFSR(it)
|
||||
},
|
||||
useMultipleExposure = useMultipleExposure,
|
||||
onMultipleExposureToggle = { viewModel.setUseMultipleExposure(it) },
|
||||
|
||||
@@ -113,8 +113,8 @@ fun CameraTopSheet(
|
||||
onMoreSettingsClick: () -> Unit,
|
||||
useMFNR: Boolean,
|
||||
onMFNRToggle: (Boolean) -> Unit,
|
||||
useHdrComposition: Boolean,
|
||||
onHdrCompositionToggle: (Boolean) -> Unit,
|
||||
useMFSR: Boolean,
|
||||
onMFSRToggle: (Boolean) -> Unit,
|
||||
useMultipleExposure: Boolean,
|
||||
onMultipleExposureToggle: (Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
@@ -220,9 +220,9 @@ fun CameraTopSheet(
|
||||
)
|
||||
|
||||
QuickSettingToggle(
|
||||
title = stringResource(R.string.settings_use_hdr_composition),
|
||||
checked = useHdrComposition,
|
||||
onCheckedChange = onHdrCompositionToggle,
|
||||
title = stringResource(R.string.settings_use_super_resolution),
|
||||
checked = useMFSR,
|
||||
onCheckedChange = onMFSRToggle,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
|
||||
|
||||
@@ -1682,7 +1682,7 @@ private fun ZoomableImage(
|
||||
color = Color.Black.copy(alpha = 0.58f),
|
||||
modifier = Modifier
|
||||
.align(Alignment.TopStart)
|
||||
.padding(16.dp)
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.gallery_raw_badge),
|
||||
|
||||
@@ -281,6 +281,22 @@ fun PresetEditorScreen(
|
||||
checked = useMFNR,
|
||||
onCheckedChange = {
|
||||
useMFNR = it
|
||||
if (it) {
|
||||
useMFSR = false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
HorizontalDivider(color = Color.White.copy(alpha = 0.05f), modifier = Modifier.padding(vertical = 8.dp))
|
||||
|
||||
SwitchSettingItem(
|
||||
title = stringResource(R.string.settings_use_super_resolution),
|
||||
checked = useMFSR,
|
||||
onCheckedChange = {
|
||||
useMFSR = it
|
||||
if (it) {
|
||||
useMFNR = false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ fun SettingsScreen(
|
||||
val vendorCaptureSettingsByLens by viewModel.vendorCaptureSettingsByLens.collectAsState()
|
||||
val useRaw by viewModel.useRaw.collectAsState(initial = false)
|
||||
val exportDngWithRawExport by viewModel.exportDngWithRawExport.collectAsState(initial = true)
|
||||
val useSuperResolution by viewModel.useMFSR.collectAsState(initial = false)
|
||||
val useHdrComposition by viewModel.useHdrComposition.collectAsState(initial = false)
|
||||
// 软件处理参数
|
||||
val sharpening by viewModel.sharpening.collectAsState(initial = 0f)
|
||||
val noiseReduction by viewModel.noiseReduction.collectAsState(initial = 0f)
|
||||
@@ -1501,6 +1501,17 @@ fun SettingsScreen(
|
||||
|
||||
// 多帧与曝光
|
||||
SettingsSection(title = stringResource(R.string.settings_section_multiframe_exposure)) {
|
||||
SwitchSettingItem(
|
||||
title = stringResource(R.string.settings_use_hdr_composition),
|
||||
checked = useHdrComposition,
|
||||
onCheckedChange = { viewModel.setUseHdrComposition(it) }
|
||||
)
|
||||
|
||||
HorizontalDivider(
|
||||
color = Color.White.copy(alpha = 0.1f),
|
||||
modifier = Modifier.padding(vertical = 12.dp)
|
||||
)
|
||||
|
||||
SliderSettingItem(
|
||||
title = stringResource(R.string.settings_multi_frame_count),
|
||||
description = stringResource(R.string.settings_multi_frame_count_description),
|
||||
|
||||
@@ -558,19 +558,14 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
|
||||
if (update.useRaw?.value == true) {
|
||||
desiredUseMultipleExposure = false
|
||||
desiredUseMFSR = false
|
||||
}
|
||||
if (update.useMFNR?.value == true) {
|
||||
desiredUseMultipleExposure = false
|
||||
desiredUseMFSR = false
|
||||
}
|
||||
if (update.useMFSR?.value == true) {
|
||||
if (desiredUseRaw) {
|
||||
desiredUseMFSR = false
|
||||
} else {
|
||||
desiredUseMultipleExposure = false
|
||||
desiredUseMFNR = false
|
||||
}
|
||||
desiredUseMultipleExposure = false
|
||||
desiredUseMFNR = false
|
||||
}
|
||||
if (update.useMultipleExposure?.value == true) {
|
||||
desiredUseRaw = false
|
||||
@@ -671,7 +666,11 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
lutId = update.lutId?.let { PreferenceUpdateValue(it.value) },
|
||||
effects = update.effects?.let { PreferenceUpdateValue(it.value) },
|
||||
aspectRatio = update.aspectRatio?.let { PreferenceUpdateValue(it.value.name) },
|
||||
useRaw = update.useRaw?.let { PreferenceUpdateValue(desiredUseRaw) },
|
||||
useRaw = if (update.useRaw != null || desiredUseRaw != prefs.useRaw) {
|
||||
PreferenceUpdateValue(desiredUseRaw)
|
||||
} else {
|
||||
null
|
||||
},
|
||||
useMFNR = if (update.useMFNR != null || desiredUseMFNR != prefs.useMFNR) {
|
||||
PreferenceUpdateValue(desiredUseMFNR)
|
||||
} else {
|
||||
|
||||
+3
@@ -38,12 +38,15 @@ class RawStackFrameRegistrationEstimatorTest {
|
||||
),
|
||||
)
|
||||
val matrix = estimate.transform.matrixAt(0)
|
||||
val candidateMatrix = estimate.candidateTransform.matrixAt(0)
|
||||
|
||||
assertTrue(estimate.forceIdentity)
|
||||
assertEquals(RawStackRegistrationSource.IMAGE_TRANSLATION, estimate.source)
|
||||
assertTrue(estimate.confidence < setup.confidenceConfig.forceIdentityThreshold)
|
||||
assertEquals(0f, matrix[2], 0f)
|
||||
assertEquals(0f, matrix[5], 0f)
|
||||
assertEquals(8f, candidateMatrix[2], 0.0001f)
|
||||
assertEquals(-4f, candidateMatrix[5], 0.0001f)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user