From a47a09d3ec159c1a8c0445ea488710bd89f83cea Mon Sep 17 00:00:00 2001 From: anirudh Date: Sat, 1 Jun 2024 12:47:57 +0530 Subject: [PATCH 1/5] added required libraries and altered camera_selector python file --- afy/camera_selector.py | 13 ++++++++----- requirements.txt | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/afy/camera_selector.py b/afy/camera_selector.py index 897562d01..2bfd89742 100644 --- a/afy/camera_selector.py +++ b/afy/camera_selector.py @@ -1,10 +1,11 @@ import cv2 import numpy as np import yaml +import os +# import yaml from afy.utils import log - g_selected_cam = None @@ -85,7 +86,7 @@ def select_camera(cam_frames, window="Camera selector"): if g_selected_cam is not None: break - + if key == 27: break @@ -97,15 +98,17 @@ def select_camera(cam_frames, window="Camera selector"): return list(cam_frames)[0] +# print(g_selected_cam) if __name__ == '__main__': - with open('config.yaml', 'r') as f: + # cam_frames = {} + yml_file_path = os.path.join(os.path.expanduser('~'), 'avatarify-python', 'config.yaml') + with open(yml_file_path, "r") as f: config = yaml.load(f, Loader=yaml.FullLoader) cam_frames = query_cameras(config['query_n_cams']) - + # print(cam_frames) if cam_frames: selected_cam = select_camera(cam_frames) print(f"Selected camera {selected_cam}") else: log("No cameras are available") - diff --git a/requirements.txt b/requirements.txt index 1e6240df0..66570cf14 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,6 @@ pyzmq==20.0.0 msgpack-numpy==0.4.7.1 pyyaml==5.4 requests==2.32.0 -pyfakewebcam==0.1.0 \ No newline at end of file +pyfakewebcam==0.1.0 +scipy==1.13.1 +torch==2.3.0 From c061812f4285902c5ad63a18b9b8fcae3d32f3e4 Mon Sep 17 00:00:00 2001 From: anirudh Date: Sat, 1 Jun 2024 16:17:55 +0530 Subject: [PATCH 2/5] configured file's path --- afy/camera_selector.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/afy/camera_selector.py b/afy/camera_selector.py index 2bfd89742..044d0b83c 100644 --- a/afy/camera_selector.py +++ b/afy/camera_selector.py @@ -2,7 +2,6 @@ import numpy as np import yaml import os -# import yaml from afy.utils import log @@ -44,8 +43,10 @@ def make_grid(images, cell_size=(320, 240), cols=2): grid = np.zeros((h0 * _rows, w0 * _cols, 3), dtype=np.uint8) for i, (camid, img) in enumerate(images.items()): img = cv2.resize(img, (w0, h0)) + # add rect img = cv2.rectangle(img, (1, 1), (w0 - 1, h0 - 1), (0, 0, 255), 2) + # add id img = cv2.putText(img, f'Camera {camid}', (10, 30), 0, 1, (0, 255, 0), 2) c = i % cols @@ -98,15 +99,14 @@ def select_camera(cam_frames, window="Camera selector"): return list(cam_frames)[0] -# print(g_selected_cam) if __name__ == '__main__': - # cam_frames = {} - yml_file_path = os.path.join(os.path.expanduser('~'), 'avatarify-python', 'config.yaml') + parent_dir = os.path.basename(os.path.dirname(os.getcwd())) + + yml_file_path = os.path.join(os.path.expanduser('~'), parent_dir, 'config.yaml') with open(yml_file_path, "r") as f: config = yaml.load(f, Loader=yaml.FullLoader) cam_frames = query_cameras(config['query_n_cams']) - # print(cam_frames) if cam_frames: selected_cam = select_camera(cam_frames) print(f"Selected camera {selected_cam}") From 96574e1317cc70c8f5c50837ae6492b8adfecbe1 Mon Sep 17 00:00:00 2001 From: anirudh Date: Sat, 1 Jun 2024 19:30:49 +0530 Subject: [PATCH 3/5] added location to load the file from each location --- afy/camera_selector.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/afy/camera_selector.py b/afy/camera_selector.py index 044d0b83c..778accc74 100644 --- a/afy/camera_selector.py +++ b/afy/camera_selector.py @@ -101,10 +101,12 @@ def select_camera(cam_frames, window="Camera selector"): if __name__ == '__main__': parent_dir = os.path.basename(os.path.dirname(os.getcwd())) - - yml_file_path = os.path.join(os.path.expanduser('~'), parent_dir, 'config.yaml') - with open(yml_file_path, "r") as f: - config = yaml.load(f, Loader=yaml.FullLoader) + file_location = ['Downloads', 'Documents', parent_dir, ''] + for loc in file_location: + yml_file_path = os.path.join(os.path.expanduser('~'), loc, 'config.yaml') + if os.path.exists(yml_file_path): + with open(yml_file_path, "r") as f: + config = yaml.load(f, Loader=yaml.FullLoader) cam_frames = query_cameras(config['query_n_cams']) if cam_frames: From 94543e5077fa900ff8fd97aa6038db46f91236d5 Mon Sep 17 00:00:00 2001 From: anirudh Date: Sat, 1 Jun 2024 19:33:44 +0530 Subject: [PATCH 4/5] added Desktop location --- afy/camera_selector.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afy/camera_selector.py b/afy/camera_selector.py index 778accc74..4bb625153 100644 --- a/afy/camera_selector.py +++ b/afy/camera_selector.py @@ -101,9 +101,10 @@ def select_camera(cam_frames, window="Camera selector"): if __name__ == '__main__': parent_dir = os.path.basename(os.path.dirname(os.getcwd())) - file_location = ['Downloads', 'Documents', parent_dir, ''] + file_location = ['Desktop', 'Downloads', 'Documents', parent_dir, ''] for loc in file_location: yml_file_path = os.path.join(os.path.expanduser('~'), loc, 'config.yaml') + print(yml_file_path) if os.path.exists(yml_file_path): with open(yml_file_path, "r") as f: config = yaml.load(f, Loader=yaml.FullLoader) From 2ea1d20f76bc0837a33c2456b5593c129f878a5f Mon Sep 17 00:00:00 2001 From: anirudh Date: Sat, 1 Jun 2024 19:39:14 +0530 Subject: [PATCH 5/5] added Programs location --- afy/camera_selector.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/afy/camera_selector.py b/afy/camera_selector.py index 4bb625153..ff549413b 100644 --- a/afy/camera_selector.py +++ b/afy/camera_selector.py @@ -101,10 +101,9 @@ def select_camera(cam_frames, window="Camera selector"): if __name__ == '__main__': parent_dir = os.path.basename(os.path.dirname(os.getcwd())) - file_location = ['Desktop', 'Downloads', 'Documents', parent_dir, ''] + file_location = ['Desktop', 'Downloads', 'Documents', parent_dir, '', 'Programs'] for loc in file_location: yml_file_path = os.path.join(os.path.expanduser('~'), loc, 'config.yaml') - print(yml_file_path) if os.path.exists(yml_file_path): with open(yml_file_path, "r") as f: config = yaml.load(f, Loader=yaml.FullLoader)