0

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!

  • Rather than rotating the SurfaceTexture, why not just manipulate the way it is displayed in the app? This is straightforward and possibly easier. – inclement Jun 30 '20 at 22:37
  • Do you mean changing the mode from landscape to portrait? I put this camera into a screen and the main app should remain in portrait mode. Would you suggest me any manipulation technique since I could not come up with any idea other than Pop- and Push- matrices which shadow the buttons on the screen. Thank you !!! – Fazilet Gokbudak Jul 01 '20 at 08:35
  • The camera apparatus ends up giving you a kivy Texture. You can display that Texture however you like. Using Pop and Push matrices is fine and could be a component of this, if you have issues with that then you're probably doing something wrong. You can also manipulate the tex_coords when displaying the texture. – inclement Jul 01 '20 at 18:40
  • Manipulating the tex_coords seems to be working. Thank you. I was wondering how to exactly decide the items of the list. I found this link: https://blog.kivy.org/2014/02/using-tex_coords-in-kivy-for-fun-and-profit/. However, I could not understand well what to change for a flip. – Fazilet Gokbudak Jul 01 '20 at 21:55
  • I managed to rotate the camera screen by moving the first two items of the tex_coord list to the end, but it ends up causing scaling problems since the screen is not a square. Do you have any suggestions for what to do to solve this issue? – Fazilet Gokbudak Jul 02 '20 at 10:53

0 Answers0