==================================== Tracking a Face with the Robotic Arm ==================================== .. raw:: html

Follow along: Tracking a Face with the Robotic Arm

The program launching process along with parameter settings are all simplified and set up on the Jupyter Notebook Environment.
(The Jetson Board used for these examples are => Jetson Nano)
.. raw:: html
- 05_07_follow_face - | Running the cell code | `Ctrl + Enter` .. thumbnail:: /_images/arm/face1.png - To control the robot arm from code, don't forget to shut down the docker container. See `here `_. - Face recognition and tracking using robot arm camera. - Import head file. .. code-block:: python import cv2 as cv import threading from time import sleep import ipywidgets as widgets from IPython.display import display from face_follow import face_follow - Initialize DOFBOT position. .. code-block:: python import Arm_Lib Arm = Arm_Lib.Arm_Device() joints_0 = [90, 150, 20, 20, 90, 30] Arm.Arm_serial_servo_write6_array(joints_0, 1500) - Create the instance and initialize the parameters. .. code-block:: python follow = face_follow() model = 'General' - Creating controls. .. code-block:: python button_layout = widgets.Layout(width='250px', height='50px', align_self='center') output = widgets.Output() exit_button = widgets.Button(description='Exit', button_style='danger', layout=button_layout) imgbox = widgets.Image(format='jpg', height=480, width=640, layout=widgets.Layout(align_self='center')) controls_box = widgets.VBox([imgbox, exit_button], layout=widgets.Layout(align_self='center')) # ['auto', 'flex-start', 'flex-end', 'center', 'baseline', 'stretch', 'inherit', 'initial', 'unset'] - Controls. .. code-block:: python def exit_button_Callback(value): global model model = 'Exit' # with output: print(model) exit_button.on_click(exit_button_Callback) - Main Process. .. code-block:: python def camera(): global model # Open camera capture = cv.VideoCapture(1) # Be executed in loop when the camera is opened normally while True: try: _, img = capture.read() img = cv.resize(img, (640, 480)) img = follow.follow_function(img) if model == 'Exit': cv.destroyAllWindows() capture.release() break imgbox.value = cv.imencode('.jpg', img)[1].tobytes() except KeyboardInterrupt:capture.release() - Start. .. code-block:: python display(controls_box,output) threading.Thread(target=camera, ).start() .. thumbnail:: /_images/ai_training/gui_face.png