-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52d546b
commit 9e69444
Showing
14 changed files
with
358 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/data/ | ||
/archive/ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import cv2 | ||
import mediapipe as mp | ||
import pyautogui | ||
from pynput.mouse import Listener | ||
from pynput import keyboard, mouse | ||
import pynput | ||
import uuid | ||
import time | ||
import datetime | ||
import os | ||
import numpy as np | ||
import sys | ||
|
||
sys.path.append("../modules") | ||
from list_webcams import list_webcams # noqa | ||
|
||
|
||
def cams_init(): | ||
webcams = list_webcams() | ||
intcams = webcams[[cam for cam in webcams.keys() if 'Integrated' in cam][0]] | ||
briocams = webcams[[cam for cam in webcams.keys() if 'BRIO' in cam][0]] | ||
camsdict = {} | ||
|
||
print('cam1') | ||
cam1 = cv2.VideoCapture(briocams[0]) | ||
cam1.set(cv2.CAP_PROP_FRAME_WIDTH, 1280) | ||
cam1.set(cv2.CAP_PROP_FRAME_HEIGHT, 720) | ||
cam1.set(cv2.CAP_PROP_FPS, 60) | ||
camsdict['brio'] = cam1 | ||
|
||
# print('cam2') | ||
# cam2 = cv2.VideoCapture(briocams[2]) | ||
# cam2.set(cv2.CAP_PROP_FRAME_WIDTH, 340) | ||
# cam2.set(cv2.CAP_PROP_FRAME_HEIGHT, 340) | ||
# cam2.set(cv2.CAP_PROP_FPS, 30) | ||
# camsdict['brioBW'] = cam2 # regular BRIO cam hangs when BW cam is in use, same behavior in guvcview | ||
|
||
# print('cam3') | ||
# cam3 = cv2.VideoCapture(intcams[0]) | ||
# cam3.set(cv2.CAP_PROP_FRAME_WIDTH, 1280) | ||
# cam3.set(cv2.CAP_PROP_FRAME_HEIGHT, 720) | ||
# cam3.set(cv2.CAP_PROP_FPS, 30) | ||
# camsdict['integrated'] = cam3 | ||
|
||
return camsdict | ||
|
||
|
||
def on_press(key): | ||
if key == pynput.keyboard.Key.enter: | ||
frames = {} | ||
t0 = time.time() | ||
for camname, cam in cams.items(): | ||
for i in range(3): | ||
ret, frame = cam.read() | ||
filename = f'./data/{iso_date}/{camname} {t0*1000:.0f} {i}.jpeg' | ||
frames[filename] = frame | ||
dt = time.time() - t0 | ||
print(dt) | ||
for filename, frame in frames.items(): | ||
cv2.imwrite(filename, frame) | ||
print('save', filename) | ||
|
||
|
||
kb_listener = pynput.keyboard.Listener(on_press=on_press) | ||
kb_listener.start() | ||
|
||
|
||
cams = cams_init() | ||
cam = cams['brio'] | ||
iso_date = datetime.datetime.now().isoformat() | ||
os.mkdir(f'./data/{iso_date}') | ||
i = 0 | ||
while True: | ||
if i == 1: | ||
print('ready') | ||
for camname, cam in cams.items(): | ||
t0 = time.time() | ||
ret, frame = cam.read() | ||
dt = time.time() - t0 | ||
if camname == 'brio': | ||
cv2.imshow('cam', frame) | ||
print(dt) | ||
cv2.waitKey(1) | ||
i += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import time | ||
import numpy as np | ||
import pygame | ||
import pygame.camera | ||
import cv2 | ||
import sys | ||
sys.path.append("../modules") | ||
from list_webcams import list_webcams # noqa | ||
|
||
|
||
webcams = list_webcams() | ||
intcams = webcams[[cam for cam in webcams.keys() if 'Integrated' in cam][0]] | ||
briocams = webcams[[cam for cam in webcams.keys() if 'BRIO' in cam][0]] | ||
|
||
pygame.camera.init() | ||
print(briocams) | ||
cam1 = pygame.camera.Camera(briocams[0], (1280, 720)) | ||
cam1.start() | ||
|
||
# cam2 = pygame.camera.Camera(intcams[0], (1280, 720)) | ||
# cam2.start() | ||
|
||
while True: | ||
# img = cam2.get_image() | ||
t0 = time.time() | ||
img = cam1.get_image() | ||
pygame_image_string = pygame.image.tostring(img, 'RGB') | ||
cv2_image_array = np.frombuffer(pygame_image_string, dtype=np.uint8) | ||
cv2_image_array = cv2_image_array.reshape((img.get_height(), img.get_width(), 3)) | ||
bgr = cv2.cvtColor(cv2_image_array, cv2.COLOR_RGB2BGR) | ||
dt = time.time() - t0 | ||
print(dt) | ||
cv2.imshow('cam', bgr) | ||
cv2.waitKey(1) | ||
|
||
|
||
pygame.image.save(img, "filename.jpg") |
Oops, something went wrong.