RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.82k stars 407 forks source link

Not View Camera #273

Open jackeykabra opened 6 years ago

jackeykabra commented 6 years ago

ActivityJava file: it works perfectly in the SM-T231 device.

MainActivity.kt file: A camera does not display in the SM-T231 device version is 4.4.2 only blank screen is displaying.

When we click on capture button image is display in image view but an orientation problem occurs in this device. I have no change on your existing library code.

 val imageView = findViewById<ImageView>(R.id.result)
 imageView.setImageBitmap(it.bitmap)
 imageView.rotation = (-it.rotationDegrees).toFloat()

I have checked two more device it will worked perfectly. the device is Moto g4 plus and HTC One M9PLUS.

Can you please solve it. Thank you

Diolor commented 6 years ago

How did you initialize FA?

Those 2 activities have different default configurations that your device might not support.

// This is for Kt:
    CameraConfiguration(
                    previewResolution = firstAvailable(
                            wideRatio(highestResolution()),
                            standardRatio(highestResolution())
                    ),
                    previewFpsRange = highestFps(),
                    flashMode = off(),
                    focusMode = firstAvailable(
                            continuousFocusPicture(),
                            autoFocus()
                    ),
                    frameProcessor = {
                        // Do something with the preview frame
                    }
    )

// This is for java:
    CameraConfiguration
            .builder()
            .photoResolution(standardRatio(
                    highestResolution()
            ))
            .focusMode(firstAvailable(
                    continuousFocusPicture(),
                    autoFocus(),
                    fixed()
            ))
            .flash(firstAvailable(
                    autoRedEye(),
                    autoFlash(),
                    torch(),
                    off()
            ))
            .previewFpsRange(highestFps())
            .sensorSensitivity(highestSensorSensitivity())
            .frameProcessor(new SampleFrameProcessor())
            .build();
jackeykabra commented 6 years ago

I haven't any changed in exiting MainActivity.kt file again I checked after you posted a comment but the still same problem that device as I mentioned as above comment.

Initialize FA:

// This is for Kt:
private sealed class Camera(
    val lensPosition: LensPositionSelector,
    val configuration: CameraConfiguration
) {

object Back : Camera(
        lensPosition = back(),
        configuration = CameraConfiguration(
                previewResolution = firstAvailable(
                        wideRatio(highestResolution()),
                        standardRatio(highestResolution())
                ),
                previewFpsRange = highestFps(),
                flashMode = off(),
                focusMode = firstAvailable(
                        continuousFocusPicture(),
                        autoFocus()
                ),
                frameProcessor = {
                    // Do something with the preview frame
                }
        )
)

object Front : Camera(
        lensPosition = front(),
        configuration = CameraConfiguration(
                previewResolution = firstAvailable(
                        wideRatio(highestResolution()),
                        standardRatio(highestResolution())
                ),
                previewFpsRange = highestFps(),
                flashMode = off(),
                focusMode = firstAvailable(
                        fixed(),
                        autoFocus()
                )
        )
)

}