{"id":9955,"date":"2022-01-17T07:00:17","date_gmt":"2022-01-16T22:00:17","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=9955"},"modified":"2022-01-11T05:19:11","modified_gmt":"2022-01-10T20:19:11","slug":"%e3%80%90python-javascript%e3%80%91%e6%8c%87%e3%82%b8%e3%82%a7%e3%82%b9%e3%83%81%e3%83%a3%e3%83%bc%e3%81%a7%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%b9%e3%82%af%e3%83%ad%e3%83%bc%e3%83%ab%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=9955","title":{"rendered":"\u3010Python + JavaScript\u3011\u6307\u30b8\u30a7\u30b9\u30c1\u30e3\u30fc\u3067\u30da\u30fc\u30b8\u30b9\u30af\u30ed\u30fc\u30eb\u3059\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001<code>Python<\/code>\u304c\u4e16\u754c\u7684\u306b\u4eba\u6c17\u306e\u8a00\u8a9e\u306b\u306a\u3063\u3066\u304b\u3089\u7d50\u69cb\u6642\u9593\u304c\u7d4c\u3061\u307e\u3059\u304c\u3001\u6b63\u76f4\u306a\u3068\u3053\u308d<code>Laravel + Vue<\/code>\u304c\u30e1\u30a4\u30f3\u306e\u958b\u767a\u3092\u3055\u305b\u3066\u3044\u305f\u3060\u3044\u3066\u3044\u308b\u3053\u3068\u3082\u3042\u308a\u3001\u6c17\u304c\u3064\u304f\u3068\u300c<strong>\u3042\u308c\u3001Python\u306e\u30eb\u30fc\u30d7\u3063\u3066\u3069\u3046\u3084\u308b\u3093\u3060\u3063\u3051\u2026\ud83d\udca6<\/strong>\u300d\u3068\u306a\u3063\u305f\u308a\u3082\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306f\u3001\u4f3c\u3066\u3044\u308b\u90e8\u5206\u3082\u591a\u3044\u3067\u3059\u304c\u5c11\u3057\u30af\u30bb\u304c\u3042\u3063\u305f\u308a\u3082\u3059\u308b\u306e\u3067\u4f7f\u308f\u306a\u3044\u3068\u5fd8\u308c\u3061\u3083\u3046\u3093\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u2026\u306a\u3093\u3066\u8003\u3048\u3066\u3044\u308b\u3068\u3001\u3075\u3068<code>Python<\/code>\u3092\u4f7f\u3063\u3066\u3084\u3063\u3066\u307f\u305f\u3044\u3053\u3068\u304c\u5929\u304b\u3089\u964d\u308a\u3066\u304d\u307e\u3057\u305f\u2757<\/p>\n<p>\u305d\u308c\u306f\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 25px;\">\u6307\u30b8\u30a7\u30b9\u30c1\u30e3\u30fc\u3067\u30d6\u30e9\u30a6\u30b6\u3092\u64cd\u4f5c\u3057\u305f\u3044\uff01<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u306e\u3082\u3001\u5c11\u3057\u524d\u306b\u300c<a href=\"https:\/\/google.github.io\/mediapipe\/\" target=\"_blank\" rel=\"noopener\">MediaPipe<\/a>\u300d\u3068\u3044\u3046<code>Google<\/code>\u304c\u3064\u304f\u3063\u305f\u300c<strong>\u3044\u308d\u3044\u308d\u306a\u7269\u4f53\u691c\u51fa\u304c\u3067\u304d\u308b\u30e9\u30a4\u30d6\u30e9\u30ea<\/strong>\u300d\u306e\u5b58\u5728\u3092\u77e5\u308a\u3001\u8208\u5473\u304c\u51fa\u3066\u3044\u305f\u304b\u3089\u306a\u3093\u3067\u3059\u306d\u3002<\/p>\n<p>\u624b\u306e\u7269\u4f53\u691c\u51fa\u306f\u3053\u3061\u3089<br \/>\n\u2193\u2193\u2193<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9958\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/01\/python_auto_scroll_2.png\" alt=\"\" width=\"290\" height=\"263\" \/><br \/>\n\uff08<a href=\"https:\/\/google.github.io\/mediapipe\/solutions\/hands.html#static_image_mode\" target=\"_blank\" rel=\"noopener\">MediaPipe \u30a6\u30a7\u30d6\u30b5\u30a4\u30c8<\/a>\u304b\u3089\u306e\u5f15\u7528\uff09<\/p>\n<p>\u305d\u3053\u3067\u2757<\/p>\n<p>\u4eca\u56de\u306f\u3001<code>MediaPipe<\/code>\uff08<code>Python<\/code>\uff09\u3067\u300c<strong>\u89aa\u6307\u306e\u5411\u304d\u304c\u4e0a or \u4e0b<\/strong>\u300d\u3092\u5224\u5225\u3057\u3001\u30d6\u30e9\u30a6\u30b6\u306e\u30b9\u30af\u30ed\u30fc\u30eb\u3092\u64cd\u4f5c\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305c\u3072\u4f55\u304b\u306e\u53c2\u8003\u306b\u306a\u308a\u307e\u3057\u305f\u3089\u5b09\u3057\u3044\u3067\u3059\u3002\ud83d\ude04\u2728<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9470 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/08\/no_13.png\" alt=\"\" width=\"294\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/08\/no_13.png 294w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/08\/no_13-276x300.png 276w\" sizes=\"auto, (max-width: 294px) 100vw, 294px\" \/>\u300c\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u69d8\u305f\u3061<br \/>\n\u304b\u3089\u9802\u3044\u305f\u304a\u6b73\u66ae\u3067\u6e80\u8179\u2757<br \/>\n\u30db\u30f3\u30c8\u5e78\u305b\ud83d\ude1a\u300d<\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Python 3.8.10\u3001Laravel 8.x<\/p>\n<h1>\u524d\u63d0\u3068\u3057\u3066<\/h1>\n<p>\u4eca\u56de\u306e\u6a5f\u80fd\u306f\u4ee5\u4e0b\u306e\u624b\u9806\u3067\u5b9f\u88c5\u3057\u307e\u3059\u3002<\/p>\n<ol>\n<li>Python \u3067\u89aa\u6307\u304c\u300c\u4e0a or \u4e0b\u300d\u3092\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306b\u5224\u5225<\/li>\n<li>Pusher \u3078\u89aa\u6307\u306e\u60c5\u5831\u3092\u9001\u4fe1<\/li>\n<li>JavaScript\uff08\u30d6\u30e9\u30a6\u30b6\u5074\uff09\u304c\u305d\u306e\u30c7\u30fc\u30bf\u3092\u53d7\u3051\u3068\u308a\u81ea\u52d5\u7684\u306b\u30b9\u30af\u30ed\u30fc\u30eb<\/li>\n<\/ol>\n<p>\u305d\u306e\u305f\u3081\u3001\u4e8b\u524d\u306b<code>Pusher<\/code>\u306b\u767b\u9332\u3057\u3001\u3055\u3089\u306b\u30a2\u30af\u30bb\u30b9\u60c5\u5831\u304c\u6e96\u5099\u6e08\u307f\u3067\u3042\u308b\u3053\u3068\u304c\u524d\u63d0\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057\u307e\u3060\u306e\u65b9\u306f\u3001\u4ee5\u4e0b\u3092\u53c2\u8003\u306b\u3057\u3066\u6e96\u5099\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>\ud83d\udcdd \u53c2\u8003\u30da\u30fc\u30b8<\/strong>\uff1a\u00a0<a href=\"https:\/\/blog.capilano-fw.com\/?p=1418#i-6\" target=\"_blank\" rel=\"noopener\">\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u30fb\u30c1\u30e3\u30c3\u30c8\u3092\u3064\u304f\u308b\uff1a\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306b\u66f4\u65b0\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/a><\/p>\n<h1>\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h1>\n<p>\u4eca\u56de\u306e\u6a5f\u80fd\u3092\u5b9f\u88c5\u3059\u308b\u305f\u3081\u306b\u4ee5\u4e0b\uff13\u3064\u306e<code>Python<\/code>\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>OpenCV\uff1a \u753b\u50cf\u7de8\u96c6<\/li>\n<li>MediaPipe\uff1a \u3044\u308d\u3044\u308d\u306a\u7269\u4f53\u3092\u8a8d\u8b58\u3059\u308b\u3002Google\u88fd\u3002<\/li>\n<li>Pusher\uff1a Python \u304b\u3089 Pusher \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3002<\/li>\n<\/ul>\n<p>\u305d\u306e\u305f\u3081\u3001\u524d\u3082\u3063\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>pip3 install opencv-python<\/strong><\/pre>\n<pre><strong>pip3 install mediapipe<\/strong><\/pre>\n<pre><strong>pip3 install pusher<\/strong><\/pre>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u4f5c\u696d\u3092\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u2757<\/p>\n<h1>Python \u5074\u306e\u4f5c\u696d<\/h1>\n<p>\u3067\u306f\u3001\u307e\u305a\u306f<code>Python<\/code>\u306e\u4f5c\u696d\u3067\u3059\u3002<\/p>\n<p><strong>finger_gestures.py<\/strong><\/p>\n<pre><strong>#!\/usr\/bin\/env python<\/strong>\r\n<strong># -*- coding: utf-8 -*-<\/strong>\r\n\r\n<strong>import cv2<\/strong>\r\n<strong>import time<\/strong>\r\n<strong>import mediapipe as mp<\/strong>\r\n<strong>import pusher<\/strong>\r\n\r\n<strong># \u5b9a\u6570<\/strong>\r\n<strong>PUSHER_APP_ID = '\uff08\u3053\u3053\u306b Pusher \u306e APP ID\uff09'<\/strong>\r\n<strong>PUSHER_APP_KEY = '\uff08\u3053\u3053\u306b Pusher \u306e\u30ad\u30fc\uff09'<\/strong>\r\n<strong>PUSHER_APP_SECRET = '\uff08\u3053\u3053\u306b Pusher \u306e\u79d8\u5bc6\u30ad\u30fc\uff09'<\/strong>\r\n<strong>PUSHER_APP_CLUSTER = '\uff08\u3053\u3053\u306b Pusher \u306e\u5730\u65b9\u540d\uff08\u304a\u305d\u3089\u304f ap3 \uff09\uff09'<\/strong>\r\n<strong>PUSHER_CHANNEL = 'finger-gestures'<\/strong>\r\n<strong>PUSHER_EVENT = 'Scroll'<\/strong>\r\n\r\n<strong>def get_status(results):<\/strong>\r\n<strong>    if results.multi_hand_landmarks:<\/strong>\r\n<strong>        hand_landmarks = results.multi_hand_landmarks[0].landmark<\/strong>\r\n<strong>        thumb = hand_landmarks[4]           # \u89aa\u6307<\/strong>\r\n<strong>        index_finger = hand_landmarks[8]    # \u4eba\u5dee\u3057\u6307<\/strong>\r\n<strong>        middle_finger = hand_landmarks[12]  # \u4e2d\u6307<\/strong>\r\n<strong>        ring_finger = hand_landmarks[16]    # \u85ac\u6307<\/strong>\r\n<strong>        pinky_finger = hand_landmarks[20]   # \u5c0f\u6307<\/strong>\r\n<strong>        # \u89aa\u6307\u304c\u4ed6\u306e\u6307\u3088\u308a\u4e0a\u306b\u3042\u308b\u5834\u5408\uff08\u4e0a\u90e8\u304b\u3089\u306e\u30d1\u30fc\u30bb\u30f3\u30c6\u30fc\u30b8\u304c\u5c11\u306a\u3044\u5834\u5408\uff09<\/strong>\r\n<strong>        if thumb.y &lt; index_finger.y and \\<\/strong>\r\n<strong>            thumb.y &lt; middle_finger.y and  \\<\/strong>\r\n<strong>            thumb.y &lt; ring_finger.y and  \\<\/strong>\r\n<strong>            thumb.y &lt; pinky_finger.y:<\/strong>\r\n<strong>            return 'up'<\/strong>\r\n<strong>        else:<\/strong>\r\n<strong>            return 'down'<\/strong>\r\n<strong>    else:<\/strong>\r\n<strong>        return 'none'<\/strong>\r\n\r\n<strong>hands = mp.solutions.hands.Hands(static_image_mode=True, max_num_hands=1, min_detection_confidence=0.5)<\/strong>\r\n<strong>cap = cv2.VideoCapture(0) # \u4e00\u756a\u76ee\u306e\u30ab\u30e1\u30e9<\/strong>\r\n<strong>pusher_client = pusher.Pusher(<\/strong>\r\n<strong>    app_id=PUSHER_APP_ID,<\/strong>\r\n<strong>    key=PUSHER_APP_KEY,<\/strong>\r\n<strong>    secret=PUSHER_APP_SECRET,<\/strong>\r\n<strong>    cluster=PUSHER_APP_CLUSTER<\/strong>\r\n<strong>)<\/strong>\r\n\r\n<strong>if not cap.isOpened():<\/strong>\r\n<strong>    print('\u30ab\u30e1\u30e9\u304c\u8d77\u52d5\u3057\u3066\u3044\u307e\u305b\u3093')<\/strong>\r\n<strong>    exit()<\/strong>\r\n\r\n<strong>status = 'none'<\/strong>\r\n<strong>last_triggerd_at = 0<\/strong>\r\n\r\n<strong>while True:<\/strong>\r\n<strong>    ret, frame = cap.read()<\/strong>\r\n<strong>    if ret == True:<\/strong>\r\n<strong>        im = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)<\/strong>\r\n<strong>        results = hands.process(im)<\/strong>\r\n<strong>        status = get_status(results)<\/strong>\r\n<strong>        cv2.putText(<\/strong>\r\n<strong>            frame,<\/strong>\r\n<strong>            text=status, <\/strong>\r\n<strong>            org=(25, 50),<\/strong>\r\n<strong>            fontFace=cv2.FONT_HERSHEY_SIMPLEX,<\/strong>\r\n<strong>            fontScale=1,<\/strong>\r\n<strong>            color=(0, 0, 255),<\/strong>\r\n<strong>            thickness=2,<\/strong>\r\n<strong>            lineType=cv2.LINE_4)<\/strong>\r\n<strong>        cv2.imshow('video', frame)<\/strong>\r\n\r\n<strong>        now = time.time()<\/strong>\r\n<strong>        delta_time = now - last_triggerd_at<\/strong>\r\n\r\n<strong>        # \u30b9\u30c6\u30fc\u30bf\u30b9\u304c\u3042\u308c\u3070\u3001\uff11\u79d2\u9593\u306b\u4e00\u56de\u3060\u3051\u5b9f\u884c\u3059\u308b<\/strong>\r\n<strong>        if status in ['up', 'down'] and delta_time &gt; 1:<\/strong>\r\n<strong>            # pusher_client.trigger(PUSHER_CHANNEL, PUSHER_EVENT, { 'status': status }) # Pusher \u3078\u9001\u4fe1<\/strong>\r\n<strong>            last_triggerd_at = now # \u6700\u5f8c\u306b Pusher \u3078\u9001\u4fe1\u3057\u305f\u6642\u9593<\/strong>\r\n<strong>    if cv2.waitKey(1) &amp; 0xFF == ord('q'):<\/strong>\r\n<strong>        break<\/strong>\r\n\r\n<strong>cap.release()<\/strong>\r\n<strong>cv2.destroyAllWindows()<\/strong><\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u91cd\u8981\u306a\u306e\u304c\u3001\u6307\u306e\u30b8\u30a7\u30b9\u30c1\u30e3\u30fc\u3092\u5224\u5225\u3057\u3066\u3044\u308b<code>get_status()<\/code>\u306e\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u30b7\u30f3\u30d7\u30eb\u306b\u300c<strong>\u89aa\u6307\u304c\u4e0a or \u4e0b<\/strong>\u300d\u304c\u5206\u304b\u308c\u3070\u3044\u3044\u3060\u3051\u3067\u3059\u306e\u3067\u3001<code>MediaPipe<\/code>\u3067\u53d6\u5f97\u3057\u305f\u300c<strong>\u89aa\u6307\u306e\u4f4d\u7f6e\u304c\u4ed6\u306e\u6307\u3088\u308a\u3082\u4e0a\u304b\u4e0b\u304b\uff1f<\/strong>\u300d\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3053\u3068\u3067\u5224\u5225\u3092\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\uff11\u70b9\u6c17\u3092\u3064\u3051\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u304c\u3001\u53d6\u5f97\u3067\u304d\u308bY\u5ea7\u6a19\u306f\u300c<strong>\u6570\u5024\u304c\u5c0f\u3055\u3044\u307b\u3069\u4e0a\u306b\u3042\u308b<\/strong>\u300d\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u753b\u50cf\u3067\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9957\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/01\/python_auto_scroll_1.png\" alt=\"\" width=\"502\" height=\"619\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/01\/python_auto_scroll_1.png 502w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/01\/python_auto_scroll_1-243x300.png 243w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001Y\u5ea7\u6a19\u306f\u300c<strong>\u753b\u50cf\u4e0a\u90e8\u304b\u3089\u306e\u4f4d\u7f6e<\/strong>\u300d\u3067\u3059\u306e\u3067\u76f4\u611f\u7684\u306a\u3082\u306e\u3068\u306f\u9006\u306b\u306a\u308b\u3068\u3044\u3046\u3053\u3068\u3092\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001\u53d6\u5f97\u3067\u304d\u308b\u6307\u306e\u4f4d\u7f6e\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9958\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/01\/python_auto_scroll_2.png\" alt=\"\" width=\"290\" height=\"263\" \/><br \/>\n\uff08<a href=\"https:\/\/google.github.io\/mediapipe\/solutions\/hands.html#static_image_mode\" target=\"_blank\" rel=\"noopener\">MediaPipe \u30a6\u30a7\u30d6\u30b5\u30a4\u30c8<\/a>\u304b\u3089\u306e\u5f15\u7528\uff09<\/p>\n<p>\u3053\u308c\u3067\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u30d3\u30c7\u30aa\u30ad\u30e3\u30d7\u30c1\u30e3\u753b\u50cf\u3092\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u8868\u793a\u3055\u308c\u3001\u3055\u3089\u306b\u300c\u89aa\u6307\u304c\u4e0a\u304b\u4e0b\u304b\uff1f\u300d\u3082<code>up<\/code>\u3001<code>down<\/code>\u3001<code>none<\/code>\u3068\u3057\u3066\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>python3 auto_scroll.py<\/strong><\/pre>\n<p>\u5b9f\u969b\u306b\u8a66\u3057\u3066\u307f\u308b\u3068\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9959\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/01\/python_auto_scroll_3.png\" alt=\"\" width=\"640\" height=\"565\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/01\/python_auto_scroll_3.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/01\/python_auto_scroll_3-300x265.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<h1>JavaScript \u5074\u306e\u4f5c\u696d<\/h1>\n<p>\u3067\u306f\u7d9a\u3044\u3066<code>JavaScript<\/code>\u5074\u306e\u4f5c\u696d\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u5fc5\u305a\u30a6\u30a7\u30d6\u30b5\u30fc\u30d0\u30fc\u3092\u901a\u3057\u3066\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u305d\u3046\u3057\u306a\u3044\u3068\u3001\u304a\u305d\u3089\u304f<code>Pusher<\/code>\u304c\u5b9f\u884c\u3067\u304d\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u203b \u3061\u306a\u307f\u306b\u3001\u79c1\u306e\u5834\u5408\u306f<code>Laravel 8.x<\/code>\u3067\u5b9f\u884c\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u30b5\u30f3\u30d7\u30eb\u306f<code>Blade<\/code>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<p><strong>resources\/views\/auto_scroll.blade.php<\/strong><\/p>\n<pre><strong>&lt;html&gt;<\/strong>\r\n<strong>&lt;head&gt;<\/strong>\r\n<strong>    &lt;link href=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.0.1\/dist\/css\/bootstrap.min.css\" rel=\"stylesheet\"&gt;<\/strong>\r\n<strong>&lt;\/head&gt;<\/strong>\r\n<strong>&lt;body&gt;<\/strong>\r\n<strong>&lt;div id=\"app\"&gt;<\/strong>\r\n<strong>    @for($i = 0 ; $i &lt; 1000 ; $i++)<\/strong>\r\n<strong>        @if($i%2 === 0)<\/strong>\r\n<strong>            &lt;div class=\"bg-danger text-light p-2\"&gt;{{ $i }}&lt;\/div&gt;<\/strong>\r\n<strong>        @else<\/strong>\r\n<strong>            &lt;div class=\"bg-success text-light p-2\"&gt;{{ $i }}&lt;\/div&gt;<\/strong>\r\n<strong>        @endif<\/strong>\r\n<strong>    @endfor<\/strong>\r\n<strong>&lt;\/div&gt;<\/strong>\r\n<strong>&lt;script src=\"\/js\/app.js\"&gt;&lt;\/script&gt;<\/strong>\r\n<strong>&lt;script&gt;<\/strong>\r\n\r\n<strong>    window.onload = () =&gt; {<\/strong>\r\n\r\n<strong>        Echo.channel('finger-gestures')<\/strong>\r\n<strong>            .listen('.Scroll', e =&gt; {<\/strong>\r\n\r\n<strong>                const status = e.status;<\/strong>\r\n<strong>                const movingLength = 100;<\/strong>\r\n<strong>                let top = window.scrollY;<\/strong>\r\n\r\n<strong>                if(status === 'up') {<\/strong>\r\n\r\n<strong>                    top = Math.max(0, top - movingLength);<\/strong>\r\n<strong>                    scrollTo(0, top);<\/strong>\r\n\r\n<strong>                } else if(status === 'down') {<\/strong>\r\n\r\n<strong>                    top = Math.min(document.body.scrollHeight, top + movingLength);<\/strong>\r\n<strong>                    scrollTo(0, top);<\/strong>\r\n\r\n<strong>                }<\/strong>\r\n\r\n<strong>            });<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>&lt;\/script&gt;<\/strong>\r\n<strong>&lt;\/body&gt;<\/strong>\r\n<strong>&lt;\/html&gt;<\/strong><\/pre>\n<p>\u306a\u304a\u3001\u5b9f\u306f\u79c1\u3082\u5c11\u3057\u30cf\u30de\u3063\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u3059\u304c\u3001<code>listen()<\/code>\u5185\u306b\u306f\u30a4\u30d9\u30f3\u30c8\u540d\u3092\u3044\u308c\u308b\u3053\u3068\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u5148\u982d\u306b\u30c9\u30c3\u30c8\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u306f\u30df\u30b9\u30bf\u30a4\u30d7\u3067\u306f\u306a\u304f\u3001\u300c<strong><code>Echo.channel()<\/code>\u3092\u4f7f\u3046\u5834\u5408\u306f\u3001\u30c9\u30c3\u30c8\u3092\u542b\u3081\u305f\u30d7\u30ea\u30d5\u30a3\u30c3\u30af\u30b9\u304c\u5fc5\u8981<\/strong>\u300d\u3068\u3044\u3046\u30eb\u30fc\u30eb\u304c\u3042\u308b\u304b\u3089\u3067\u3059\u3002\uff08\u4ee5\u524d\u306f\u306a\u304b\u3063\u305f\u6c17\u304c\u3059\u308b\u3093\u3067\u3059\u3051\u3069\u306d\u3002\u3002\ud83d\ude25\uff09<\/p>\n<p>\u8a73\u3057\u304f\u306f\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>\ud83d\udcdd \u53c2\u8003\u30da\u30fc\u30b8\uff1a<\/strong> <a href=\"https:\/\/github.com\/tlaverdure\/laravel-echo-server\/issues\/116#issuecomment-275432879\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/tlaverdure\/laravel-echo-server\/issues\/116#issuecomment-275432879<\/a><\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u305d\u308c\u3067\u306f\u3001\u5b9f\u969b\u306b\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u2757<br \/>\n\u4eca\u56de\u306f\u52d5\u753b\u306b\u3057\u3066\u307f\u307e\u3057\u305f\u306e\u3067\u4ee5\u4e0b\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u2193\u2193\u2193<\/p>\n<p><iframe loading=\"lazy\" title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/O15qIJGXfHs\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u60f3\u5b9a\u3057\u3066\u3044\u305f\u4ee5\u4e0a\u306b\u30ad\u30d3\u30ad\u30d3\u5207\u308a\u66ff\u308f\u3063\u3066\u304f\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u6210\u529f\u3067\u3059\ud83d\ude04\u2728<\/p>\n<h1>\u4f01\u696d\u69d8\u3078\u306e\u3054\u63d0\u6848<\/h1>\n<p>\u4eca\u56de\u306e\u6280\u8853\u3092\u4f7f\u3046\u3068\u3001\u4f8b\u3048\u3070\u5de5\u5834\u5185\u3067\u4f5c\u696d\u3092\u3057\u306a\u304c\u3089\u30d1\u30bd\u30b3\u30f3\u3092\u64cd\u4f5c\u3059\u308b\u5834\u5408\u306b\u300c<strong>\u30ab\u30e1\u30e9\u306b\u624b\u306e\u30b8\u30a7\u30b9\u30c1\u30e3\u30fc\u3092\u898b\u305b\u308b\u3060\u3051<\/strong>\u300d\u3067\u5165\u529b\uff06\u5b9f\u884c\u3067\u304d\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u4eca\u56de\u3054\u7d39\u4ecb\u3057\u305f\u306e\u306f\u300c\u4e0a or \u4e0b\u300d\u3060\u3051\u306e\u30b8\u30a7\u30b9\u30c1\u30e3\u30fc\u3067\u3057\u305f\u304c\u3001\u6a5f\u68b0\u5b66\u7fd2\u3092\u4f7f\u3048\u3070\u300c<strong>\u30b0\u30fc<\/strong>\u300d\u300c<strong>\u30c1\u30e7\u30ad<\/strong>\u300d\u300c<strong>\u30d1\u30fc<\/strong>\u300d\u300c<strong>\u30e1\u30ed\u30a4\u30c3\u30af\u30fb\u30b5\u30a4\u30f3<\/strong>\u300d\u300c<strong>\u30b9\u30d1\u30a4\u30c0\u30fc\u30de\u30f3\u306e\u624b\u306e\u5f62<\/strong>\u300d\u306a\u3069\u3088\u308a\u591a\u304f\u306e\u30b8\u30a7\u30b9\u30c1\u30e3\u306b\u3082\u5bfe\u5fdc\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057\u305d\u3046\u3044\u3063\u305f\u6a5f\u80fd\u3092\u3054\u5e0c\u671b\u3067\u3057\u305f\u3089\u305c\u3072\u304a\u554f\u3044\u5408\u308f\u305b\u304b\u3089\u3054\u9023\u7d61\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u304a\u5f85\u3061\u3057\u3066\u304a\u308a\u307e\u3059\u3002m(_ _)m<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u5c11\u3057\u3044\u3064\u3082\u3068\u306f\u9055\u3063\u3066<code>Python<\/code>\u3092\u4f7f\u3063\u305f\u5185\u5bb9\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u306a\u304a\u3001\u5b9f\u306f<code>MediaPipe<\/code>\u306f\u30d6\u30e9\u30a6\u30b6\u306e<code>JavaScript<\/code>\u3067\u3082\u52d5\u304f\u306e\u3067\u3059\u304c\u3001\u4ee5\u524d\u5225\u306e\u958b\u767a\u51fa\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30a6\u30a7\u30d6\u30ab\u30e1\u30e9\u3092\u4f7f\u3046\u3068<code>CPU<\/code>\u4f7f\u7528\u7387\u304c\u5927\u304d\u304f\u306a\u308a\u3059\u304e\u3066\u3057\u307e\u3063\u305f\u305f\u3081\u3001\u4eca\u56de\u306f<code>Python<\/code>\u3092\u9078\u629e\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3068\u306f\u3044\u3048\u3001\u4eca\u56de\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b<code>15\uff05<\/code>\u307b\u3069\u306e<code>CPU<\/code>\u4f7f\u7528\u7387\u306b\u306a\u3063\u3066\u3044\u307e\u3057\u305f\u306e\u3067\u3001\u30a6\u30a7\u30d6\u30ab\u30e1\u30e9\u304b\u3089\u753b\u50cf\u3092\u53d6\u5f97\u3059\u308b\u90e8\u5206\u3092\uff11\u79d2\u306b\uff11\u56de\u3054\u3068\u306b\u5909\u66f4\u3057\u3066\u307f\u305f\u3068\u3053\u308d<code>7%<\/code>\u307b\u3069\u306b\u6291\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b9f\u969b\u306b\u4f7f\u3046\u5834\u5408\u306f\u3001\u3053\u306e\u8fba\u308a\u306e\u300c\u8ca0\u8377\u3068\u4fbf\u5229\u3055\u300d\u306e\u30d0\u30e9\u30f3\u30b9\u304c\u5fc5\u8981\u306b\u306a\u3063\u3066\u304f\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\uff08\u30ab\u30e1\u30e9\u90e8\u5206\u306f\u5c02\u7528\u3067<code>Raspberry Pi<\/code>\u3092\u4f7f\u3063\u3066\u3082\u826f\u3044\u304b\u3082\u3067\u3059\u306d\ud83d\udc4d\uff09<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u3082\u81ea\u7531\u7814\u7a76\u7684\u306a\u30ab\u30f3\u30b8\u3067\u8a66\u3057\u3066\u898b\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u2757<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6066 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_23.png\" alt=\"\" width=\"370\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_23.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_23-300x259.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/>\u300c\u5927\u6383\u9664\u5f8c\u3001<br \/>\n<strong>\u3010\u4e0d\u8981\u54c1\u914d\u308a\u304a\u3058\u3055\u3093\u3011<\/strong><br \/>\n\u3068\u3057\u3066\u30e2\u30ce\u3092\u914d\u308a\u307e\u3057\u305f\ud83d\udc4d\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001Python\u304c\u4e16\u754c\u7684\u306b\u4eba\u6c17\u306e\u8a00\u8a9e\u306b\u306a\u3063\u3066\u304b\u3089\u7d50\u69cb\u6642\u9593\u304c\u7d4c\u3061\u307e\u3059\u304c\u3001\u6b63\u76f4\u306a\u3068\u3053\u308dLaravel + Vue\u304c\u30e1\u30a4\u30f3\u306e\u958b\u767a\u3092\u3055\u305b\u3066\u3044\u305f\u3060\u3044\u3066\u3044\u308b\u3053\u3068\u3082\u3042\u308a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=9955\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u3010Python + JavaScript\u3011\u6307\u30b8\u30a7\u30b9\u30c1\u30e3\u30fc\u3067\u30da\u30fc\u30b8\u30b9\u30af\u30ed\u30fc\u30eb\u3059\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":9963,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,120,39],"tags":[229],"class_list":["post-9955","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-opencv","category-python","tag-pusher"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/9955","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9955"}],"version-history":[{"count":8,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/9955\/revisions"}],"predecessor-version":[{"id":9970,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/9955\/revisions\/9970"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/9963"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}