Sandeep Agrawal
Sandeep Agrawal

Reputation: 576

cameraX android capturing more area while image capture

I am trying camexaX library for capturing the image but it is capturing more space from left and right.

enter image description here

I captured the area between Q to O alphabet in preview but it has captured more area around Q and O.

    /**
 * Bind the Camera to the lifecycle
 */
private fun bindCamera(){
    CameraX.unbindAll()

    // Preview config for the camera
    val previewConfig = PreviewConfig.Builder()
        .setLensFacing(lensFacing)
        .build()

    val preview = Preview(previewConfig)

    // Image capture config which controls the Flash and Lens
    val imageCaptureConfig = ImageCaptureConfig.Builder()
        .setTargetRotation(windowManager.defaultDisplay.rotation)
        .setLensFacing(lensFacing)
        .setFlashMode(FlashMode.ON)
        .build()

    imageCapture = ImageCapture(imageCaptureConfig)

    // The view that displays the preview
    val textureView: TextureView = findViewById(R.id.view_finder)

    // Handles the output data of the camera
    preview.setOnPreviewOutputUpdateListener { previewOutput ->
        // Displays the camera image in our preview view
        textureView.surfaceTexture = previewOutput.surfaceTexture
    }

    // Bind the camera to the lifecycle
    CameraX.bindToLifecycle(this as LifecycleOwner, imageCapture, preview)
}

Can some one help me here?

Upvotes: 1

Views: 919

Answers (1)

Ognjen Bogicevic
Ognjen Bogicevic

Reputation: 29

This is normal behaviour because your camera records wider angle than your Preview can show. Preview will only adapt the picture height and width to the size that it can display and ImageCapture will capture the picture independently as if there is no Preview.

It is important to realize that all of the use cases CameraX provide (Preview, ImageAnalysis and ImageCapture) can work independently. Meaning, you can use your ImageCapture even without the Preview. Same goes for the ImageAnalysis and Preveiw.

Upvotes: 0

Related Questions