From 08ce2a18dfb8557165ae019fb4190545f02586fa Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Sun, 8 Dec 2019 15:41:29 -0500 Subject: [PATCH 1/2] Front-end GUI to choose camera --- DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_Minimal.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_Minimal.py b/DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_Minimal.py index 2e92af22..9396135b 100644 --- a/DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_Minimal.py +++ b/DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_Minimal.py @@ -11,8 +11,17 @@ import cv2 CAMERA_FRONT = 1 CAMERA_REAR = 0 + sg.change_look_and_feel('Dark Black 1') +# ---------------- A Quick Little Window - to get camera to use ---------------- +win_get_cam = sg.Window('Which Camera?',[[sg.T('Which camera?')],[sg.Combo(['Front', 'Rear'], default_value='Rear', font='any 20')],[sg.T(size=(1,2))], [sg.Ok()]], location=(0,0)) +event, values = win_get_cam.read() +win_get_cam.close() +if event != 'Ok': exit() +USE_CAMERA = [CAMERA_FRONT, CAMERA_REAR][values[0]=='Rear'] + + # define the window layout layout = [[sg.Image(filename='', key='-IMAGE-', tooltip='Right click for exit menu')], [sg.Exit()],] @@ -23,7 +32,7 @@ window = sg.Window('Demo Application - OpenCV Integration', layout, location=(0, right_click_menu=['&Right', ['E&xit']], ) # if trying Qt, you will need to remove this right click menu # ---===--- Event LOOP Read and display frames, operate the GUI --- # -cap = cv2.VideoCapture(CAMERA_REAR) # Setup the OpenCV capture device (webcam) +cap = cv2.VideoCapture(USE_CAMERA) # Setup the OpenCV capture device (webcam) while True: event, values = window.read(timeout=20) if event in ('Exit', None): From f467d2c4b72a6d081e702114483c9dfa8777b85e Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Sun, 8 Dec 2019 15:43:02 -0500 Subject: [PATCH 2/2] Front-end to choose which camera --- DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_ASCII.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_ASCII.py b/DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_ASCII.py index 6de65e26..c06f9580 100644 --- a/DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_ASCII.py +++ b/DemoPrograms/PyDroid3/Demo_OpenCV_Webcam_ASCII.py @@ -36,7 +36,7 @@ SC, GCF, WCF = .1, 1, 7/4 sg.change_look_and_feel('Dark Black 1') # make it look cool # ---------------- A Quick Little Window - to get camera to use ---------------- -win_get_cam = sg.Window('Which Camera?',[[sg.T('Which camera?')],[sg.Combo(['Front', 'Rear'], default_value='Rear', font='any 20')], [sg.Ok()]], location=(0,0)) +win_get_cam = sg.Window('Which Camera?',[[sg.T('Which camera?')],[sg.Combo(['Front', 'Rear'], default_value='Rear', font='any 20')],[sg.T(size=(1,2))], [sg.Ok()]], location=(0,0)) event, values = win_get_cam.read() win_get_cam.close() if event != 'Ok': exit()