I'm new to python 3.10. I have the below python code outputting my webcam screen using python. How would I duplicate the webcam output within the same window. One screen on the left of the window and the second screen on the right hand side of the window? Something simple with no buttons. Or so I thought ;) proving more difficult than anticipated!
and no, "Integrate OpenCV webcam into a Kivy user interface" does not answer the question. I dont want to add button using kivy, i want to duplicate the webcam in the same screen window instance. i tried using kivy with a box layout in 'horizontal' orientation, but cannot figure bring my stream into the 2 box horizontal box layout. (adding kivy code below)
import cv2
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.uix.widget import Widget
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
cap=cv2.VideoCapture(0)
cap.release()
cv2.destroyAllWindows()
cap=cv2.VideoCapture(0)
while cap.isOpened():
ret, frame=cap.read()
cv2.imshow('VR',frame)
cv2.imshow('VR', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
class VRWindow(Screen):
def cam_connect(self):
cap=cv2.VideoCapture(0)
while cap.isOpened():
ret, frame=cap.read()
cv2.imshow('VR',frame)
# if cv2.waitKey(1) & 0xFF == ord('q'):
# break
pass
class Window(Screen):
pass
class ScreenManger(ScreenManager):
pass
kv = Builder.load_file('vrgui.kv')
class VRApp(App):
def build(self):
layout = boxLayout()
layout.orientation = 'horizontal'
return kv
if __name__ == '__main__':
VRApp().run()
kv file
ScreenManager:
VRWindow:
Window:
<VRWindow>:
name: "first"
FloatLayout:
#orientation:'horizontal'
Label:
text: 'VRLeft'
size: root.width, root.height
pos_hint: {'x': 0, 'y': .0}
size_hint: .5, 1.0
root.cam_connect()
Label:
text: 'VRRight'
size: root.width, root.height
pos_hint: {'x': .5, 'y': .0}
size_hint: .5, 1.0
#root.cam_connect()
<Window>:
name: "second"
FloatLayout:
#orientation:'horizontal'
size: root.width, root.height
pos_hint: {'x': 0, 'y': .0}
size_hint: 1.0, 1.0
#root.cam_connect()
Thank you for your time.