|
|
|
|
@ -13,17 +13,24 @@ from geom_controll.arm_control import ArmController
|
|
|
|
|
from robot.simulated_robot import DummySimRobot
|
|
|
|
|
from robot.debug_robot import DebugRobot
|
|
|
|
|
|
|
|
|
|
from camera.factory import create_camera
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
# Все параметры
|
|
|
|
|
cfg = Config()
|
|
|
|
|
|
|
|
|
|
# Детектор скелета
|
|
|
|
|
detector = MediaPipeDetector()
|
|
|
|
|
|
|
|
|
|
# Детектор статичных жестов
|
|
|
|
|
special_detector = SpecialGestureDetector(
|
|
|
|
|
mode=cfg.SPECIAL_GESTURE_MODE,
|
|
|
|
|
model_path=cfg.ML_GESTURE_MODEL,
|
|
|
|
|
class_names=cfg.ML_GESTURE_CLASSES
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Динамические жесты
|
|
|
|
|
dynamic_predictor = None
|
|
|
|
|
|
|
|
|
|
if cfg.DYNAMIC_GESTURE['enabled']:
|
|
|
|
|
dynamic_predictor = DynamicGesturePredictor(
|
|
|
|
|
cfg.DYNAMIC_GESTURE['model_path'],
|
|
|
|
|
@ -32,16 +39,23 @@ def main():
|
|
|
|
|
cfg.DYNAMIC_GESTURE['threshold']
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Геометрический контроллер скоростей
|
|
|
|
|
arm_control = ArmController(cfg.ARM_CONTROL, mirror=cfg.MIRROR_CAMERA)
|
|
|
|
|
|
|
|
|
|
# Тип робота: симуляция - с игрой, дебаг - просто печать команды в консоль
|
|
|
|
|
if cfg.ROBOT_MODE == 'simulator':
|
|
|
|
|
robot = DummySimRobot(cfg)
|
|
|
|
|
else:
|
|
|
|
|
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)
|
|
|
|
|
if not cap.isOpened():
|
|
|
|
|
print("Ошибка: не удалось открыть камеру")
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
enabled = False
|
|
|
|
|
# включение управления жестами
|
|
|
|
|
@ -52,11 +66,16 @@ def main():
|
|
|
|
|
dome_processed = False
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
'''
|
|
|
|
|
ret, frame = cap.read()
|
|
|
|
|
if not ret:
|
|
|
|
|
break
|
|
|
|
|
if cfg.MIRROR_CAMERA:
|
|
|
|
|
frame = cv2.flip(frame, 1)
|
|
|
|
|
'''
|
|
|
|
|
frame = camera.get_frame()
|
|
|
|
|
if frame is None:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
result = detector.detect(frame)
|
|
|
|
|
if result['success']:
|
|
|
|
|
@ -126,7 +145,8 @@ def main():
|
|
|
|
|
if cv2.waitKey(1) & 0xFF == ord('q'):
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
cap.release()
|
|
|
|
|
#cap.release()
|
|
|
|
|
camera.release()
|
|
|
|
|
cv2.destroyAllWindows()
|
|
|
|
|
robot.quit()
|
|
|
|
|
|
|
|
|
|
|