Skip to content

Latest commit

 

History

History
83 lines (63 loc) · 2.69 KB

README.md

File metadata and controls

83 lines (63 loc) · 2.69 KB

Ring Face Recognition

License: ISC GitHub Actions Test GitHub Actions Release

概要

Ring Doorbellで顔認識するためのアプリケーションです。

フローチャート

graph TD
    start(Ringモーション検知) --> startStream[ストリーミング開始]
    startStream --> detectFace[画像を解析し顔を検出]

    %% 必要な顔画像数に達するまでのループ
    detectFace --> faceCount{顔画像数が必要数以上か?}
    faceCount -->|No| waitAndRetry[再試行: 画像を取得]
    waitAndRetry --> detectFace
    faceCount -->|Yes| composeImages[画像を合成]

    %% Recognition
    composeImages --> sendToRecognition[Amazon Recognitionで顔認識]
    matched -->|Yes| notifyWebhook[Webhookで一致したIDを通知]
    notifyWebhook --> stopStream[ストリーミング終了]

    %% Recognition失敗時の処理
    sendToRecognition --> matched{顔一致あり?}
    matched -->|No| retry{リトライ可能?}
    retry -->|Yes| clearFace[顔画像を全てクリア]
    clearFace --> detectFace
    retry -->|No| stopStream

    %% タイムアウト処理
    startStream --> timeout[タイムアウト]
    timeout --> stopStream
Loading
  • AWSのコストを抑えるためにFace Detectorを使ってローカルでざっくり検出させています
  • 閾値未満と顔見検出はストリーミング開始直後の荒い画像が原因の可能性が高いのでリトライしています

使い方

認証

# 取得したリフレッシュトークンを .refreshToken へ保存します (""は不要)
npm run auth

Native

npm install
npm run build
node --env-file=.env dist/index

Docker

# --net=hostの方が安定する
docker run -d \
  --net=host \
  --name ring-face-recognition \
  -v $(pwd)/.refreshToken:/app/.refreshToken \
  -p 3000:3000 \
  --env-file .env \
  --restart always \
  nana4rider/ring-face-recognition:latest

Tip

必要な環境変数についてはこちらをご確認ください。

ストリーミングを安定させるため、 host ネットワーク・モードの利用を推奨します。

リンク