勉強しないとな~blog

ちゃんと勉強せねば…な電気設計エンジニアです。

OAK-D S2進める - 手検出サンプル2

前回の続き。

nokixa.hatenablog.com

やったこと

前回のhand_trackerのサンプルで、OAK-Dデバイスでなく動画ファイルを入力にできるとのことで、試した。
内部でMediaPipeが使用されているので、普通にMediaPipeを使うのでもいいかもしれないが、こちらではBPF(Body Pre Focusing)が用意されているので、結果が良くなるかもしれない。

前のピアノ弾いてる動画で。

環境

前回と同じGitHubリポジトリで。

github.com

前回下記のようにクローンしたものをそのまま使う。

git clone https://github.com/geaxgx/depthai_hand_tracker

実施

python demo.py --input "../../data/2023-08-31 07.48.56.mp4" --output "../../data/2023-08-31 07.48.56_depthai_1.avi"
Palm detection blob : C:\work\oak-d_test\depthai_hand_tracker\models\palm_detection_sh4.blob
Landmark blob       : C:\work\oak-d_test\depthai_hand_tracker\models\hand_landmark_lite_sh4.blob
Video FPS: 15
Original frame size: 2304x1296
Padding on height : 504
Frame working size: 2304x1296
896 anchors have been created
Creating pipeline...
Creating Palm Detection Neural Network...
Creating Hand Landmark Neural Network (2 threads)...
Pipeline created.
[19443010819FF41200] [2.6] [1.075] [NeuralNetwork(0)] [warning] Network compiled for 4 shaves, maximum available 16, compiling for 8 shaves likely will yield in better performance
Pipeline started - USB speed: SUPER
[19443010819FF41200] [2.6] [1.076] [NeuralNetwork(3)] [warning] Network compiled for 4 shaves, maximum available 16, compiling for 8 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [1.082] [NeuralNetwork(0)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
[19443010819FF41200] [2.6] [1.082] [NeuralNetwork(3)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
FPS : 15.8 f/s (# frames = 458)
# frames w/ no hand           : 1 (0.2%)
# frames w/ palm detection    : 47 (10.3%)
# frames w/ landmark inference : 456 (99.6%)- # after palm detection: 46 - # after landmarks ROI prediction: 410
On frames with at least one landmark inference, average number of landmarks inferences/frame: 1.34
# lm inferences: 610 - # failed lm inferences: 97 (15.9%)
Palm detection round trip            : 27.7 ms
Hand landmark round trip             : 18.7 ms

今回はOAK-Dカメラは不要だが、接続しておかないとエラーになってしまった。
のでつなぎながらやっている。

以前MediaPipeを使ったときと特に変わらない感じ。
当然か?
ほとんど左手しか認識されていない。

モデル変更

-lm_modelオプションで、使うモデルを変えられるようなので、fullのモデルでやってみる。

python demo.py --input "../../data/2023-08-31 07.48.56.mp4" --output "../../data/2023-08-31 07.48.56_depthai_2.avi" --lm_model full
Palm detection blob : C:\work\oak-d_test\depthai_hand_tracker\models\palm_detection_sh4.blob
Landmark blob       : C:\work\oak-d_test\depthai_hand_tracker\models\hand_landmark_full_sh4.blob
Video FPS: 15
Original frame size: 2304x1296
Padding on height : 504
Frame working size: 2304x1296
896 anchors have been created
Creating pipeline...
Creating Palm Detection Neural Network...
Creating Hand Landmark Neural Network (2 threads)...
Pipeline created.
[19443010819FF41200] [2.6] [1.127] [NeuralNetwork(0)] [warning] Network compiled for 4 shaves, maximum available 16, compiling for 8 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [1.128] [NeuralNetwork(3)] [warning] Network compiled for 4 shaves, maximum available 16, compiling for 8 shaves likely will yield in better performance
Pipeline started - USB speed: SUPER
[19443010819FF41200] [2.6] [1.136] [NeuralNetwork(0)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
[19443010819FF41200] [2.6] [1.136] [NeuralNetwork(3)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
FPS : 13.8 f/s (# frames = 458)
# frames w/ no hand           : 1 (0.2%)
# frames w/ palm detection    : 47 (10.3%)
# frames w/ landmark inference : 456 (99.6%)- # after palm detection: 46 - # after landmarks ROI prediction: 410
On frames with at least one landmark inference, average number of landmarks inferences/frame: 1.29
# lm inferences: 588 - # failed lm inferences: 69 (11.7%)
Palm detection round trip            : 27.5 ms
Hand landmark round trip             : 28.8 ms

いまいち変わらないか、少し悪くなったか…
最初の動画と同じ範囲を切り出したので見えないが、 切り出し範囲外では、両手が認識されるタイミングが増えていた。

BPF使用

次、BPF付きのコードを実施。

いくつかオプションあるが、

  • --body_pre_focusingオプションは、4パターンあるが、今回は両手の検出をしたい(Duoモード、-sオプション設定しない場合のデフォルト)ので、groupに強制される、ので設定はなし
    • right: 右手だけ検出
    • left: 左手だけ検出
    • higher: 手を上げた場合だけ検出(肘との位置関係)
    • group: 右手、左手両方含むエリアを取り出す
  • --all_handsは、設定しないと、手を上げた場合だけ考慮になる、設定すると、全条件で考慮、なのでこれは設定する
python demo_bpf.py --input "../../data/2023-08-31 07.48.56.mp4" --output "../../data/2023-08-31 07.48.56_depthai_3.avi" --all_hands
Palm detection blob : C:\work\oak-d_test\depthai_hand_tracker\models\palm_detection_sh4.blob
Landmark blob       : C:\work\oak-d_test\depthai_hand_tracker\models\hand_landmark_lite_sh4.blob
In Duo mode, body_pre_focusing is forced to 'group'
Body pose blob      : C:\work\oak-d_test\depthai_hand_tracker\models\movenet_singlepose_thunder_U8_transpose.blob
Video FPS: 15
Original frame size: 2304x1296
Padding on height : 504
Frame working size: 2304x1296
896 anchors have been created
Creating pipeline...
Creating Body Pose Neural Network...
Creating Palm Detection Neural Network...
Creating Hand Landmark Neural Network...
Pipeline created.
[19443010819FF41200] [2.6] [1.248] [NeuralNetwork(3)] [warning] Network compiled for 4 shaves, maximum available 16, compiling for 8 shaves likely will yield in better performance
Pipeline started - USB speed: SUPER
[19443010819FF41200] [2.6] [1.249] [NeuralNetwork(0)] [warning] Network compiled for 4 shaves, maximum available 16, compiling for 8 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [1.249] [NeuralNetwork(6)] [warning] Network compiled for 4 shaves, maximum available 16, compiling for 8 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [1.257] [NeuralNetwork(3)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
[19443010819FF41200] [2.6] [1.257] [NeuralNetwork(0)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
[19443010819FF41200] [2.6] [1.257] [NeuralNetwork(6)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
FPS : 15.1 f/s (# frames = 458)
# frames w/ no hand           : 0 (0.0%)
# frames w/ palm detection    : 35 (7.6%)
# frames w/ landmark inference : 457 (99.8%)- # after palm detection: 35 - # after landmarks ROI prediction: 422
On frames with at least one landmark inference, average number of landmarks inferences/frame: 1.20
# lm inferences: 549 - # failed lm inferences: 4 (0.7%)
Body pose estimation round trip      : 94.7 ms
Palm detection round trip            : 25.5 ms
Hand landmark round trip             : 24.5 ms

結果、それほど変わらず。
若干、両手が認識されるタイミングが変わったりしてる。
(載せた動画の範囲外)

モデル変更&BPF使用

python demo_bpf.py --input "../../data/2023-08-31 07.48.56.mp4" --output "../../data/2023-08-31 07.48.56_depthai_4.avi" --lm_model full --all_hands
Palm detection blob : C:\work\oak-d_test\depthai_hand_tracker\models\palm_detection_sh4.blob
Landmark blob       : C:\work\oak-d_test\depthai_hand_tracker\models\hand_landmark_full_sh4.blob
In Duo mode, body_pre_focusing is forced to 'group'
Body pose blob      : C:\work\oak-d_test\depthai_hand_tracker\models\movenet_singlepose_thunder_U8_transpose.blob
Video FPS: 15
Original frame size: 2304x1296
Padding on height : 504
Frame working size: 2304x1296
896 anchors have been created
Creating pipeline...
Creating Body Pose Neural Network...
Creating Palm Detection Neural Network...
Creating Hand Landmark Neural Network...
Pipeline created.
[19443010819FF41200] [2.6] [1.386] [NeuralNetwork(3)] [warning] Network compiled for 4 shaves, maximum available 16, compiling for 8 shaves likely will yield in better performance
Pipeline started - USB speed: SUPER
[19443010819FF41200] [2.6] [1.386] [NeuralNetwork(0)] [warning] Network compiled for 4 shaves, maximum available 16, compiling for 8 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [1.387] [NeuralNetwork(6)] [warning] Network compiled for 4 shaves, maximum available 16, compiling for 8 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [1.395] [NeuralNetwork(3)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
[19443010819FF41200] [2.6] [1.395] [NeuralNetwork(0)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
[19443010819FF41200] [2.6] [1.395] [NeuralNetwork(6)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
FPS : 12.7 f/s (# frames = 458)
# frames w/ no hand           : 0 (0.0%)
# frames w/ palm detection    : 34 (7.4%)
# frames w/ landmark inference : 457 (99.8%)- # after palm detection: 34 - # after landmarks ROI prediction: 423
On frames with at least one landmark inference, average number of landmarks inferences/frame: 1.18
# lm inferences: 538 - # failed lm inferences: 3 (0.6%)
Body pose estimation round trip      : 97.9 ms
Palm detection round trip            : 25.8 ms
Hand landmark round trip             : 36.7 ms

なぜかScreenToGifで動画ファイル読み込みできなかったので、GIFなしだが、 大きな変化はなかった。
見た目判断だが。

ここまで

ピアノ動画では、右手側の鍵盤が太陽の光の反射で真っ白に飛んでるので、もしかしたら映りの大きさよりそっちのほうが問題かもしれない。

<備忘録>HTMLで折り畳みコンテンツ

折り畳みコンテンツの作り方、何回か使って、以前のブログ記事にも載せたが、記事の中に埋もれてしまって、少し探してしまったので、今後すぐ参照できるように。

書き方

<details>
<summary>
クリックで開く/閉じる
</summary>

コンテンツ

</details>

detailsとsummaryどっちが外側だったか、内側だったか、すぐ忘れてしまう。

HTML5から登場したもののよう。
IEでは対応していないらしい。

detailsとsummaryタグでアコーディオンを作る - HTMLリファレンス

とりあえずはてなブログMarkdownモードで書いてる限りは、これで動いてる。

使用例

以前のYOLO物体認識結果のログ(結構長い)で。

クリックで開く/閉じる

(yolov5) PS C:\work\yolo_test\yolov5> python detect.py --source rtsp://USER:PASSWORD@192.168.1.29 --view-img                    
detect: weights=yolov5s.pt, source=rtsp://USER:PASSWORD@192.168.1.29, data=data\coco128.yaml, imgsz=[640, 640], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=, view_img=True, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs\detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1
YOLOv5  v7.0-210-gdd10481 Python-3.11.4 torch-2.0.1+cpu CPU

Fusing layers... 
YOLOv5s summary: 213 layers, 7225885 parameters, 0 gradients
1/1: rtsp://USER:PASSWORD@192.168.1.29...  Success (inf frames 2304x1296 at 25.00 FPS)

0: 384x640 1 person, 126.9ms
0: 384x640 1 person, 145.1ms
0: 384x640 1 person, 136.3ms
0: 384x640 1 person, 126.6ms
0: 384x640 1 person, 131.3ms
0: 384x640 1 person, 121.4ms
0: 384x640 1 person, 102.3ms
0: 384x640 1 person, 104.9ms
0: 384x640 1 person, 100.0ms
0: 384x640 1 person, 107.8ms
0: 384x640 1 person, 103.2ms
0: 384x640 1 person, 101.0ms
0: 384x640 1 person, 101.4ms
0: 384x640 1 person, 107.9ms
0: 384x640 1 person, 103.0ms
0: 384x640 1 person, 104.0ms
0: 384x640 1 person, 99.9ms
0: 384x640 1 person, 102.0ms
0: 384x640 1 person, 101.4ms
0: 384x640 1 person, 100.0ms
0: 384x640 1 person, 95.4ms
0: 384x640 1 person, 116.2ms
0: 384x640 2 persons, 102.4ms
0: 384x640 1 person, 102.6ms
0: 384x640 1 person, 102.0ms
0: 384x640 1 person, 98.7ms
0: 384x640 1 person, 91.6ms
0: 384x640 1 person, 105.3ms
0: 384x640 1 person, 115.2ms
0: 384x640 1 person, 1 remote, 102.4ms
0: 384x640 1 person, 101.7ms
0: 384x640 1 person, 98.9ms
0: 384x640 1 person, 1 bench, 1 toothbrush, 101.4ms
0: 384x640 1 person, 100.8ms
0: 384x640 1 person, 1 bench, 1 toothbrush, 100.7ms
0: 384x640 1 person, 116.4ms
0: 384x640 1 person, 108.4ms
0: 384x640 1 person, 1 book, 114.5ms
0: 384x640 1 person, 2 books, 106.1ms
0: 384x640 1 person, 1 bottle, 105.4ms
0: 384x640 1 person, 115.0ms
0: 384x640 1 person, 104.8ms
0: 384x640 1 person, 105.3ms
0: 384x640 1 person, 100.5ms
0: 384x640 1 person, 104.2ms
0: 384x640 1 person, 101.4ms
0: 384x640 2 persons, 107.2ms
0: 384x640 1 person, 98.9ms
0: 384x640 2 persons, 119.1ms
0: 384x640 2 persons, 106.0ms
0: 384x640 1 person, 97.7ms
0: 384x640 1 person, 103.6ms
0: 384x640 1 person, 107.9ms
0: 384x640 2 persons, 98.3ms
0: 384x640 1 person, 108.5ms
0: 384x640 2 persons, 112.8ms
0: 384x640 2 persons, 120.2ms
0: 384x640 2 persons, 103.5ms
0: 384x640 2 persons, 102.5ms
0: 384x640 3 persons, 101.0ms
0: 384x640 3 persons, 102.6ms
0: 384x640 2 persons, 102.7ms
0: 384x640 3 persons, 1 bed, 115.9ms
0: 384x640 2 persons, 97.8ms
0: 384x640 2 persons, 1 bed, 102.7ms
0: 384x640 2 persons, 1 bed, 103.1ms
0: 384x640 3 persons, 1 bed, 102.3ms
0: 384x640 2 persons, 1 bed, 101.0ms
0: 384x640 2 persons, 1 bed, 102.9ms
0: 384x640 3 persons, 1 bed, 118.3ms
0: 384x640 1 person, 1 bed, 106.1ms
0: 384x640 3 persons, 103.9ms
0: 384x640 2 persons, 1 bed, 106.1ms
0: 384x640 3 persons, 112.8ms
0: 384x640 3 persons, 1 bed, 121.9ms
0: 384x640 2 persons, 115.7ms
0: 384x640 2 persons, 101.9ms
0: 384x640 2 persons, 108.7ms
0: 384x640 2 persons, 101.0ms
0: 384x640 2 persons, 1 bed, 104.7ms
0: 384x640 2 persons, 1 bed, 95.3ms
0: 384x640 1 person, 1 bed, 100.7ms
0: 384x640 1 person, 118.1ms
0: 384x640 1 person, 100.8ms
0: 384x640 1 person, 112.8ms
0: 384x640 1 person, 102.5ms
0: 384x640 1 person, 101.9ms
0: 384x640 1 person, 95.2ms
0: 384x640 2 persons, 105.7ms
0: 384x640 1 person, 122.1ms
0: 384x640 1 person, 101.0ms
0: 384x640 1 person, 100.7ms
0: 384x640 1 person, 112.0ms
0: 384x640 3 persons, 111.3ms
0: 384x640 2 persons, 104.9ms
0: 384x640 1 person, 106.8ms
0: 384x640 1 person, 102.2ms
0: 384x640 1 person, 108.7ms
0: 384x640 1 person, 104.7ms
0: 384x640 1 person, 90.2ms
0: 384x640 1 person, 98.1ms
0: 384x640 1 person, 103.5ms
0: 384x640 1 person, 104.1ms
0: 384x640 1 person, 108.6ms
0: 384x640 1 person, 113.7ms
0: 384x640 1 person, 105.1ms
0: 384x640 1 person, 103.0ms
0: 384x640 2 persons, 105.8ms
0: 384x640 2 persons, 101.6ms
0: 384x640 2 persons, 102.7ms
0: 384x640 2 persons, 119.5ms
0: 384x640 1 person, 102.8ms
0: 384x640 2 persons, 1 toothbrush, 101.2ms
0: 384x640 1 person, 107.1ms
0: 384x640 1 person, 113.5ms
0: 384x640 1 person, 105.8ms
0: 384x640 1 person, 1 cup, 104.2ms
0: 384x640 2 persons, 1 chair, 108.7ms
0: 384x640 2 persons, 104.5ms
0: 384x640 2 persons, 101.2ms
0: 384x640 1 bed, 105.6ms
0: 384x640 1 person, 1 bed, 102.9ms
0: 384x640 (no detections), 105.3ms
0: 384x640 (no detections), 115.1ms
0: 384x640 (no detections), 103.6ms
0: 384x640 (no detections), 107.4ms
0: 384x640 (no detections), 103.4ms
0: 384x640 (no detections), 101.3ms
0: 384x640 (no detections), 101.9ms
0: 384x640 (no detections), 101.8ms
0: 384x640 (no detections), 117.4ms
0: 384x640 (no detections), 106.6ms
0: 384x640 (no detections), 102.9ms
0: 384x640 (no detections), 102.0ms
0: 384x640 (no detections), 103.6ms
0: 384x640 (no detections), 102.8ms
0: 384x640 (no detections), 101.9ms
0: 384x640 (no detections), 115.6ms
0: 384x640 (no detections), 99.5ms
0: 384x640 (no detections), 98.7ms
0: 384x640 (no detections), 101.1ms
0: 384x640 (no detections), 103.8ms
0: 384x640 (no detections), 111.2ms
0: 384x640 (no detections), 109.7ms
0: 384x640 (no detections), 113.8ms
0: 384x640 (no detections), 104.3ms
0: 384x640 (no detections), 96.0ms
0: 384x640 (no detections), 109.0ms
0: 384x640 (no detections), 104.3ms
0: 384x640 (no detections), 102.8ms
0: 384x640 (no detections), 101.9ms
0: 384x640 (no detections), 114.4ms
0: 384x640 (no detections), 91.6ms
0: 384x640 (no detections), 104.1ms
0: 384x640 1 person, 102.2ms
0: 384x640 2 persons, 99.6ms
0: 384x640 2 persons, 1 teddy bear, 105.9ms
0: 384x640 2 persons, 1 teddy bear, 103.6ms
0: 384x640 2 persons, 1 teddy bear, 113.6ms
0: 384x640 2 persons, 102.0ms
0: 384x640 3 persons, 102.0ms
0: 384x640 2 persons, 103.1ms
0: 384x640 2 persons, 101.5ms
0: 384x640 2 persons, 1 bed, 102.6ms
0: 384x640 2 persons, 1 bed, 99.7ms
0: 384x640 2 persons, 1 bed, 89.5ms
0: 384x640 2 persons, 1 bed, 102.3ms
0: 384x640 2 persons, 1 bed, 106.4ms
0: 384x640 2 persons, 1 bed, 106.6ms
0: 384x640 2 persons, 1 bed, 102.5ms
0: 384x640 2 persons, 1 bed, 141.0ms
0: 384x640 2 persons, 1 bed, 128.0ms
0: 384x640 2 persons, 1 bed, 117.4ms
0: 384x640 2 persons, 1 bed, 125.5ms
0: 384x640 2 persons, 109.8ms
0: 384x640 2 persons, 109.2ms
0: 384x640 2 persons, 109.7ms
0: 384x640 2 persons, 1 bed, 109.7ms
0: 384x640 2 persons, 126.8ms
0: 384x640 2 persons, 1 bed, 93.9ms
0: 384x640 2 persons, 1 bed, 112.3ms
0: 384x640 2 persons, 93.9ms
0: 384x640 2 persons, 113.8ms
0: 384x640 1 person, 110.0ms
0: 384x640 1 person, 109.8ms
0: 384x640 2 persons, 94.0ms
0: 384x640 2 persons, 109.2ms
0: 384x640 1 person, 125.4ms
0: 384x640 1 person, 125.5ms
0: 384x640 2 persons, 1 hot dog, 111.1ms
0: 384x640 2 persons, 109.8ms
0: 384x640 2 persons, 115.0ms
0: 384x640 2 persons, 109.8ms
0: 384x640 2 persons, 108.2ms
0: 384x640 1 bed, 109.8ms
0: 384x640 2 persons, 110.4ms
0: 384x640 1 person, 125.5ms
0: 384x640 2 persons, 110.9ms
0: 384x640 2 persons, 111.1ms
0: 384x640 1 person, 109.8ms
0: 384x640 2 persons, 114.4ms
0: 384x640 2 persons, 1 remote, 110.6ms
0: 384x640 2 persons, 125.6ms
0: 384x640 2 persons, 108.1ms
0: 384x640 2 persons, 140.1ms
0: 384x640 2 persons, 1 donut, 149.0ms
0: 384x640 2 persons, 1 donut, 142.2ms
0: 384x640 3 persons, 1 donut, 125.4ms
0: 384x640 1 person, 120.4ms
0: 384x640 3 persons, 140.5ms
0: 384x640 3 persons, 125.8ms
0: 384x640 3 persons, 1 donut, 125.2ms

...

その他参考にしたサイト

はてなブログを使ってて気づいた事 - Aikの技術日記

details: 詳細折りたたみ要素 - HTML: ハイパーテキストマークアップ言語 | MDN

OAK-D S2進める - 手検出のサンプル

また続き。

ユースケース

最初のステップの次として、HelloWorldのほかに書かれているのが、ユースケース例。

DepthAI’s Documentation — DepthAI documentation | Luxonis

これを見ると、Hand Trackingのサンプルが出ていたので、これをやってみたい。

Hand Tracking

上記のTry Nowをクリックすると、GitHubのページに飛ぶ。

github.com

これを読んでみた感じ。

環境用意

まずリポジトリのクローン。

git clone https://github.com/geaxgx/depthai_hand_tracker

一応、今回クローンしたコミットを控えておく。

Author: geaxgx <geaxgx@gmail.com>
Date: 2023/01/15 2:07:41
Commit hash: 97731232fffd467e8de2c3a34ab8382962bb385e

Replacing np.int by np.int32 as np.int is no longer available starting from numpy 1.24

requirements.txtを見てみると、前回のhello-worldのものと比べて、若干depthaiのバージョンが新しくなっている。

前回作ったdepthai環境で、アップデートしてみることにする。

cd .\depthai_hand_tracker\
pip install -r .\requirements.txt
(depthai) PS C:\work\oak-d_test> cd .\depthai_hand_tracker\
(depthai) PS C:\work\oak-d_test\depthai_hand_tracker> pip install -r .\requirements.txt
Requirement already satisfied: opencv-python>=4.5.1.48 in c:\users\a\.conda\envs\depthai\lib\site-packages (from -r .\requirements.txt (line 1)) (4.5.1.48)
Collecting depthai>=2.13 (from -r .\requirements.txt (line 2))
  Downloading depthai-2.25.0.0-cp38-cp38-win_amd64.whl.metadata (9.0 kB)
Requirement already satisfied: numpy>=1.17.3 in c:\users\a\.conda\envs\depthai\lib\site-packages (from opencv-python>=4.5.1.48->-r .\requirements.txt (line 1)) (1.24.4)
Downloading depthai-2.25.0.0-cp38-cp38-win_amd64.whl (10.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.6/10.6 MB 8.6 MB/s eta 0:00:00
Installing collected packages: depthai
  Attempting uninstall: depthai
    Found existing installation: depthai 2.11.1.1
    Uninstalling depthai-2.11.1.1:
      Successfully uninstalled depthai-2.11.1.1
Successfully installed depthai-2.25.0.0
(depthai) PS C:\work\oak-d_test\depthai_hand_tracker> 

大丈夫だった。

実行

ひとまず何もオプションなしで。

python demo.py
(depthai) PS C:\work\oak-d_test\depthai_hand_tracker> python demo.py
Palm detection blob : C:\work\oak-d_test\depthai_hand_tracker\models\palm_detection_sh4.blob
Landmark blob       : C:\work\oak-d_test\depthai_hand_tracker\models\hand_landmark_lite_sh4.blob
Internal camera FPS set to: 23
Sensor resolution: (1920, 1080)
Internal camera image size: 1152 x 648 - crop_w:0 pad_h: 252
896 anchors have been created
Creating pipeline...
Creating Color Camera...
Creating Palm Detection Neural Network...
Creating Hand Landmark Neural Network (2 threads)...
Pipeline created.
[19443010819FF41200] [2.6] [1.057] [NeuralNetwork(4)] [warning] Network compiled for 4 shaves, maximum available 13, compiling for 6 shaves likely will yield in better performance
Pipeline started - USB speed: SUPER
[19443010819FF41200] [2.6] [1.058] [NeuralNetwork(6)] [warning] Network compiled for 4 shaves, maximum available 13, compiling for 6 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [1.067] [NeuralNetwork(4)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
[19443010819FF41200] [2.6] [1.067] [NeuralNetwork(6)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
FPS : 22.3 f/s (# frames = 3149)
# frames w/ no hand           : 1333 (42.3%)
# frames w/ palm detection    : 1726 (54.8%)
# frames w/ landmark inference : 1816 (57.7%)- # after palm detection: 393 - # after landmarks ROI prediction: 1423 
On frames with at least one landmark inference, average number of landmarks inferences/frame: 1.00
# lm inferences: 1816 - # failed lm inferences: 238 (13.1%)
(depthai) PS C:\work\oak-d_test\depthai_hand_tracker> 

動いた。画像ウィンドウが出て、手の認識がされている。'q'キーを押したら終了する。

が、失敗することもあった。カメラのコネクタ根元をちょっといじって接続がおかしくなったときかな。

(depthai) PS C:\work\oak-d_test\depthai_hand_tracker> python demo.py
Palm detection blob : C:\work\oak-d_test\depthai_hand_tracker\models\palm_detection_sh4.blob
Landmark blob       : C:\work\oak-d_test\depthai_hand_tracker\models\hand_landmark_lite_sh4.blob
Internal camera FPS set to: 23
Sensor resolution: (1920, 1080)
Internal camera image size: 1152 x 648 - crop_w:0 pad_h: 252
896 anchors have been created
Creating pipeline...
Creating Color Camera...
Creating Palm Detection Neural Network...
Creating Hand Landmark Neural Network (2 threads)...
Pipeline created.
[19443010819FF41200] [2.6] [1.769] [NeuralNetwork(4)] [warning] Network compiled for 4 shaves, maximum available 13, compiling for 6 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [1.770] [NeuralNetwork(6)] [warning] Network compiled for 4 shaves, maximum available 13, compiling for 6 shaves likely will yield in better performance
Pipeline started - USB speed: HIGH
[19443010819FF41200] [2.6] [1.780] [NeuralNetwork(4)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
[19443010819FF41200] [2.6] [1.780] [NeuralNetwork(6)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
Traceback (most recent call last):
  File "demo.py", line 85, in <module>
    frame, hands, bag = tracker.next_frame()
  File "C:\work\oak-d_test\depthai_hand_tracker\HandTracker.py", line 558, in next_frame
    inference = self.q_lm_out.get()
RuntimeError: Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: 'lm_out' (X_LINK_ERROR)'
Stack trace (most recent call last):
#31   Object "", at 00007FFAE5C4B53B, in PyModule_ClearDict
#30   Object "", at 00007FFAE5C16B4B, in PyDict_Pop
#29   Object "", at 00007FFAE5C672E0, in PyType_GenericNew
#28   Object "", at 00007FFAE5C16A06, in PyDict_Pop
#27   Object "", at 00007FFAE5C672E0, in PyType_GenericNew
#26   Object "", at 00007FFAE5C16A06, in PyDict_Pop
#25   Object "", at 00007FFAC7AD7EE2, in pybind11::error_already_set::error_already_set
#24   Object "", at 00007FFAC7AD7DEE, in pybind11::error_already_set::error_already_set
#23   Object "", at 00007FFAC7B1B2B9, in PyInit_depthai
#22   Object "", at 00007FFAC7B2A554, in PyInit_depthai
#21   Object "", at 00007FFAC7D73DFC, in PyInit_depthai
#20   Object "", at 00007FFAC7D5365B, in PyInit_depthai
#19   Object "", at 00007FFAC7D74F30, in PyInit_depthai
#18   Object "", at 00007FFAC7D54157, in PyInit_depthai
#17   Object "", at 00007FFAC7D6468D, in PyInit_depthai
#16   Object "", at 00007FFAC7D3899E, in PyInit_depthai
#15   Object "", at 00007FFAC7D38CDB, in PyInit_depthai
#14   Object "", at 00007FFAC7D51DB1, in PyInit_depthai
#13   Object "", at 00007FFAC7D503AF, in PyInit_depthai
#12   Object "", at 00007FFB6FC33C66, in RtlCaptureContext2
#11   Object "", at 00007FFAC7E76CC5, in PyInit_depthai
#10   Object "", at 00007FFAC7E7FDB0, in PyInit_depthai
#9    Object "", at 00007FFAC7EB6A44, in PyInit_depthai
#8    Object "", at 00007FFAC7E741C3, in PyInit_depthai
#7    Object "", at 00007FFB6D2D5B0C, in RaiseException
#6    Object "", at 00007FFB6FBE4475, in RtlRaiseException
#5    Object "", at 00007FFB6FBAE466, in RtlFindCharInUnicodeString
#4    Object "", at 00007FFB6FC3441F, in _chkstk
#3    Object "", at 00007FFAC7E73529, in PyInit_depthai
#2    Object "", at 00007FFAC7E76845, in PyInit_depthai
#1    Object "", at 00007FFAC7E767E0, in PyInit_depthai
#0    Object "", at 00007FFAC7E75B42, in PyInit_depthai

こんなエラーも出た。実行時、カメラからカチカチ音が出て、動こうとしていたが、結局ダメだった感じ。

(depthai) PS C:\work\oak-d_test\depthai_hand_tracker> python demo.py
Palm detection blob : C:\work\oak-d_test\depthai_hand_tracker\models\palm_detection_sh4.blob
Landmark blob       : C:\work\oak-d_test\depthai_hand_tracker\models\hand_landmark_lite_sh4.blob
[19443010819FF41200] [2.6] [1711058217.082] [host] [warning] Device crashed, but no crash dump could be extracted.
Traceback (most recent call last):
  File "demo.py", line 59, in <module>
    tracker = HandTracker(
  File "C:\work\oak-d_test\depthai_hand_tracker\HandTracker.py", line 130, in __init__
    self.device = dai.Device()
RuntimeError: Device already closed or disconnected: io error

動画保存オプション

-o (動画ファイル名)で保存できるとのこと。試してみた。

python demo.py -o out.mp4
(depthai) PS C:\work\oak-d_test\depthai_hand_tracker> python demo.py -o out.mp4
Palm detection blob : C:\work\oak-d_test\depthai_hand_tracker\models\palm_detection_sh4.blob
Landmark blob       : C:\work\oak-d_test\depthai_hand_tracker\models\hand_landmark_lite_sh4.blob
Internal camera FPS set to: 23
Sensor resolution: (1920, 1080)
Internal camera image size: 1152 x 648 - crop_w:0 pad_h: 252
896 anchors have been created
Creating pipeline...
Creating Color Camera...
Creating Palm Detection Neural Network...
Creating Hand Landmark Neural Network (2 threads)...
Pipeline created.
[19443010819FF41200] [2.6] [1.138] [NeuralNetwork(4)] [warning] Network compiled for 4 shaves, maximum available 13, compiling for 6 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [1.139] [NeuralNetwork(6)] [Pipeline started - USB speed: SUPER
warning] Network compiled for 4 shaves, maximum available 13, compiling for 6 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [1.148] [NeuralNetwork(4)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
[19443010819FF41200] [2.6] [1.148] [NeuralNetwork(6)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 7 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
FPS : 19.7 f/s (# frames = 269)
# frames w/ no hand           : 21 (7.8%)
# frames w/ palm detection    : 49 (18.2%)
# frames w/ landmark inference : 248 (92.2%)- # after palm detection: 28 - # after landmarks ROI prediction: 220    
On frames with at least one landmark inference, average number of landmarks inferences/frame: 1.00
# lm inferences: 249 - # failed lm inferences: 5 (2.0%)

とりあえず拡張子.mp4にしてみたが、うまくいかなかった。ファイルはできていたが、再生したら真っ黒画像だった。

拡張子.aviにしたらいけた。

python demo.py -o out.avi
(depthai) PS C:\work\oak-d_test\depthai_hand_tracker> python demo.py -o out.avi
Palm detection blob : C:\work\oak-d_test\depthai_hand_tracker\models\palm_detection_sh4.blob
Landmark blob       : C:\work\oak-d_test\depthai_hand_tracker\models\hand_landmark_lite_sh4.blob
Internal camera FPS set to: 23
Sensor resolution: (1920, 1080)
Internal camera image size: 1152 x 648 - crop_w:0 pad_h: 252
896 anchors have been created
Creating pipeline...
Creating Color Camera...
Creating Palm Detection Neural Network...
Creating Hand Landmark Neural Network (2 threads)...
Pipeline created.
[19443010819FF41200] [2.6] [0.956] [NeuralNetwork(4)] [warning] Network compiled for 4 shaves, maximum available 13, compiling for 6 shaves likely will yield in better performance
Pipeline started - USB speed: SUPER
[19443010819FF41200] [2.6] [0.957] [NeuralNetwork(6)] [warning] Network compiled for 4 shaves, maximum available 13, compiling for 6 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [0.967] [NeuralNetwork(4)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
[19443010819FF41200] [2.6] [0.967] [NeuralNetwork(6)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary
FPS : 20.3 f/s (# frames = 337)
# frames w/ no hand           : 18 (5.3%)
# frames w/ palm detection    : 52 (15.4%)
# frames w/ landmark inference : 319 (94.7%)- # after palm detection: 34 - # after landmarks ROI prediction: 285    
On frames with at least one landmark inference, average number of landmarks inferences/frame: 1.00
# lm inferences: 320 - # failed lm inferences: 4 (1.2%)

3次元位置オプション

-xyzを付けると、手首の位置の3次元座標が出るよう。

python demo.py -o out_xyz.avi -xyz
(depthai) PS C:\work\oak-d_test\depthai_hand_tracker> python demo.py -o out_xyz.avi -xyz
Palm detection blob : C:\work\oak-d_test\depthai_hand_tracker\models\palm_detection_sh4.blob
Landmark blob       : C:\work\oak-d_test\depthai_hand_tracker\models\hand_landmark_lite_sh4.blob
Internal camera FPS set to: 23
Sensor resolution: (1920, 1080)
Internal camera image size: 1152 x 648 - crop_w:0 pad_h: 252
896 anchors have been created
Creating pipeline...
Creating Color Camera...
Creating MonoCameras, Stereo and SpatialLocationCalculator nodes...
RGB calibration lens position: 131
Creating Palm Detection Neural Network...
Creating Hand Landmark Neural Network (2 threads)...
Pipeline created.
[19443010819FF41200] [2.6] [1.367] [NeuralNetwork(10)] [warning] Network compiled for 4 shaves, maximum available 12, compiling for 6 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [1.369] [NeuralNetwork(12)] [warning] Network compiled for 4 shaves, maximum available 12, compiling for 6 shaves likely will yield in better performance
[19443010819FF41200] [2.6] [1.384] [NeuralNetwork(10)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary        
Pipeline started - USB speed: SUPER
[19443010819FF41200] [2.6] [1.385] [NeuralNetwork(12)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary        
FPS : 16.4 f/s (# frames = 300)
# frames w/ no hand           : 7 (2.3%)
# frames w/ palm detection    : 51 (17.0%)
# frames w/ landmark inference : 293 (97.7%)- # after palm detection: 44 - # after landmarks ROI prediction: 249    
On frames with at least one landmark inference, average number of landmarks inferences/frame: 1.00
# lm inferences: 293 - # failed lm inferences: 17 (5.8%)
Spatial location requests round trip : 5.2 ms

少しフレームレートが下がっているが、手首の位置の座標が出ている。

ここまで

次は、これをもう少しいじってみるか、ほかのサンプルを動かしてみるか。

OAK-D S2進める - HelloWorld

OAK-D S2の続き。

Hello World

公式ドキュメントを見ると、デモアプリを動かしてみた次のステップとして、HelloWorldプロジェクトでコーディングしてみよう、というのがある。

Hello World — DepthAI documentation | Luxonis

コーディングのしかたは、読んでみて、そういう感じかー、と。

これを実行してみた。

GitHubリポジトリクローン

リポジトリはここにあるので、これをクローンする。

github.com

git clone https://github.com/luxonis/depthai-tutorials/ c:\work\oak-d_test\depthai-tutorial

こんな感じのディレクトリ構造。

この中のhello-worldのほうを動かしてみる。

環境作成

Anacondaで新規作成。
Pythonバージョンは3.10にしておく。適当。

conda create -n depthai python=3.10
conda activate depthai

必要なパッケージのインストール。

pip install -r .\1-hello-world\requirements.txt

↓ 結果 (途中まで)

(depthai) PS C:\work\oak-d_test\depthai-tutorials> pip install -r .\1-hello-world\requirements.txt
Collecting opencv-python==4.5.1.48 (from -r .\1-hello-world\requirements.txt (line 1))
  Downloading opencv-python-4.5.1.48.tar.gz (88.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 88.3/88.3 MB 46.9 MB/s eta 0:00:00
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [315 lines of output]
      Ignoring numpy: markers 'python_version == "3.6" and platform_machine != "aarch64"' don't match your environment
      Ignoring numpy: markers 'python_version >= "3.6" and sys_platform == "linux" and platform_machine == "aarch64"' don't match your environment
      Ignoring numpy: markers 'python_version == "3.7" and platform_machine != "aarch64"' don't match your environment
      Ignoring numpy: markers 'python_version == "3.8" and platform_machine != "aarch64"' don't match your environment

...

クリックで全結果開く

(depthai) PS C:\work\oak-d_test\depthai-tutorials> pip install -r .\1-hello-world\requirements.txt
Collecting opencv-python==4.5.1.48 (from -r .\1-hello-world\requirements.txt (line 1))
  Downloading opencv-python-4.5.1.48.tar.gz (88.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 88.3/88.3 MB 46.9 MB/s eta 0:00:00
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [315 lines of output]
      Ignoring numpy: markers 'python_version == "3.6" and platform_machine != "aarch64"' don't match your environment
      Ignoring numpy: markers 'python_version >= "3.6" and sys_platform == "linux" and platform_machine == "aarch64"' don't match your environment
      Ignoring numpy: markers 'python_version == "3.7" and platform_machine != "aarch64"' don't match your environment
      Ignoring numpy: markers 'python_version == "3.8" and platform_machine != "aarch64"' don't match your environment
      Collecting setuptools
        Downloading setuptools-69.2.0-py3-none-any.whl.metadata (6.3 kB)
      Collecting wheel
        Downloading wheel-0.43.0-py3-none-any.whl.metadata (2.2 kB)
      Collecting scikit-build
        Downloading scikit_build-0.17.6-py3-none-any.whl.metadata (14 kB)
      Collecting cmake
        Downloading cmake-3.28.3-py2.py3-none-win_amd64.whl.metadata (6.5 kB)
      Collecting pip
        Downloading pip-24.0-py3-none-any.whl.metadata (3.6 kB)
      Collecting numpy==1.19.3
        Downloading numpy-1.19.3.zip (7.3 MB)
           ---------------------------------------- 7.3/7.3 MB 46.5 MB/s eta 0:00:00
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'done'
        Preparing metadata (pyproject.toml): started
        Preparing metadata (pyproject.toml): finished with status 'error'
        error: subprocess-exited-with-error

        Preparing metadata (pyproject.toml) did not run successfully.
        exit code: 1

        [275 lines of output]
        setup.py:67: RuntimeWarning: NumPy 1.19.3 may not yet support Python 3.10.
          warnings.warn(
        Running from numpy source directory.
        setup.py:480: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
          run_build = parse_setuppy_commands()
        Processing numpy/random\_bounded_integers.pxd.in
        Processing numpy/random\bit_generator.pyx
        Processing numpy/random\mtrand.pyx
        Processing numpy/random\_bounded_integers.pyx.in
        Processing numpy/random\_common.pyx
        Processing numpy/random\_generator.pyx
        Processing numpy/random\_mt19937.pyx
        Processing numpy/random\_pcg64.pyx
        Processing numpy/random\_philox.pyx
        Processing numpy/random\_sfc64.pyx
        Cythonizing sources
        blas_opt_info:
        blas_mkl_info:
        No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
        customize MSVCCompiler
          libraries mkl_rt not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
          NOT AVAILABLE

        blis_info:
          libraries blis not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
          NOT AVAILABLE

        openblas_info:
          libraries openblas not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
        get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
        customize GnuFCompiler
        Could not locate executable g77
        Could not locate executable f77
        customize IntelVisualFCompiler
        Could not locate executable ifort
        Could not locate executable ifl
        customize AbsoftFCompiler
        Could not locate executable f90
        customize CompaqVisualFCompiler
        Could not locate executable DF
        customize IntelItaniumVisualFCompiler
        Could not locate executable efl
        customize Gnu95FCompiler
        Could not locate executable gfortran
        Could not locate executable f95
        customize G95FCompiler
        Could not locate executable g95
        customize IntelEM64VisualFCompiler
        customize IntelEM64TFCompiler
        Could not locate executable efort
        Could not locate executable efc
        customize PGroupFlangCompiler
        Could not locate executable flang
        don't know how to compile Fortran code on platform 'nt'
          NOT AVAILABLE

        atlas_3_10_blas_threads_info:
        Setting PTATLAS=ATLAS
          libraries tatlas not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
          NOT AVAILABLE

        atlas_3_10_blas_info:
          libraries satlas not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
          NOT AVAILABLE

        atlas_blas_threads_info:
        Setting PTATLAS=ATLAS
          libraries ptf77blas,ptcblas,atlas not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
          NOT AVAILABLE

        atlas_blas_info:
          libraries f77blas,cblas,atlas not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
          NOT AVAILABLE

        accelerate_info:
          NOT AVAILABLE

        C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\system_info.py:1914: UserWarning:
            Optimized (vendor) Blas libraries are not found.
            Falls back to netlib Blas library which has worse performance.
            A better performance should be easily gained by switching
            Blas library.
          if self._calc_info(blas):
        blas_info:
          libraries blas not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
          NOT AVAILABLE

        C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\system_info.py:1914: UserWarning:
            Blas (http://www.netlib.org/blas/) libraries not found.
            Directories to search for the libraries can be specified in the
            numpy/distutils/site.cfg file (section [blas]) or by setting
            the BLAS environment variable.
          if self._calc_info(blas):
        blas_src_info:
          NOT AVAILABLE

        C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\system_info.py:1914: UserWarning:
            Blas (http://www.netlib.org/blas/) sources not found.
            Directories to search for the sources can be specified in the
            numpy/distutils/site.cfg file (section [blas_src]) or by setting
            the BLAS_SRC environment variable.
          if self._calc_info(blas):
          NOT AVAILABLE

        non-existing path in 'numpy\\distutils': 'site.cfg'
        lapack_opt_info:
        lapack_mkl_info:
          libraries mkl_rt not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
          NOT AVAILABLE

        openblas_lapack_info:
          libraries openblas not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
          NOT AVAILABLE

        openblas_clapack_info:
          libraries openblas,lapack not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
          NOT AVAILABLE

        flame_info:
          libraries flame not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
          NOT AVAILABLE

        atlas_3_10_threads_info:
        Setting PTATLAS=ATLAS
          libraries lapack_atlas not found in C:\Users\a\.conda\envs\depthai\lib
          libraries tatlas,tatlas not found in C:\Users\a\.conda\envs\depthai\lib
          libraries lapack_atlas not found in C:\
          libraries tatlas,tatlas not found in C:\
          libraries lapack_atlas not found in C:\Users\a\.conda\envs\depthai\libs
          libraries tatlas,tatlas not found in C:\Users\a\.conda\envs\depthai\libs
          libraries lapack_atlas not found in C:\ProgramData\anaconda3\Library\lib
          libraries tatlas,tatlas not found in C:\ProgramData\anaconda3\Library\lib
        <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
          NOT AVAILABLE

        atlas_3_10_info:
          libraries lapack_atlas not found in C:\Users\a\.conda\envs\depthai\lib
          libraries satlas,satlas not found in C:\Users\a\.conda\envs\depthai\lib
          libraries lapack_atlas not found in C:\
          libraries satlas,satlas not found in C:\
          libraries lapack_atlas not found in C:\Users\a\.conda\envs\depthai\libs
          libraries satlas,satlas not found in C:\Users\a\.conda\envs\depthai\libs
          libraries lapack_atlas not found in C:\ProgramData\anaconda3\Library\lib
          libraries satlas,satlas not found in C:\ProgramData\anaconda3\Library\lib
        <class 'numpy.distutils.system_info.atlas_3_10_info'>
          NOT AVAILABLE

        atlas_threads_info:
        Setting PTATLAS=ATLAS
          libraries lapack_atlas not found in C:\Users\a\.conda\envs\depthai\lib
          libraries ptf77blas,ptcblas,atlas not found in C:\Users\a\.conda\envs\depthai\lib
          libraries lapack_atlas not found in C:\
          libraries ptf77blas,ptcblas,atlas not found in C:\
          libraries lapack_atlas not found in C:\Users\a\.conda\envs\depthai\libs
          libraries ptf77blas,ptcblas,atlas not found in C:\Users\a\.conda\envs\depthai\libs
          libraries lapack_atlas not found in C:\ProgramData\anaconda3\Library\lib
          libraries ptf77blas,ptcblas,atlas not found in C:\ProgramData\anaconda3\Library\lib
        <class 'numpy.distutils.system_info.atlas_threads_info'>
          NOT AVAILABLE

        atlas_info:
          libraries lapack_atlas not found in C:\Users\a\.conda\envs\depthai\lib
          libraries f77blas,cblas,atlas not found in C:\Users\a\.conda\envs\depthai\lib
          libraries lapack_atlas not found in C:\
          libraries f77blas,cblas,atlas not found in C:\
          libraries lapack_atlas not found in C:\Users\a\.conda\envs\depthai\libs
          libraries f77blas,cblas,atlas not found in C:\Users\a\.conda\envs\depthai\libs
          libraries lapack_atlas not found in C:\ProgramData\anaconda3\Library\lib
          libraries f77blas,cblas,atlas not found in C:\ProgramData\anaconda3\Library\lib
        <class 'numpy.distutils.system_info.atlas_info'>
          NOT AVAILABLE

        lapack_info:
          libraries lapack not found in ['C:\\Users\\a\\.conda\\envs\\depthai\\lib', 'C:\\', 'C:\\Users\\a\\.conda\\envs\\depthai\\libs', 'C:\\ProgramData\\anaconda3\\Library\\lib']
          NOT AVAILABLE

        C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\system_info.py:1748: UserWarning:
            Lapack (http://www.netlib.org/lapack/) libraries not found.
            Directories to search for the libraries can be specified in the
            numpy/distutils/site.cfg file (section [lapack]) or by setting
            the LAPACK environment variable.
          return getattr(self, '_calc_info_{}'.format(name))()
        lapack_src_info:
          NOT AVAILABLE

        C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\system_info.py:1748: UserWarning:
            Lapack (http://www.netlib.org/lapack/) sources not found.
            Directories to search for the sources can be specified in the
            numpy/distutils/site.cfg file (section [lapack_src]) or by setting
            the LAPACK_SRC environment variable.
          return getattr(self, '_calc_info_{}'.format(name))()
          NOT AVAILABLE

        numpy_linalg_lapack_lite:
          FOUND:
            language = c
            define_macros = [('HAVE_BLAS_ILP64', None), ('BLAS_SYMBOL_SUFFIX', '64_')]

        C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\_distutils\dist.py:275: UserWarning: Unknown distribution option: 'define_macros'
          warnings.warn(msg)
        running dist_info
        running build_src
        build_src
        building py_modules sources
        creating build
        creating build\src.win-amd64-3.10
        creating build\src.win-amd64-3.10\numpy
        creating build\src.win-amd64-3.10\numpy\distutils
        building library "npymath" sources
        Traceback (most recent call last):
          File "C:\Users\a\.conda\envs\depthai\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
            main()
          File "C:\Users\a\.conda\envs\depthai\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
            json_out['return_val'] = hook(**hook_input['kwargs'])
          File "C:\Users\a\.conda\envs\depthai\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 149, in prepare_metadata_for_build_wheel
            return hook(metadata_directory, config_settings)
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\build_meta.py", line 157, in prepare_metadata_for_build_wheel
            self.run_setup()
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\build_meta.py", line 248, in run_setup
            super(_BuildMetaLegacyBackend,
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\build_meta.py", line 142, in run_setup
            exec(compile(code, __file__, 'exec'), locals())
          File "setup.py", line 508, in <module>
            setup_package()
          File "setup.py", line 500, in setup_package
            setup(**metadata)
          File "C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\core.py", line 169, in setup
            return old_setup(**new_attr)
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\__init__.py", line 165, in setup
            return distutils.core.setup(**attrs)
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
            dist.run_commands()
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
            self.run_command(cmd)
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
            cmd_obj.run()
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\command\dist_info.py", line 31, in run
            egg_info.run()
          File "C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\command\egg_info.py", line 24, in run
            self.run_command("build_src")
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
            self.distribution.run_command(command)
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
            cmd_obj.run()
          File "C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\command\build_src.py", line 144, in run
            self.build_sources()
          File "C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\command\build_src.py", line 155, in build_sources
            self.build_library_sources(*libname_info)
          File "C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\command\build_src.py", line 288, in build_library_sources
            sources = self.generate_sources(sources, (lib_name, build_info))
          File "C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\command\build_src.py", line 378, in generate_sources
            source = func(extension, build_dir)
          File "numpy\core\setup.py", line 658, in get_mathlib_info
            st = config_cmd.try_link('int main(void) { return 0;}')
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 243, in try_link
            self._link(body, headers, include_dirs,
          File "C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\command\config.py", line 162, in _link
            return self._wrap_method(old_config._link, lang,
          File "C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\command\config.py", line 96, in _wrap_method
            ret = mth(*((self,)+args))
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 137, in _link
            (src, obj) = self._compile(body, headers, include_dirs, lang)
          File "C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\command\config.py", line 105, in _compile
            src, obj = self._wrap_method(old_config._compile, lang,
          File "C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\command\config.py", line 96, in _wrap_method
            ret = mth(*((self,)+args))
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 132, in _compile
            self.compiler.compile([src], include_dirs=include_dirs)
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 401, in compile
            self.spawn(args)
          File "C:\Users\a\AppData\Local\Temp\pip-build-env-1ex9rkmn\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 505, in spawn
            return super().spawn(cmd, env=env)
          File "C:\Users\a\AppData\Local\Temp\pip-install-qj0t3ans\numpy_f5584457dc114a31b81d23044f8a008d\numpy\distutils\ccompiler.py", line 90, in <lambda>
            m = lambda self, *args, **kw: func(self, *args, **kw)
        TypeError: CCompiler_spawn() got an unexpected keyword argument 'env'
        [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
      error: metadata-generation-failed

      Encountered error while generating package metadata.

      See above for output.

      note: This is an issue with the package mentioned above, not pip.
      hint: See above for details.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
(depthai) PS C:\work\oak-d_test\depthai-tutorials>     

ということで、Python 3.10だとだめそう。

環境作り直しで、Python3.8でやり直してみる。

conda deactivate
conda remove -n depthai --all
conda create -n depthai python=3.8
conda activate depthai
pip install -r .\1-hello-world\requirements.txt

↓ 結果(一部)

(depthai) PS C:\work\oak-d_test\depthai-tutorials> pip install -r .\1-hello-world\requirements.txt
Collecting opencv-python==4.5.1.48 (from -r .\1-hello-world\requirements.txt (line 1))
  Downloading opencv_python-4.5.1.48-cp38-cp38-win_amd64.whl.metadata (17 kB)
Collecting depthai==2.11.1.1 (from -r .\1-hello-world\requirements.txt (line 2))
  Downloading depthai-2.11.1.1-cp38-cp38-win_amd64.whl.metadata (8.6 kB)
Collecting blobconverter==1.2.6 (from -r .\1-hello-world\requirements.txt (line 3))
  Downloading blobconverter-1.2.6-py3-none-any.whl.metadata (7.3 kB)
Collecting numpy>=1.17.3 (from opencv-python==4.5.1.48->-r .\1-hello-world\requirements.txt (line 1))
  Downloading numpy-1.24.4-cp38-cp38-win_amd64.whl.metadata (5.6 kB)

...

Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 kB ? eta 0:00:00
Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 229.9/229.9 kB ? eta 0:00:00
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: urllib3, six, PyYAML, numpy, jmespath, idna, depthai, charset-normalizer, certifi, requests, python-dateutil, opencv-python, botocore, s3transfer, boto3, blobconverter
Successfully installed PyYAML-6.0.1 blobconverter-1.2.6 boto3-1.34.64 botocore-1.34.64 certifi-2024.2.2 charset-normalizer-3.3.2 depthai-2.11.1.1 idna-3.6 jmespath-1.0.1 numpy-1.24.4 opencv-python-4.5.1.48 python-dateutil-2.9.0.post0 requests-2.31.0 s3transfer-0.10.1 six-1.16.0 urllib3-1.26.18
(depthai) PS C:\work\oak-d_test\depthai-tutorials> 

クリックで全部開く

(depthai) PS C:\work\oak-d_test\depthai-tutorials> pip install -r .\1-hello-world\requirements.txt
Collecting opencv-python==4.5.1.48 (from -r .\1-hello-world\requirements.txt (line 1))
  Downloading opencv_python-4.5.1.48-cp38-cp38-win_amd64.whl.metadata (17 kB)
Collecting depthai==2.11.1.1 (from -r .\1-hello-world\requirements.txt (line 2))
  Downloading depthai-2.11.1.1-cp38-cp38-win_amd64.whl.metadata (8.6 kB)
Collecting blobconverter==1.2.6 (from -r .\1-hello-world\requirements.txt (line 3))
  Downloading blobconverter-1.2.6-py3-none-any.whl.metadata (7.3 kB)
Collecting numpy>=1.17.3 (from opencv-python==4.5.1.48->-r .\1-hello-world\requirements.txt (line 1))
  Downloading numpy-1.24.4-cp38-cp38-win_amd64.whl.metadata (5.6 kB)
Collecting requests (from blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting PyYAML (from blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Downloading PyYAML-6.0.1-cp38-cp38-win_amd64.whl.metadata (2.1 kB)
Collecting boto3 (from blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Downloading boto3-1.34.64-py3-none-any.whl.metadata (6.6 kB)
Collecting botocore<1.35.0,>=1.34.64 (from boto3->blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Downloading botocore-1.34.64-py3-none-any.whl.metadata (5.7 kB)
Collecting jmespath<2.0.0,>=0.7.1 (from boto3->blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Downloading jmespath-1.0.1-py3-none-any.whl.metadata (7.6 kB)
Collecting s3transfer<0.11.0,>=0.10.0 (from boto3->blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Downloading s3transfer-0.10.1-py3-none-any.whl.metadata (1.7 kB)
Collecting charset-normalizer<4,>=2 (from requests->blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Downloading charset_normalizer-3.3.2-cp38-cp38-win_amd64.whl.metadata (34 kB)
Collecting idna<4,>=2.5 (from requests->blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Using cached idna-3.6-py3-none-any.whl.metadata (9.9 kB)
Collecting urllib3<3,>=1.21.1 (from requests->blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Downloading urllib3-2.2.1-py3-none-any.whl.metadata (6.4 kB)
Collecting certifi>=2017.4.17 (from requests->blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Downloading certifi-2024.2.2-py3-none-any.whl.metadata (2.2 kB)
Collecting python-dateutil<3.0.0,>=2.1 (from botocore<1.35.0,>=1.34.64->boto3->blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
Collecting urllib3<3,>=1.21.1 (from requests->blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Downloading urllib3-1.26.18-py2.py3-none-any.whl.metadata (48 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 2.4 MB/s eta 0:00:00
Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1->botocore<1.35.0,>=1.34.64->boto3->blobconverter==1.2.6->-r .\1-hello-world\requirements.txt (line 3))
  Downloading six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Downloading opencv_python-4.5.1.48-cp38-cp38-win_amd64.whl (34.9 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 34.9/34.9 MB 34.4 MB/s eta 0:00:00
Downloading depthai-2.11.1.1-cp38-cp38-win_amd64.whl (8.7 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.7/8.7 MB 78.6 MB/s eta 0:00:00
Downloading blobconverter-1.2.6-py3-none-any.whl (10 kB)
Downloading numpy-1.24.4-cp38-cp38-win_amd64.whl (14.9 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.9/14.9 MB 65.6 MB/s eta 0:00:00
Downloading boto3-1.34.64-py3-none-any.whl (139 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 139.3/139.3 kB ? eta 0:00:00
Downloading PyYAML-6.0.1-cp38-cp38-win_amd64.whl (157 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 157.3/157.3 kB ? eta 0:00:00
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Downloading botocore-1.34.64-py3-none-any.whl (12.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.0/12.0 MB 81.8 MB/s eta 0:00:00
Downloading certifi-2024.2.2-py3-none-any.whl (163 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 163.8/163.8 kB ? eta 0:00:00
Downloading charset_normalizer-3.3.2-cp38-cp38-win_amd64.whl (99 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 99.6/99.6 kB ? eta 0:00:00
Using cached idna-3.6-py3-none-any.whl (61 kB)
Downloading jmespath-1.0.1-py3-none-any.whl (20 kB)
Downloading s3transfer-0.10.1-py3-none-any.whl (82 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 82.2/82.2 kB 4.5 MB/s eta 0:00:00
Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 kB ? eta 0:00:00
Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 229.9/229.9 kB ? eta 0:00:00
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: urllib3, six, PyYAML, numpy, jmespath, idna, depthai, charset-normalizer, certifi, requests, python-dateutil, opencv-python, botocore, s3transfer, boto3, blobconverter
Successfully installed PyYAML-6.0.1 blobconverter-1.2.6 boto3-1.34.64 botocore-1.34.64 certifi-2024.2.2 charset-normalizer-3.3.2 depthai-2.11.1.1 idna-3.6 jmespath-1.0.1 numpy-1.24.4 opencv-python-4.5.1.48 python-dateutil-2.9.0.post0 requests-2.31.0 s3transfer-0.10.1 six-1.16.0 urllib3-1.26.18
(depthai) PS C:\work\oak-d_test\depthai-tutorials> 

今度は大丈夫だった。

実行

python 1-hello-world/hello_world.py

ちゃんと動いた。

ここまで

サンプルコードを動かしただけだが、PythonからOAK-Dを扱える環境ができた、という意味はあるか。

次は手の認識をするサンプルがあるので、それをやってみる。

OAD-D S2進める - USBケーブル

去年の10月に買ってから全然進んでいなかったので。
今回はUSBケーブルの件について。

nokixa.hatenablog.com

概要

OAK-D S2では7.5Wの電力が必要だったが、今使っているPCのUSB3.0 Type-Aポートでは供給不可能だったので、 Thunderboltのポート(コネクタ自体はType-C)に接続する必要があった。

それに使えそうなType-C - Type-Cのケーブルを去年の11月のブラックフライデーのとき、Amazonで購入した。

Amazon.co.jp: RAMPOW USB-C & USB-C ケーブル【100W PD対応/USB 3.2 Gen 2x2-20Gbpsデータ転送】PD3.0/QC3.0超高速充電 4K/60Hz 映像出力対応 超高耐久 type-cケーブル MacBook Pro/iPad Pro/Google Pixel/Galaxy等タイプC対応 在宅勤務/出張支援 ネイビー 2M : パソコン・周辺機器

外観

結構ごついケーブル

仕様

  • メーカーはRAMPOWという会社、中国のメーカーらしい
  • USB 3.2 Gen 2x2 20Gbps超高速データ転送
  • USB PDとQC 3.0 急速充電
    • 最大100WのPower Deliveryに対応
    • OAK-D S2の電力には十分
  • ナイロン素材使用
    • 引っ張りやねじれに強く、さらに絡まりにくさも兼ね備える
    • 20,000回以上の折り曲げ試験に合格
  • 長さは2mを購入 (1mもあり)
    • ピアノを弾いているところを撮影するのには、少し長さが必要そうなので
  • 径は実測で5mm

使ってみた

PCにこんな感じで接続。

デモアプリを動かした、問題なく動いてる。

と思ったが、一度アプリを落として再度立ち上げてみると、前と同じようなエラーが出てしまった。

何度かやり直しすれば動いたので、これで良しとしておく。
ハード的に問題あるのか?

ここまで

公式ドキュメントを読んだところ、HelloWorldと手の認識のサンプルがあってよさそうだったので、それをやってみる。

姿勢推定アルゴリズム調べ

姿勢推定に今までOpenPose、MediaPipe、YOLOv8を使ってきたが、他にも色々あるようなので整理してみる。
2024年2月現在調べたところで。
まだ調べ切れていないかも。

フリーで使えるもの(とは言えライセンスの制約あり)と、商用のものに分けてみる。
個人で使いたいので、後者はあんまり関心ないが、一応リストしておく。

フリーのもの

OpenPose

GitHub - CMU-Perceptual-Computing-Lab/openpose: OpenPose: Real-time multi-person keypoint detection library for body, face, hands, and foot estimation

OpenPose has represented the first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints (in total 135 keypoints) on single images.

使ってみたもの。

一番有名か?
ただ、2020年でGitHubの更新は止まっている。

exeと学習済みモデルが用意されているので、お試ししやすい。
試したところでは、処理が結構重かった。システムとして使えるようにするには課題あり。

AlphaPose

GitHub - MVIG-SJTU/AlphaPose: Real-Time and Accurate Full-Body Multi-Person Pose Estimation&Tracking System

AlphaPose is an accurate multi-person pose estimator, which is the first open-source system that achieves 70+ mAP (75 mAP) on COCO dataset and 80+ mAP (82.1 mAP) on MPII dataset.

上海交通大学のもの。
GitHubからすぐ使えるか。
学習済みモデル、推論用のスクリプトもあるよう。

去年までは更新されているので、まだアクティブと言ってもいいのか。
論文も2022年に出ているよう。

HRNet

HRNet · GitHub

HRNetの中でも、物体検出、顔特徴点検出などあるが、その中の一つとして姿勢推定があるよう。

GitHub - HRNet/HRNet-Human-Pose-Estimation: This repo is copied from https://github.com/leoxiaobin/deep-high-resolution-net.pytorch

In this work, we are interested in the human pose estimation problem with a focus on learning reliable high-resolution representations.

高解像度画像を使えるとかな感じ?

学習済みモデルもあるよう。

最終更新は5年前で、2019年6月、OpenPoseより古い…

GitHub - HRNet/HRNet-Bottom-Up-Pose-Estimation: This is an official pytorch implementation of “Bottom-Up Human Pose Estimation by Ranking Heatmap-Guided Adaptive Keypoint Estimates” (https://arxiv.org/abs/2006.15480).

In this work, We present several schemes that are rarely or unthoroughly studied before for improving keypoint detection and grouping (keypoint regression) performance.

こっちは最終更新2021年4月。

GitHub - HRNet/Lite-HRNet: This is an official pytorch implementation of Lite-HRNet: A Lightweight High-Resolution Network.

In this work, we present an efficient high-resolution network, Lite-HRNet, for human pose estimation.

これは軽め?実用に使えそう?
最終更新は上と同じく2021年4月。

YOLO

GitHub - ultralytics/yolov5: YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite

GitHub - ultralytics/ultralytics: NEW - YOLOv8 🚀 in PyTorch > ONNX > OpenVINO > CoreML > TFLite

とりあえず、現状YOLOv5とYOLOv8で姿勢推定できるのは確認している。
一番使いやすいと思う。

参考。

YOLOv8で姿勢推定する

nokixa.hatenablog.com

MediaPipe

MediaPipe  |  Google for Developers

Googleさんが整備してるから使いやすい。
コード書かなくても、ブラウザからお試しできるし。

ただ、スマホのインカメとか、Webカメラに特化してる気がするので、今の目当てにどこまで使えるか?

商用

VisionPose

姿勢推定AIエンジン「VisionPose(ビジョンポーズ)」| AIシステム開発の株式会社ネクストシステム

VisionPoseは、マーカーや深度センサなどを使わずにカメラ画像を使用して複数人の骨格を検出する高精度のAI姿勢推定エンジンです。
人体30キーポイントを最大60FPSでリアルタイムに検出可能※PCスペックで変動
2台のカメラで3D推論(Standard)と、1台のカメラで3D推論(Single3D)に対応

色々な企業で採用されているらしい。

AsillaPose

アジラ、施設向けAI警備システムに重要な姿勢推定AIで世界トップクラスの「AsillaPose®」シリーズ、最新版をリリース | 株式会社アジラのプレスリリース

株式会社アジラ(本社:東京都町田市、代表取締役:木村 大介、以下アジラ)は、自社プロダクト「施設向けAI警備システム」のコア技術である、姿勢推定AI「AsillaPose®」シリーズの最新版(Ver5.0)をリリースいたしました。

警備システムをやってる会社のものらしい。
怪しい行動の検出に特化してるとか?

「世界最高レベルの高い精度と速度を両立」と書いてあったりもした。

骨格検知アルゴリズム「AsillaPose」とは

Pose Proposal Network (PPN)

コニカミノルタ、複数人の2Dポーズをリアルタイムに高速検出する「Pose Proposal Networks(PPN)」を発表 | Seamless

コニカミノルタ株式会社の研究者は、複数人の2Dポーズをリアルタイムに検出する「Pose Proposal Networks(PPN)」を発表しました。

5分でわかる姿勢推定モデルと応用事例 - AI事業 - マクニカ

コニカミノルタのもの。2018年発表なので古め?
中でYOLO、OpenPoseを使ってるらしい。
論文がリンク切れになってる。

Actlyzer

行動分析技術 Actlyzer(アクトライザー) : 富士通

行動分析の技術だが、姿勢推定も含むのか?もしかしてそれは別?

以上

色々あるので、ピアノの手の動きをうまくとらえられるのはどれか?という観点で選んで試してみたい。

楽天証券状況

金曜から値動きし始めたばっかりだが、早速上がってる。嬉しい。

米国株式・・・5000円入れて+122円(+2.44%)
国内株式・・・2000円入れて+19円(+0.95%)

米国株式のほうがいい感じ?

まだ数日しか見てないからなんとも言えないか。