Kivy 中的旋转相机输入

Rotated camera input in Kivy

我正在尝试使用 Kivy 附带的 Camera 对象向用户展示来自他们相机的实时预览流。当相机的框架是 ScatterLayout 时,一切都很好,但位置不稳定(我们通常不喜欢使用 ScatterLayout)。使用 GridLayout 时,位置变得稳定(在不同设备上)但预览流在 Android 设备上旋转了 90 度(在我的笔记本电脑上一切正常)

有什么想法和想法吗?

构造函数调用(顾名思义,CroppedCamera class 除了裁剪框架什么都不做。删除它不会改变问题):

self.camera = CroppedCamera(index=0, resolution=(1280, 720), rotation=camRot, ratio=imgRatio, imageBox=self)
    self.add_widget(self.camera.outer)

class CroppedCamera(Camera):
  def __init__(self, ratio, imageBox, rotation, *args, **kwargs):
    super(CroppedCamera, self).__init__(*args, **kwargs)
    self.outer = GridLayout()
    self.outer.rows = 1
    self.outer.cols = 1
    self.imageBox = imageBox
    self.outer.add_widget(self)
    self.outer.rotation = rotation
    self.outer.pos_hint = {'x': 0, 'y': -0.3}
    self.outer.size_hint = (0.8, 1)

旋转似乎只能使用 ScatterLayout,因为这是此布局带来的功能的一部分。为了只旋转,但要禁用用户交互(拖动、缩放、旋转等),可以通过设置如下内容来简单地禁用它们:

ScatterLayout(do_scale=False, do_translation_x=False, do_translation_y=False, do_rotation=False)