{"id":379486,"date":"2024-06-24T09:00:22","date_gmt":"2024-06-24T09:00:22","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=379486"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=379486","title":{"rendered":"<span>\u0418\u043d\u0436\u0435\u043d\u0435\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0418\u0418 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u043f\u0430\u043d\u0430\u043c\u044b \u0438\u0437 \u043e\u043a\u043d\u0430 \u043d\u0430 \u0433\u043e\u043b\u043e\u0432\u044b \u0436\u0438\u0442\u0435\u043b\u044f\u043c \u041d\u044c\u044e-\u0419\u043e\u0440\u043a\u0430<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0418\u043d\u0436\u0435\u043d\u0435\u0440 \u0438\u0437 \u041d\u044c\u044e-\u0419\u043e\u0440\u043a\u0430 <a href=\"https:\/\/dropofahat.zone\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u043e\u0432\u0430\u043b<\/a> \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 DropofaHat.zone. \u041e\u043d \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b \u0418\u0418, \u0447\u0442\u043e\u0431\u044b \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0437 \u043e\u043a\u043d\u0430 \u0441\u0432\u043e\u0435\u0439 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u043f\u0430\u043d\u0430\u043c\u044b \u043f\u0440\u044f\u043c\u043e \u043d\u0430 \u0433\u043e\u043b\u043e\u0432\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432\u043d\u0438\u0437\u0443 \u043f\u0435\u0448\u0435\u0445\u043e\u0434\u043e\u0432.\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d4b\/3da\/231\/d4b3da231adee68e1a89a8a6b7f19abb.JPG\" width=\"690\" height=\"494\"\/><\/figure>\n<p>\u041f\u043e \u0441\u043b\u043e\u0432\u0430\u043c \u0430\u0432\u0442\u043e\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043b\u044e\u0431\u043e\u0439 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0435\u043c\u0443 \u0432\u0440\u0435\u043c\u044f, \u043e\u043f\u043b\u0430\u0442\u0438\u0442\u044c \u043f\u0430\u043d\u0430\u043c\u0443 \u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0430 3 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043f\u043e\u0434 \u0435\u0433\u043e \u043e\u043a\u043d\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u0432\u0430\u0440. \u0413\u043e\u043b\u043e\u0432\u043d\u044b\u0435 \u0443\u0431\u043e\u0440\u044b \u0432\u044b\u043b\u0435\u0442\u0430\u044e\u0442 \u0438\u0437 \u043e\u043a\u043d\u0430 \u0441 5-\u043c\u0438\u043d\u0443\u0442\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c.<\/p>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/66791d6b28dfc09d9e4d7d5f\" data-style=\"\" id=\"66791d6b28dfc09d9e4d7d5f\" width=\"\"><\/div>\n<p>\u042d\u043d\u0442\u0443\u0437\u0438\u0430\u0441\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b Raspberry Pi, \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c Adafruit, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u043d\u043b\u0430\u0439\u043d-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 Roboflow. \u041e\u043d \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 \u043b\u0451\u0433\u043a\u0438\u0445 \u043f\u0430\u043d\u0430\u043c\u043a\u0430\u0445 \u0441 \u043f\u0440\u043e\u043f\u0435\u043b\u043b\u0435\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u043f\u0443\u0441\u043a\u0430 \u043f\u0430\u043d\u0430\u043c \u0447\u0435\u0440\u0435\u0437 \u043e\u043a\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b, \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u044f\u0436\u0438. \u041e\u043d\u0430 \u043e\u0431\u0451\u0440\u043d\u0443\u0442\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u0448\u0430\u0433\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0418\u0418 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0447\u0442\u043e \u043a\u0442\u043e-\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0434 \u043e\u043a\u043d\u043e\u043c, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b Python \u00abdropHat.py\u00bb \u043d\u0430 Raspberry Pi.<\/p>\n<pre><code>import time     import board     import digitalio      enable_pin = digitalio.DigitalInOut(board.D18)     coil_A_1_pin = digitalio.DigitalInOut(board.D4)     coil_A_2_pin = digitalio.DigitalInOut(board.D17)     coil_B_1_pin = digitalio.DigitalInOut(board.D23)     coil_B_2_pin = digitalio.DigitalInOut(board.D24)      enable_pin.direction = digitalio.Direction.OUTPUT     coil_A_1_pin.direction = digitalio.Direction.OUTPUT     coil_A_2_pin.direction = digitalio.Direction.OUTPUT     coil_B_1_pin.direction = digitalio.Direction.OUTPUT     coil_B_2_pin.direction = digitalio.Direction.OUTPUT      enable_pin.value = True      def forward(delay, steps):         i = 0         while i in range(0, steps):             setStep(1, 0, 1, 0)             time.sleep(delay)             setStep(0, 1, 1, 0)             time.sleep(delay)             setStep(0, 1, 0, 1)             time.sleep(delay)             setStep(1, 0, 0, 1)             time.sleep(delay)             i += 1      def setStep(w1, w2, w3, w4):         coil_A_1_pin.value = w1         coil_A_2_pin.value = w2         coil_B_1_pin.value = w3         coil_B_2_pin.value = w4      # Run a full rotation (512 steps) with a 5 millsecond delay     forward(5, int(512))                 <\/code><\/pre>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0441\u0442\u0430\u043b\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0418\u0418. \u042d\u043d\u0442\u0443\u0437\u0438\u0430\u0441\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0430 \u043a\u0430\u043c\u0435\u0440\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043d\u0443\u0442 \u0432\u0438\u0434\u0435\u043e \u0441\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u043e\u043a\u043d\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u043f\u0435\u0448\u0435\u0445\u043e\u0434\u043e\u0432 \u0431\u0435\u0437 \u0433\u043e\u043b\u043e\u0432\u043d\u044b\u0445 \u0443\u0431\u043e\u0440\u043e\u0432. \u041e\u043d <a href=\"https:\/\/universe.roboflow.com\/test-y7opj\/drop-of-a-a-hat\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b<\/a> \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438\u0437 133 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e <a href=\"https:\/\/universe.roboflow.com\/test-y7opj\/drop-of-a-a-hat\/model\/2\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0434\u0435\u043b\u044c<\/a>.\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8a2\/8f1\/7e9\/8a28f17e911b14a2711cc3012d1c8fb2.JPG\" width=\"688\" height=\"903\"\/><\/figure>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 Python \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0451\u0442, \u043a\u043e\u0433\u0434\u0430 \u043a\u0442\u043e-\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u0432 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043f\u043e\u0434 \u043e\u043a\u043d\u043e\u043c 3 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043f\u043e\u0434\u0440\u044f\u0434. \u0421\u043f\u0443\u0441\u0442\u044f \u044d\u0442\u043e\u0442 \u043f\u0435\u0440\u0438\u043e\u0434 \u043d\u0430 Raspberry Pi \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f dropHat.py.<\/p>\n<pre><code>import cv2 import time import paramiko  from inference_sdk import InferenceHTTPClient  CLIENT = InferenceHTTPClient(     api_url=\"https:\/\/detect.roboflow.com\",     api_key=\"API_KEY\" )  def ssh_execute(host, port, username, password, command):     client = paramiko.SSHClient()     client.load_system_host_keys()     client.set_missing_host_key_policy(paramiko.WarningPolicy)      try:         client.connect(host, port=port, username=username, password=password)         stdin, stdout, stderr = client.exec_command(command)                  # Print command output         print(stdout.read().decode().strip())                  if stderr.read().decode().strip():             print('Error:', stderr)     finally:         client.close()  video = cv2.VideoCapture(0)  # 0 usually refers to the webcam  consec_detections = 0 while True:     ret, frame = video.read()      # Directly pass the frames to the Roboflow model     result = CLIENT.infer(frame, model_id=\"drop-of-a-a-hat\/2\")      # Check if a prediction is made     if 'predictions' in result and len(result['predictions'])>0:         consec_detections += 1     else:         consec_detections = 0      # If there are three consecutive detections, perform an action (like printing a message)     if consec_detections >= 3:         # DROP THE HAT         ssh_execute('raspberry.local', 22, 'pi', 'raspberry', 'python3 dropHat.py')         # Reset counter         consec_detections = 0      # Delay before the next frame for 1 second     time.sleep(1) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/823880\/\"> https:\/\/habr.com\/ru\/articles\/823880\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0418\u043d\u0436\u0435\u043d\u0435\u0440 \u0438\u0437 \u041d\u044c\u044e-\u0419\u043e\u0440\u043a\u0430 <a href=\"https:\/\/dropofahat.zone\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u043e\u0432\u0430\u043b<\/a> \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 DropofaHat.zone. \u041e\u043d \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b \u0418\u0418, \u0447\u0442\u043e\u0431\u044b \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0437 \u043e\u043a\u043d\u0430 \u0441\u0432\u043e\u0435\u0439 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b \u043f\u0430\u043d\u0430\u043c\u044b \u043f\u0440\u044f\u043c\u043e \u043d\u0430 \u0433\u043e\u043b\u043e\u0432\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432\u043d\u0438\u0437\u0443 \u043f\u0435\u0448\u0435\u0445\u043e\u0434\u043e\u0432.\u00a0<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u043e \u0441\u043b\u043e\u0432\u0430\u043c \u0430\u0432\u0442\u043e\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043b\u044e\u0431\u043e\u0439 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0435\u043c\u0443 \u0432\u0440\u0435\u043c\u044f, \u043e\u043f\u043b\u0430\u0442\u0438\u0442\u044c \u043f\u0430\u043d\u0430\u043c\u0443 \u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0430 3 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043f\u043e\u0434 \u0435\u0433\u043e \u043e\u043a\u043d\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u0432\u0430\u0440. \u0413\u043e\u043b\u043e\u0432\u043d\u044b\u0435 \u0443\u0431\u043e\u0440\u044b \u0432\u044b\u043b\u0435\u0442\u0430\u044e\u0442 \u0438\u0437 \u043e\u043a\u043d\u0430 \u0441 5-\u043c\u0438\u043d\u0443\u0442\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c.<\/p>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/66791d6b28dfc09d9e4d7d5f\" data-style=\"\" id=\"66791d6b28dfc09d9e4d7d5f\" width=\"\"><\/div>\n<p>\u042d\u043d\u0442\u0443\u0437\u0438\u0430\u0441\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b Raspberry Pi, \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c Adafruit, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u043d\u043b\u0430\u0439\u043d-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 Roboflow. \u041e\u043d \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 \u043b\u0451\u0433\u043a\u0438\u0445 \u043f\u0430\u043d\u0430\u043c\u043a\u0430\u0445 \u0441 \u043f\u0440\u043e\u043f\u0435\u043b\u043b\u0435\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u043f\u0443\u0441\u043a\u0430 \u043f\u0430\u043d\u0430\u043c \u0447\u0435\u0440\u0435\u0437 \u043e\u043a\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b, \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u044f\u0436\u0438. \u041e\u043d\u0430 \u043e\u0431\u0451\u0440\u043d\u0443\u0442\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u0448\u0430\u0433\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0418\u0418 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0447\u0442\u043e \u043a\u0442\u043e-\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0434 \u043e\u043a\u043d\u043e\u043c, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b Python \u00abdropHat.py\u00bb \u043d\u0430 Raspberry Pi.<\/p>\n<pre><code>import time     import board     import digitalio      enable_pin = digitalio.DigitalInOut(board.D18)     coil_A_1_pin = digitalio.DigitalInOut(board.D4)     coil_A_2_pin = digitalio.DigitalInOut(board.D17)     coil_B_1_pin = digitalio.DigitalInOut(board.D23)     coil_B_2_pin = digitalio.DigitalInOut(board.D24)      enable_pin.direction = digitalio.Direction.OUTPUT     coil_A_1_pin.direction = digitalio.Direction.OUTPUT     coil_A_2_pin.direction = digitalio.Direction.OUTPUT     coil_B_1_pin.direction = digitalio.Direction.OUTPUT     coil_B_2_pin.direction = digitalio.Direction.OUTPUT      enable_pin.value = True      def forward(delay, steps):         i = 0         while i in range(0, steps):             setStep(1, 0, 1, 0)             time.sleep(delay)             setStep(0, 1, 1, 0)             time.sleep(delay)             setStep(0, 1, 0, 1)             time.sleep(delay)             setStep(1, 0, 0, 1)             time.sleep(delay)             i += 1      def setStep(w1, w2, w3, w4):         coil_A_1_pin.value = w1         coil_A_2_pin.value = w2         coil_B_1_pin.value = w3         coil_B_2_pin.value = w4      # Run a full rotation (512 steps) with a 5 millsecond delay     forward(5, int(512))                 <\/code><\/pre>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0441\u0442\u0430\u043b\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0418\u0418. \u042d\u043d\u0442\u0443\u0437\u0438\u0430\u0441\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0430 \u043a\u0430\u043c\u0435\u0440\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043d\u0443\u0442 \u0432\u0438\u0434\u0435\u043e \u0441\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u043e\u043a\u043d\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u043f\u0435\u0448\u0435\u0445\u043e\u0434\u043e\u0432 \u0431\u0435\u0437 \u0433\u043e\u043b\u043e\u0432\u043d\u044b\u0445 \u0443\u0431\u043e\u0440\u043e\u0432. \u041e\u043d <a href=\"https:\/\/universe.roboflow.com\/test-y7opj\/drop-of-a-a-hat\" rel=\"noopener noreferrer nofollow\">\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b<\/a> \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438\u0437 133 \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e <a href=\"https:\/\/universe.roboflow.com\/test-y7opj\/drop-of-a-a-hat\/model\/2\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0434\u0435\u043b\u044c<\/a>.\u00a0<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 Python \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0451\u0442, \u043a\u043e\u0433\u0434\u0430 \u043a\u0442\u043e-\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u0432 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043f\u043e\u0434 \u043e\u043a\u043d\u043e\u043c 3 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043f\u043e\u0434\u0440\u044f\u0434. \u0421\u043f\u0443\u0441\u0442\u044f \u044d\u0442\u043e\u0442 \u043f\u0435\u0440\u0438\u043e\u0434 \u043d\u0430 Raspberry Pi \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f dropHat.py.<\/p>\n<pre><code>import cv2 import time import paramiko  from inference_sdk import InferenceHTTPClient  CLIENT = InferenceHTTPClient(     api_url=\"https:\/\/detect.roboflow.com\",     api_key=\"API_KEY\" )  def ssh_execute(host, port, username, password, command):     client = paramiko.SSHClient()     client.load_system_host_keys()     client.set_missing_host_key_policy(paramiko.WarningPolicy)      try:         client.connect(host, port=port, username=username, password=password)         stdin, stdout, stderr = client.exec_command(command)                  # Print command output         print(stdout.read().decode().strip())                  if stderr.read().decode().strip():             print('Error:', stderr)     finally:         client.close()  video = cv2.VideoCapture(0)  # 0 usually refers to the webcam  consec_detections = 0 while True:     ret, frame = video.read()      # Directly pass the frames to the Roboflow model     result = CLIENT.infer(frame, model_id=\"drop-of-a-a-hat\/2\")      # Check if a prediction is made     if 'predictions' in result and len(result['predictions'])>0:         consec_detections += 1     else:         consec_detections = 0      # If there are three consecutive detections, perform an action (like printing a message)     if consec_detections >= 3:         # DROP THE HAT         ssh_execute('raspberry.local', 22, 'pi', 'raspberry', 'python3 dropHat.py')         # Reset counter         consec_detections = 0      # Delay before the next frame for 1 second     time.sleep(1) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/823880\/\"> https:\/\/habr.com\/ru\/articles\/823880\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-379486","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/379486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=379486"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/379486\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=379486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=379486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=379486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}