Моя камера сделана в opencv 2, и у меня есть графический интерфейс.Камера добавлена в FlotLayout.Я хотел бы определить местонахождение камеры opencv в моих координатах.Есть ли способ сделать это?
Снимок экрана GUI
Я хотел бы переместить вывод камеры в левую сторону.
import cv2
from kivy.clock import Clock
from kivy.graphics.texture import Texture
from kivy.uix.image import Image
class KivyCamera(Image):
def __init__(self, **kwargs):
super(KivyCamera, self).__init__(**kwargs)
self.capture = None
def start(self, capture, fps=30):
self.capture = capture
Clock.schedule_interval(self.update, 1.0 / fps)
def stop(self):
Clock.unschedule(self.update)
self.capture = None
def captured(self, export_path: str = None):
cv2.imwrite(export_path, self.capture.read()[1])
def update(self, *args):
return_value, frame = self.capture.read()
if return_value:
w, h = frame.shape[1], frame.shape[0]
if not self.texture or self.texture.width != w or self.texture.height != h:
self.texture = Texture.create(size=(w, h))
self.texture.flip_vertical()
self.texture.blit_buffer(frame.tobytes(), colorfmt='bgr')
self.canvas.ask_update()
class ClickAndGo(App):
def build(self):
# tworzymy layout dla kamery
self.camlayout = FloatLayout()
# tworzymy layout dla panelu bocznego - informacyjnego/statusu robota
self.roblayout = FloatLayout()
# dodajemy obiekt kamery
self.capture = cv2.VideoCapture(0)
self.capture.set(cv2.CAP_PROP_FRAME_WIDTH, 2200)
self.capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 2200)
self.my_camera = KivyCamera()