Kivy Android Camera API 2 - Camera Rotation

376 Views Asked by At

I am using the camera feature defined in the following repo but with some changes. I just want to rotate the SurfaceTexture defined in camera2.py so that the camera can also work in portrait mode.

I tried Push- and Pop- Matrix solution but it shadows the buttons in the camera. Hence, I want it to be solved on the Java side rather than the Kivy side.

This is the link to the repo: https://github.com/inclement/colour-blind-camera

This is where the main problem lies in:

https://github.com/inclement/colour-blind-camera/blob/master/camera2/camera2.py

I do not add the whole snippet here since it is too long but it is basically somewhere around the following snippet (Line 263):

    self.preview_resolution = resolution
    self._prepare_preview_fbo(resolution)
    self.preview_texture = Texture(
        width=resolution[0], height=resolution[1], target=GL_TEXTURE_EXTERNAL_OES, colorfmt="rgba")
    logger.info("Texture id is {}".format(self.preview_texture.id))
    self.java_preview_surface_texture = SurfaceTexture(int(self.preview_texture.id))
    self.java_preview_surface_texture.setDefaultBufferSize(*resolution)
    self.java_preview_surface = Surface(self.java_preview_surface_texture)

Any help appreciated a lot!

0

There are 0 best solutions below