質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
OpenCV

OpenCV(オープンソースコンピュータービジョン)は、1999年にインテルが開発・公開したオープンソースのコンピュータビジョン向けのクロスプラットフォームライブラリです。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

1675閲覧

姿勢推定(head-pose-estimation)を試したい(OpenCV, Tensorflow)

ccchogeee

総合スコア11

OpenCV

OpenCV(オープンソースコンピュータービジョン)は、1999年にインテルが開発・公開したオープンソースのコンピュータビジョン向けのクロスプラットフォームライブラリです。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2020/04/20 02:09

編集2020/05/01 02:21

前提・実現したいこと

初心者です、ご助言でいただければと思います。

顔の姿勢推定をしてみたく、head-pose-estimationのコードを以下のgithubから落としてきました。
https://github.com/yinguobing/head-pose-estimation

しかし、以下のエラーが出て、うまく動かすことができません。
指定したビデオに対して、ビデオ内の人物の顔の向きを推定するプログラムです。

発生している問題・エラーメッセージ

$ python3 estimate_head_pose.py --video /Users/home/head-pose-estimation/video.MP4 OpenCV version: 3.3.1 2020-04-20 10:48:50.699505: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA WARNING:tensorflow:From /Users/tamada/head-pose-estimation_1/mark_detector.py:82: load (from tensorflow.python.saved_model.loader_impl) is deprecated and will be removed in a future version. Instructions for updating: This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.loader.load or tf.compat.v1.saved_model.load. There will be a new function for importing SavedModels in Tensorflow 2.0. WARNING:tensorflow:From /Users/home/.pyenv/versions/pose_estimation/lib/python3.5/site-packages/tensorflow/python/training/saver.py:1276: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version. Instructions for updating: Use standard file APIs to check for files with this prefix. objc[86085]: +[NSMutableString initialize] may have been in progress in another thread when fork() was called. objc[86085]: +[NSMutableString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

この状態から、ターミナルが動かなくなります。
control+cで中断すると、以下が出てきます。

^CTraceback (most recent call last): File "estimate_head_pose.py", line 161, in <module> main() File "estimate_head_pose.py", line 103, in main facebox = box_queue.get() File "/Users/home/.pyenv/versions/3.5.3/lib/python3.5/multiprocessing/queues.py", line 94, in get res = self._recv_bytes() File "/Users/home/.pyenv/versions/3.5.3/lib/python3.5/multiprocessing/connection.py", line 216, in recv_bytes buf = self._recv_bytes(maxlength) File "/Users/home/.pyenv/versions/3.5.3/lib/python3.5/multiprocessing/connection.py", line 407, in _recv_bytes buf = self._recv(4) File "/Users/home/.pyenv/versions/3.5.3/lib/python3.5/multiprocessing/connection.py", line 379, in _recv chunk = read(handle, remaining) KeyboardInterrupt

試したこと

最初は、tensorflowのバージョンが良くないのかと思いupdateしてみましたが、違うエラーが出てきてさらに混乱をしました。そこで、tensorflowのバージョンを戻し実行をしてみました。
load()の辺りに問題があるように感じるのですが、修正の方法を見つけることができませんでした。
進んでいるのか、そうでないのかもよくわかりません。

試したことその2

エラー中の

objc[86085]: +[NSMutableString initialize] may have been in progress in another thread when fork() was called.

の部分を検索してみると以下のようなサイトを見つけました↓
https://stackoverflow.com/questions/52671926/rails-may-have-been-in-progress-in-another-thread-when-fork-was-called

そこで、

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

の1行をbash_profileに追記し反映してみましたが、上に書いたものと全く同じエラーが出力されました。

補足情報(FW/ツールのバージョンなど)

githubのページ:https://github.com/yinguobing/head-pose-estimation
PC:macos 10.15.4
python:3.5.3
Tensorflow:1.14
opencv:3.3.1.11
numpy:1.16.4

githubのREADMEに書いてある環境となるべく合わせるようにしました。
osはubuntuではなくmacOSを使用しています。

試し切れていないことがまだまだ多くあると思います、、、

よろしくお願いします!!

また、他にうまく動かしやすい姿勢推定のプログラムがありましたら、教えていただけたらと思います!!!

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

全然動かすことができずにいたのですが、https://github.com/ildoonet/tf-pose-estimationのサイトを動かす際に作成した仮想環境内で実行したところ、動かすことができました!何のモジュールや設定が足りなかったのかもしれません。

以下は、https://github.com/ildoonet/tf-pose-estimationを動かす際に行ったことです。(モデルのダウンロード等は除く)

  1. pipを用いて以下のモジュール・ライブラリをインストール。
argparse dill fire matplotlib psutil pycocotools requests scikit-image scipy slidingwindow tqdm
  1. 実行時の以下のエラーに対処。
ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.

これは、https://qiita.com/masatomix/items/03419c7ea10262da18f3を参考に

echo "backend : Qt4Agg" >> ~/.matplotlib/matplotlibrc

で解決しました!

投稿2020/05/13 05:13

ccchogeee

総合スコア11

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問