79356049

Date: 2025-01-14 18:44:01
Score: 0.5
Natty:
Report link

I found out that this error is actually a problem with IDE or project structure (I'm not really sure). I found out that the ResolutionStrategy constructor is only available in Java Classes, so I can use it like this:

public class CameraUtils {

    public static ResolutionStrategy createStrategy(Size deviceSize) {

        return new ResolutionStrategy(deviceSize, ResolutionStrategy.FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER);
    }
    public static ResolutionSelector createSelector(Size deviceSize) {
        return new ResolutionSelector.Builder().setResolutionStrategy(createStrategy(deviceSize)).build();
    }
}

And then call the helper class from my Kotlin code:

val camera = LifecycleCameraController(this)
camera.imageAnalysisBackpressureStrategy = ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST
camera.imageAnalysisResolutionSelector = CameraUtils.createSelector(Size(width, height))
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Proteus