Kivy Camera display is rotated -90 degrees

kivy display
kivy clear screen
kivy get screen
kivy screen keyboard
kivy reset screen
kivy screen on exit
kivy screen layout
kivy split screen

I am accessing my camera in android 4.4 using python with kivy framework.

This is my simple code:

from kivy.app import App
from kivy.uix.camera import Camera
from kivy.core.window import Window

class CamApp(App):
    def build(self):
        return Camera(resolution= Window.size)

CamApp().run()

But when I ran my code, it displayed this:

Ideally, it should look like this:

It looks like the kivy Camera is displaying the output with a built in -90 degrees. Is this normal or a bug? Or should I rotate the display myself?


I think this is a bug, but you can rotate the widget if you use this code:

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
import time
Builder.load_string('''
<CameraClick>:
    orientation: 'vertical'
    Camera:
        id: camera
        resolution: (640, 480)
        play: False
    ToggleButton:
        text: 'Play'
        on_press: camera.play = not camera.play
        size_hint_y: None
        height: '48dp'
    Button:
        text: 'Capture'
        size_hint_y: None
        height: '48dp'
        on_press: root.capture()
    canvas.before:
        PushMatrix
        Rotate:
            angle: -90
            origin: self.center
    canvas.after:
        PopMatrix
''')


class CameraClick(BoxLayout):
    def capture(self):
        '''
        Function to capture the images and give them the names
        according to their captured time and date.
        '''
        camera = self.ids['camera']
        timestr = time.strftime("%Y%m%d_%H%M%S")
        camera.export_to_png("IMG_{}.png".format(timestr))
        print("Captured")


class TestCamera(App):

    def build(self):
        return CameraClick()


TestCamera().run()

This worked for me on android.

Scatter, kivy.uix.boxlayout · kivy.uix.bubble · kivy.uix.button · kivy.uix.camera · kivy.uix. Scatter is used to build interactive widgets that can be translated, rotated and see it on the screen), but the maximum scale is 9.99506983235e+19 (2^66). Rotation value of the scatter in degrees moving in a counterclockwise direction. I've just installed fresh Jessie image on rpi2 attached to the official display with the early adopter frame, so I had to configure it to rotate the screen. It appears that only the display itself is rotated, touch coordinates are reported inverted as if no rotation happened. It happens both in X and on the framebuffer with Kivy. Has anyone


Problem with Rotate instruction with x and y axis. · Issue #5825 · kivy , Versions Python: 3.5.2 / 2.7.12 OS: Linux (Ubuntu based) Kivy: 1.10.0 Kivy For example A rotation of 60 degrees on x-axis should make the shape So that I ensure the z of point of origin is set to 0, the screen surface. The end goal here is to figure out how to emulate the rotation used by 3dsmax when pressing Alt+MMB. Right now with the current code you can move around using WASDQE keys (shift to accelerate), left/right button to rotate camera around it's/scene's center or zooming by using mouse wheel.


It is better to use opencv in your kivy code. it's give you a bunch of options and tools to manipulate pictures and videos. This code is ready for PC. I had 180 deg flip problem and fix it with opencv. you can use my code and this link:https://www.tutorialkart.com/opencv/python/opencv-python-rotate-image/

import os

import cv2
from kivy.app import App
from kivy.clock import Clock
from kivy.graphics.texture import Texture
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.image import Image


class KivyCamera(Image):
    def __init__(self, capture=None, fps=0, **kwargs):
        super(KivyCamera, self).__init__(**kwargs)
        # self.capture = cv2.VideoCapture("/sdcard2/python-apk/2.mp4")
        # print "file path exist :" + str(os.path.exists("/sdcard2/python-apk/1.mkv"))
        self.capture = cv2.VideoCapture(0)
        Clock.schedule_interval(self.update, 1.0 / fps)

    def update(self, dt):
        ret, frame = self.capture.read()
        # print str(os.listdir('/sdcard2/'))
        if ret:
            # convert it to texture
            buf1 = cv2.flip(frame, 0)
            buf = buf1.tostring()
            image_texture = Texture.create(size=(frame.shape[1], frame.shape[0]), colorfmt='bgr')
            image_texture.blit_buffer(buf, colorfmt='bgr', bufferfmt='ubyte')
            # display image from the texture
            self.texture = image_texture


class CamApp(App):
    def build(self):
        self.my_camera = KivyCamera(fps=12)
        self.box = BoxLayout(orientation='vertical')
        btn1 = Button(text="Hello")
        self.box.add_widget(btn1)
        # l = Label(text=cv2.__version__, font_size=150)
        # self.box.add_widget(l)
        self.box.add_widget(self.my_camera)
        return self.box

    def on_stop(self):
        # without this, app will not exit even if the window is closed
        # self.capture.release()
        pass

    def on_pause(self):
        return True


if __name__ == '__main__':
    CamApp().run()enter code here

Flip a widget horizontally, any way to flip an Image/Camera widget, or maybe alter the texture to do so before it gets Or you are displaying the texture on your own with Rectangle, you can http://kivy.org/docs/api-kivy.graphics.texture.html#kivy.graphics.texture. then rotate it around 180 degrees, which is essentially the same as I am struggling to understand what is going on with my (knock-off) Waveshare 3.5" TFT calibration. For my application, I need to have the display and the touch screen rotated 180 degrees. Flipping


Rotation Example, This example rotates a button using PushMatrix and PopMatrix. You should see a static button with the words 'hello world' rotated at a 45 degree angle. - [#6324]: We are transitioning the kivy Windows dependencies from the `kivy.deps.xxx` namespace stored under `kivy/deps/xxx` to the `kivy_deps.xxx` namespace stored under `kivy_deps/xxx`. Pip is sometimes not able to distinguish between these two formats, so follow the instructions below.


Rotating, translating, and scaling the canvas, The rotation, translation, and scaling canvas in Kivy is relatively easy with the use of matrices. Working with a camera Rotate the matrix 45 degrees. In canvas.after, pop the matrix from the context's matrix stack onto the model view: Copy. Android - image from camera or gallery comes slightly rotated sometimes Sometimes, when I load an image from the gallery or the camera the image gets rotated not in a 90Degrees angle but just a little bit something like 5 Degrees and I can't explain it since it's not even


File python-Kivy.changes of Package python-Kivy, You should see a static button with the words 'hello world' rotated at a 45 degree angle. ''' from kivy.app import App from kivy.lang import Builder kv  Hello, I have an application developed in Python-Kivy for Android, using buildozer. This application uses Opencv to activate the smartphone's camera, and capture frames from the camera to analyze. The application is generated normally, but when it starts on the smartphone, it crashes.