works fine with web and oak
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
class Config:
|
class Config:
|
||||||
# ===== Камера =====
|
# ===== Камера =====
|
||||||
CAMERA_ID = 0
|
CAMERA_ID = 0 # только для 'web'
|
||||||
|
CAMERA_TYPE = 'oak' # 'web' или 'oak'
|
||||||
MIRROR_CAMERA = True
|
MIRROR_CAMERA = True
|
||||||
|
|
||||||
# ===== Преобразование позы в скорости =====
|
# ===== Преобразование позы в скорости =====
|
||||||
@@ -14,7 +15,7 @@ class Config:
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ===== Статические жесты (dome, cross) =====
|
# ===== Статические жесты (dome, cross) =====
|
||||||
SPECIAL_GESTURE_MODE = 'ml' # или 'ml' 'geometric'
|
SPECIAL_GESTURE_MODE = 'ml' # 'ml' или 'geometric'
|
||||||
ML_GESTURE_MODEL = '/home/ubuntu/sirius/models/rf/special_gestures_rf.pkl'
|
ML_GESTURE_MODEL = '/home/ubuntu/sirius/models/rf/special_gestures_rf.pkl'
|
||||||
ML_GESTURE_CLASSES = ['dome', 'cross', 'none']
|
ML_GESTURE_CLASSES = ['dome', 'cross', 'none']
|
||||||
|
|
||||||
@@ -53,4 +54,4 @@ class Config:
|
|||||||
FIRE_RADIUS = 15
|
FIRE_RADIUS = 15
|
||||||
SCORE_PER_FIRE = 10
|
SCORE_PER_FIRE = 10
|
||||||
|
|
||||||
ROBOT_MODE = 'simulator' # или 'debug'
|
ROBOT_MODE = 'simulator' # 'simulator' или 'debug'
|
||||||
|
|||||||
@@ -13,17 +13,24 @@ from geom_controll.arm_control import ArmController
|
|||||||
from robot.simulated_robot import DummySimRobot
|
from robot.simulated_robot import DummySimRobot
|
||||||
from robot.debug_robot import DebugRobot
|
from robot.debug_robot import DebugRobot
|
||||||
|
|
||||||
|
from camera.factory import create_camera
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
# Все параметры
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
|
|
||||||
|
# Детектор скелета
|
||||||
detector = MediaPipeDetector()
|
detector = MediaPipeDetector()
|
||||||
|
|
||||||
|
# Детектор статичных жестов
|
||||||
special_detector = SpecialGestureDetector(
|
special_detector = SpecialGestureDetector(
|
||||||
mode=cfg.SPECIAL_GESTURE_MODE,
|
mode=cfg.SPECIAL_GESTURE_MODE,
|
||||||
model_path=cfg.ML_GESTURE_MODEL,
|
model_path=cfg.ML_GESTURE_MODEL,
|
||||||
class_names=cfg.ML_GESTURE_CLASSES
|
class_names=cfg.ML_GESTURE_CLASSES
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Динамические жесты
|
||||||
dynamic_predictor = None
|
dynamic_predictor = None
|
||||||
|
|
||||||
if cfg.DYNAMIC_GESTURE['enabled']:
|
if cfg.DYNAMIC_GESTURE['enabled']:
|
||||||
dynamic_predictor = DynamicGesturePredictor(
|
dynamic_predictor = DynamicGesturePredictor(
|
||||||
cfg.DYNAMIC_GESTURE['model_path'],
|
cfg.DYNAMIC_GESTURE['model_path'],
|
||||||
@@ -32,16 +39,23 @@ def main():
|
|||||||
cfg.DYNAMIC_GESTURE['threshold']
|
cfg.DYNAMIC_GESTURE['threshold']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Геометрический контроллер скоростей
|
||||||
arm_control = ArmController(cfg.ARM_CONTROL, mirror=cfg.MIRROR_CAMERA)
|
arm_control = ArmController(cfg.ARM_CONTROL, mirror=cfg.MIRROR_CAMERA)
|
||||||
|
|
||||||
|
# Тип робота: симуляция - с игрой, дебаг - просто печать команды в консоль
|
||||||
if cfg.ROBOT_MODE == 'simulator':
|
if cfg.ROBOT_MODE == 'simulator':
|
||||||
robot = DummySimRobot(cfg)
|
robot = DummySimRobot(cfg)
|
||||||
else:
|
else:
|
||||||
robot = DebugRobot()
|
robot = DebugRobot()
|
||||||
|
|
||||||
|
# Захват кадра с камеры
|
||||||
|
camera = create_camera(camera_type=cfg.CAMERA_TYPE, camera_id=cfg.CAMERA_ID, mirror=cfg.MIRROR_CAMERA)
|
||||||
|
'''
|
||||||
cap = cv2.VideoCapture(cfg.CAMERA_ID)
|
cap = cv2.VideoCapture(cfg.CAMERA_ID)
|
||||||
if not cap.isOpened():
|
if not cap.isOpened():
|
||||||
print("Ошибка: не удалось открыть камеру")
|
print("Ошибка: не удалось открыть камеру")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
'''
|
||||||
|
|
||||||
enabled = False
|
enabled = False
|
||||||
# включение управления жестами
|
# включение управления жестами
|
||||||
@@ -52,11 +66,16 @@ def main():
|
|||||||
dome_processed = False
|
dome_processed = False
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
'''
|
||||||
ret, frame = cap.read()
|
ret, frame = cap.read()
|
||||||
if not ret:
|
if not ret:
|
||||||
break
|
break
|
||||||
if cfg.MIRROR_CAMERA:
|
if cfg.MIRROR_CAMERA:
|
||||||
frame = cv2.flip(frame, 1)
|
frame = cv2.flip(frame, 1)
|
||||||
|
'''
|
||||||
|
frame = camera.get_frame()
|
||||||
|
if frame is None:
|
||||||
|
continue
|
||||||
|
|
||||||
result = detector.detect(frame)
|
result = detector.detect(frame)
|
||||||
if result['success']:
|
if result['success']:
|
||||||
@@ -126,7 +145,8 @@ def main():
|
|||||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||||
break
|
break
|
||||||
|
|
||||||
cap.release()
|
#cap.release()
|
||||||
|
camera.release()
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
robot.quit()
|
robot.quit()
|
||||||
|
|
||||||
|
|||||||
Submodule submodules/gesture_detection updated: 988ce22d01...a751f51078
Reference in New Issue
Block a user