Opencv Aruco で Pose estimation する その2 estimatePoseBoard
今度は estimatePoseBoard を試します。
#!/usr/bin/env python # -*- coding: utf-8 -* import cv2 import numpy as np aruco = cv2.aruco # WEBカメラ cap = cv2.VideoCapture(0) dictionary = aruco.getPredefinedDictionary(aruco.DICT_4X4_50) parameters = aruco.DetectorParameters_create() # CORNER_REFINE_NONE, no refinement. CORNER_REFINE_SUBPIX, do subpixel refinement. CORNER_REFINE_CONTOUR use contour-Points parameters.cornerRefinementMethod = aruco.CORNER_REFINE_CONTOUR cameraMatrix = np.array( [[1.42068235e+03,0.00000000e+00,9.49208512e+02], [0.00000000e+00,1.37416685e+03,5.39622051e+02], [0.00000000e+00,0.00000000e+00,1.00000000e+00]] ) distCoeffs = np.array( [1.69926613e-01,-7.40003491e-01,-7.45655262e-03,-1.79442353e-03, 2.46650225e+00] ) cap.set(cv2.CAP_PROP_FPS, 10) #cap.set(cv2.CAP_PROP_FRAME_WIDTH, 600) #cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 600) board = aruco.GridBoard_create(5, 1, 0.04, 0.01, dictionary) def main(): ret, frame = cap.read() # 変換処理ループ while ret == True: corners, ids, rejectedImgPoints = aruco.detectMarkers(frame, dictionary, parameters=parameters) #print(corners) #print(ids) #print(rejectedImgPoints) aruco.drawDetectedMarkers(frame, corners, ids, (0,255,0)) for i, corner in enumerate( corners ): points = corner[0].astype(np.int32) cv2.polylines(frame, [points], True, (0,255,255)) cv2.putText(frame, str(ids[i][0]), tuple(points[0]), cv2.FONT_HERSHEY_PLAIN, 1,(0,0,0), 1) # int valid = estimatePoseBoard(corners, ids, board, cameraMatrix, distCoeffs, rvec, tvec); retval, rvec, tvec = aruco.estimatePoseBoard(corners, ids, board, cameraMatrix, distCoeffs) if retval != 0: aruco.drawAxis(frame, cameraMatrix, distCoeffs, rvec, tvec, 0.1) cv2.imshow('org', frame) # Escキーで終了 key = cv2.waitKey(50) if key == 27: # ESC break # 次のフレーム読み込み ret, frame = cap.read() if __name__ == '__main__': try: main() except KeyboardInterrupt: pass
これでも、やはり、 z axis flipping は発生します。
Opencv Aruco で Pose estimation する その1
Pose estimation ってのは、姿勢推定 なのでしょうか?
estimatePoseSingleMarkers においては、そのマーカーの向きを推定します(多分)。
なお、estimatePoseBoard も有ります。
とにかくやってみましょう。
マーカー画像の用意
今回は、マーカーを5つ(0,1,2,3,4)印刷しました。DICT_4X4_50 で作成したものです。
スクリプト
(いくつかのサイト様のコードを参考にさせていただいたのですが、混じってしまって、特定できませんでした。)
#!/usr/bin/env python # -*- coding: utf-8 -* import cv2 import numpy as np aruco = cv2.aruco # WEBカメラ cap = cv2.VideoCapture(0) dictionary = aruco.getPredefinedDictionary(aruco.DICT_4X4_50) parameters = aruco.DetectorParameters_create() # CORNER_REFINE_NONE, no refinement. CORNER_REFINE_SUBPIX, do subpixel refinement. CORNER_REFINE_CONTOUR use contour-Points parameters.cornerRefinementMethod = aruco.CORNER_REFINE_CONTOUR cameraMatrix = np.array( [[1.42068235e+03,0.00000000e+00,9.49208512e+02], [0.00000000e+00,1.37416685e+03,5.39622051e+02], [0.00000000e+00,0.00000000e+00,1.00000000e+00]] ) distCoeffs = np.array( [1.69926613e-01,-7.40003491e-01,-7.45655262e-03,-1.79442353e-03, 2.46650225e+00] ) cap.set(cv2.CAP_PROP_FPS, 10) #cap.set(cv2.CAP_PROP_FRAME_WIDTH, 600) #cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 600) def main(): ret, frame = cap.read() # 変換処理ループ while ret == True: corners, ids, rejectedImgPoints = aruco.detectMarkers(frame, dictionary, parameters=parameters) #print(corners) #print(ids) #print(rejectedImgPoints) aruco.drawDetectedMarkers(frame, corners, ids, (0,255,0)) for i, corner in enumerate( corners ): points = corner[0].astype(np.int32) cv2.polylines(frame, [points], True, (0,255,255)) cv2.putText(frame, str(ids[i][0]), tuple(points[0]), cv2.FONT_HERSHEY_PLAIN, 1,(0,0,0), 1) # rvecs, tvecs, _objPoints = cv.aruco.estimatePoseSingleMarkers( corners, markerLength, cameraMatrix, distCoeffs[, rvecs[, tvecs[, _objPoints]]] ) rvecs, tvecs, _objPoints = aruco.estimatePoseSingleMarkers(corners, 0.05, cameraMatrix, distCoeffs) if ids is not None: for i in range( ids.size ): #print( 'rvec {}, tvec {}'.format( rvecs[i], tvecs[i] )) #print( 'rvecs[{}] {}'.format( i, rvecs[i] )) #print( 'tvecs[{}] {}'.format( i, tvecs[i] )) aruco.drawAxis(frame, cameraMatrix, distCoeffs, rvecs[i], tvecs[i], 0.1) cv2.imshow('org', frame) # Escキーで終了 key = cv2.waitKey(50) if key == 27: # ESC break # 次のフレーム読み込み ret, frame = cap.read() if __name__ == '__main__': try: main() except KeyboardInterrupt: pass
parameters.cornerRefinementMethod = aruco.CORNER_REFINE_CONTOUR
で、何かを設定していますが、どの様な差が出るのかわかってません。
z axis flipping 現象
z軸が反転するような現象が起こります。(再現して撮影しようとすると、変に大変だったりします。)
これは、バグなのかどうか、スレッドがいろいろ見当たりますが、どうやらバグではなく、そういうもののようです。
この画像の、白の面が、どっち向きなのか(天井から下がっているのか、地面に設置されているのか)を、判定できないことと一緒らしいです。
Iterative Pose Estimation Using Coplanar Feature Points
https://pdfs.semanticscholar.org/36bc/490d902061a27b1c598725cd61ad9f1fd4b5.pdf
の画像。
じゃあどうする?
今回のように、複数のマーカーが存在し、向きが一緒だとわかっている場合は、マーカーの向きを多数決的に決めてしまえば、ほぼOKとの指摘があります。
opencv チュートリアルチャレンジ カメラキャリブレーション
カメラキャリブレーション — OpenCV-Python Tutorials 1 documentation
Aruco で estimatePoseSingleMarkers を試したいと思ったところ、cameraMatrix と distCoeffs が必要だと判明。
OpenCV: ArUco Marker Detection
estimatePoseSingleMarkers Pose estimation for single markers.
cameraMatrix と distCoeffs は、カメラ行列(内部パラメータ)
レンズ歪みパラメータ
らしい。
Camera Calibration and 3D Reconstruction — OpenCV 3.0.0-dev documentation
Python: cv2.calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs[, rvecs[, tvecs[, flags[, criteria]]]]) → retval, cameraMatrix, distCoeffs, rvecs, tvecs
とにかく取得しましょう。
チェスボードを用意する
https://github.com/opencv/opencv/tree/master/samples/data
こちらから、chessboard.png
を取得し、印刷。
曲がらないように、板に貼り付けました。
画像を用意する
キャリブレーションしたいカメラ(今回はWEBカメラ)で、チェスボード用紙を、いろんな角度から撮影します。
(背景にいろいろ写り込んでいたので、写真の掲載は控えます)
ディレクトリ calib を作成し、入れ込んでおきます。
パラメーターを算出する
こちらを参考(ほぼそのまま)にしました。
csharp/calibration.py at master · tanaka0079/csharp · GitHub
myCalib.py
# -*- coding: utf-8 -*- import numpy as np import cv2 from glob import glob def main(): square_size = 1.0 # 正方形のサイズ pattern_size = (7, 7) # 交差ポイントの数 pattern_points = np.zeros( (np.prod(pattern_size), 3), np.float32 ) #チェスボード(X,Y,Z)座標の指定 (Z=0) pattern_points[:,:2] = np.indices(pattern_size).T.reshape(-1, 2) pattern_points *= square_size objpoints = [] imgpoints = [] for fn in glob("calib/*.jpg"): # 画像の取得 gray = cv2.imread(fn, 0) print("loading..." + fn) # チェスボードのコーナーを検出 ret, corner = cv2.findChessboardCorners(gray, pattern_size) # コーナーがあれば if ret == True: term = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_COUNT, 30, 0.1) cv2.cornerSubPix(gray, corner, (5,5), (-1,-1), term) else: print('Chessboard not found!') continue imgpoints.append(corner.reshape(-1, 2)) #appendメソッド:リストの最後に因数のオブジェクトを追加 objpoints.append(pattern_points) #corner.reshape(-1, 2) : 検出したコーナーの画像内座標値(x, y) # 内部パラメータを計算 ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1], None, None) # 計算結果を表示 print("RMS = ", ret) print("mtx = \n", mtx) print("dist = ", dist.ravel()) # 計算結果を保存 np.savetxt("ret.csv", np.array([ret]), delimiter =',',fmt="%0.14f") np.savetxt("mtx.csv", mtx, delimiter =',',fmt="%0.14f") if __name__ == '__main__': main()
私の結果は、
mtx
1420.68234847996541,0.00000000000000,949.20851179562965 0.00000000000000,1374.16684667116965,539.62205073603297 0.00000000000000,0.00000000000000,1.00000000000000
ret
1.129281781
でした。
Dell alienware aurora r4 Bios update
alienware aurora r4 は、古いけれども、まだまだ使えると思う。
SSDを新品に変えて、Windows10を入れた。
せっかくなので、GeForce GTX 1050ti あたりを入れてみようかな?そもそも対応しているのかな?と、情報を集めていたところ「Biosがアップデートされて入れば動くよ!」という書き込みを発見し、まぁとりあえず Bios update だけでもやってみるかな?と思ったところ、かなり時間がかかったので、備忘録と、日本の何処かの人の助けにはなるかな? と思って記載します。
Bios 設定画面に進めない!
F2 でBios設定画面、F12 で起動オプションをが出る、、、はず。
ところがなんと、今回はここからつまずきました。
刺してあった、ゲーミングキーボードの G510 キーボードでは、F2 を押しまくっても、押し続けても、 Bios設定画面に入れない。
ふと、しまってあったDellのシンプルなUSBキーボードを全面のUSBポートにつなぎ直して挑戦したら、すんなり入れた。
キーボードの違いなのか、USBポートの違いなのかは、不明。
ハードウェア
Dell alienware aurora r4
Bios
現状 A3
目標 A11
ダウンロード
Alienware Aurora R4のサポート | ドライバおよびダウンロード | Dell 日本
アップデートできない!?
A11 アップデートでつまずく
ドキュメントには、windows環境でも、動くよと、ある。
インストール手順 Run the BIOS update utility from Windows environment 1. Browse to the location where you downloaded the file and double-click the new file. 2. Windows System will auto restart and update BIOS while system startup screen. 3. After BIOS update finished, system will auto reboot to take effect.
ところが、A11 の Bios アップデートプログラムをダウンロードしてを実行すると、A5 に先にしろと言われる。
A5 でエラー!
じゃあということで、ダウンロードして実行する。
Alienware Aurora R4 System BIOS ドライバの詳細 | Dell 日本
インストール手順 1. Click the .exe in OS mode 2. Enter YES to update your BIOS. 3. After flash OK, please remember to restart your system.
と、でるが、A5 の Bios アップデートプログラムを実行すると、エラーがでて進まない。
MS-Dos でやるといいらしい。
調べていくと、free-dos の起動USBにファイルを書き足す方法と、ms-dos で行う方法が見つかった。
ms-dos の 起動USB を作成するほうが楽だと判断した。
MS-DOS 起動USB の作成
HP USB Disk Storage を使用する
HP USB Disk Storage を取得する。
起動情報は、Windows98 のものをダウンロードした。どこからか拾ってきた気がします。
フォーマットできない!?
Windows10で実行すると、Write protected と出る。
解除方法は youtube で見つかった。
※後述しますが、私は結局失敗してます
https://www.youtube.com/watch?v=NidagvFl5kI
Input these in order: "diskpart" enter "listdisk" enter "select disk 1" enter (just don't choose wrong partition, notice the size partition) "clean" enter "convert mbr" enter
Biosファイルのリネーム
ファイル名の長さ制限「ファイル名(ベース名)部分が最大で8文字、拡張子部分が最大で3文字」らしいので、A5.exe, A11.exe などとリネームしておいた。
Biosファイルを設置
USBのRootディレクトリに置いた。
F12 から USB ブート
MS-DOS の起動までは行くが、A5を実行しても、プログラムが進まない。
しばらく待って、Ctrl + Alt + Del で抜け出した。
Windows7でサイド作成
Windowsを10から7に変えたから成功したのかは不明だが、Write protected などともでず、普通に終わった。
再度 Ms-dos で起動
起動し、A5 を実行。
進捗画面がちゃんと出て、1分足らずで終了。
動作確認
Windowsを通常起動し、正常に使用できることを確認した。
A11 にアップデート
再度 USB から MS-Dos で起動し、A11 を実行。正常に終わる。
再起動でとまった
y でリブートするが、けたたましいファンの音がするばかりで起動しない。
このことは、BBS でも報告があり、電源を切って入れ直すと2回目の起動で正常に進んだ・・・と書かれてあったので、しばらくまってみてから、電源を切って再起動した。
無事完了したように思われる。
opencv で 鮮鋭化
鮮鋭化 / アンシャープマスキング を行います。
チュートリアルには登場しないし、専用の関数も無いのですが、cvFilter2D で、kernel にマイナスを使用して適用することで実現するようです。
filter2D
使用するカーネルは
0, −1, 0 −1, 5, −1, 0, −1, 0
−1, −1, −1 −1, 9, −1, −1, −1, −1
などです。
結果
オリジナル
4近傍
8近傍
#!/usr/bin/env python # -*- coding: utf-8 -* import sys import cv2 import numpy as np def main(): # BGR image = cv2.imread('img/um.02.png') cv2.namedWindow("original") cv2.moveWindow("original", 200, 200) cv2.imshow('original', image) kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]], np.float32) #kernel = np.array([[0,-1,0], [-1,5,-1], [0,-1,0]], np.float32) print(kernel) dst = cv2.filter2D(image, -1, kernel) cv2.namedWindow("result") cv2.moveWindow("result", 200, 400) cv2.imshow('result', dst) cv2.imwrite('img/um.k9.png', dst) cv2.waitKey(0) cv2.destroyAllWindows() return 0 if __name__ == '__main__': try: main() except KeyboardInterrupt: pass
openpose を試す
openpose を試しましょう。
インストール
openpose/installation.md at master · CMU-Perceptual-Computing-Lab/openpose · GitHub
依存
いろいろありますが、構築が面倒な CUDA 8 と cuDNN 5.1 が、私の環境では、ちょうど
$ nvcc --version nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2016 NVIDIA Corporation Built on Tue_Jan_10_13:22:03_CST_2017 Cuda compilation tools, release 8.0, V8.0.61 $ ls /usr/local/cuda/lib64/libcudnn.so.* /usr/local/cuda/lib64/libcudnn.so.5 /usr/local/cuda/lib64/libcudnn.so.5.1.10
ということで、満たしておりました。
その他も、 apt-get からインストールできました。
コマンドラインからコンパイル
openpose/installation.md at master · CMU-Perceptual-Computing-Lab/openpose · GitHub
テスト
まずは、サンプルを使いましょう。
処理が軽そうな画像を。
~/openpose$ ./build/examples/openpose/openpose.bin --image_dir examples/media/ Starting pose estimation demo. Auto-detecting all available GPUs... Detected 1 GPU(s), using 1 of them starting at GPU 0. Starting thread(s) Real-time pose estimation demo successfully finished. Total time: 9.159081 seconds. HDF5: infinite loop closing library D,T,F,FD,P,FD,P,FD,P,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E
加工後の画像が表示されて、消えていきます。
オプションの確認
$ ./openpose/build/examples/openpose/openpose.bin --help openpose.bin: Warning: SetUsageMessage() never called Flags from /home/kiyo/openpose/examples/openpose/openpose.cpp: -3d (Running OpenPose 3-D reconstruction demo: 1) Reading from a stereo camera system. 2) Performing 3-D reconstruction from the multiple views. 3) Displaying 3-D reconstruction results. Note that it will only display 1 person. If multiple people is present, it will fail.) type: bool default: false -3d_min_views (Minimum number of views required to reconstruct each keypoint. By default (-1), it will require all the cameras to see the keypoint in order to reconstruct it.) type: int32 default: -1 -3d_views (Complementary option to `--image_dir` or `--video`. OpenPose will read as many images per iteration, allowing tasks such as stereo camera processing (`--3d`). Note that `--camera_parameters_folder` must be set. OpenPose must find as many `xml` files in the parameter folder as this number indicates.) type: int32 default: 1 -alpha_heatmap (Blending factor (range 0-1) between heatmap and original frame. 1 will only show the heatmap, 0 will only show the frame. Only valid for GPU rendering.) type: double default: 0.69999999999999996 -alpha_pose (Blending factor (range 0-1) for the body part rendering. 1 will show it completely, 0 will hide it. Only valid for GPU rendering.) type: double default: 0.59999999999999998 -body_disable (Disable body keypoint detection. Option only possible for faster (but less accurate) face keypoint detection.) type: bool default: false -camera (The camera index for cv::VideoCapture. Integer in the range [0, 9]. Select a negative number (by default), to auto-detect and open the first available camera.) type: int32 default: -1 -camera_fps (Frame rate for the webcam (also used when saving video). Set this value to the minimum value between the OpenPose displayed speed and the webcam real frame rate.) type: double default: 30 -camera_parameter_folder (String with the folder where the camera parameters are located.) type: string default: "models/cameraParameters/flir/" -camera_resolution (Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the default 1280x720 for `--camera`, or the maximum flir camera resolution available for `--flir_camera`) type: string default: "-1x-1" -disable_blending (If enabled, it will render the results (keypoint skeletons or heatmaps) on a black background, instead of being rendered into the original image. Related: `part_to_show`, `alpha_pose`, and `alpha_pose`.) type: bool default: false -disable_multi_thread (It would slightly reduce the frame rate in order to highly reduce the lag. Mainly useful for 1) Cases where it is needed a low latency (e.g. webcam in real-time scenarios with low-range GPU devices); and 2) Debugging OpenPose when it is crashing to locate the error.) type: bool default: false -display (Display mode: -1 for automatic selection; 0 for no display (useful if there is no X server and/or to slightly speed up the processing if visual output is not required); 2 for 2-D display; 3 for 3-D display (if `--3d` enabled); and 1 for both 2-D and 3-D display.) type: int32 default: -1 -face (Enables face keypoint detection. It will share some parameters from the body pose, e.g. `model_folder`. Note that this will considerable slow down the performance and increse the required GPU memory. In addition, the greater number of people on the image, the slower OpenPose will be.) type: bool default: false -face_alpha_heatmap (Analogous to `alpha_heatmap` but applied to face.) type: double default: 0.69999999999999996 -face_alpha_pose (Analogous to `alpha_pose` but applied to face.) type: double default: 0.59999999999999998 -face_net_resolution (Multiples of 16 and squared. Analogous to `net_resolution` but applied to the face keypoint detector. 320x320 usually works fine while giving a substantial speed up when multiple faces on the image.) type: string default: "368x368" -face_render (Analogous to `render_pose` but applied to the face. Extra option: -1 to use the same configuration that `render_pose` is using.) type: int32 default: -1 -face_render_threshold (Analogous to `render_threshold`, but applied to the face keypoints.) type: double default: 0.40000000000000002 -flir_camera (Whether to use FLIR (Point-Grey) stereo camera.) type: bool default: false -frame_first (Start on desired frame number. Indexes are 0-based, i.e. the first frame has index 0.) type: uint64 default: 0 -frame_flip (Flip/mirror each frame (e.g. for real time webcam demonstrations).) type: bool default: false -frame_last (Finish on desired frame number. Select -1 to disable. Indexes are 0-based, e.g. if set to 10, it will process 11 frames (0-10).) type: uint64 default: 18446744073709551615 -frame_rotate (Rotate each frame, 4 possible values: 0, 90, 180, 270.) type: int32 default: 0 -frames_repeat (Repeat frames when finished.) type: bool default: false -fullscreen (Run in full-screen mode (press f during runtime to toggle).) type: bool default: false -hand (Enables hand keypoint detection. It will share some parameters from the body pose, e.g. `model_folder`. Analogously to `--face`, it will also slow down the performance, increase the required GPU memory and its speed depends on the number of people.) type: bool default: false -hand_alpha_heatmap (Analogous to `alpha_heatmap` but applied to hand.) type: double default: 0.69999999999999996 -hand_alpha_pose (Analogous to `alpha_pose` but applied to hand.) type: double default: 0.59999999999999998 -hand_net_resolution (Multiples of 16 and squared. Analogous to `net_resolution` but applied to the hand keypoint detector.) type: string default: "368x368" -hand_render (Analogous to `render_pose` but applied to the hand. Extra option: -1 to use the same configuration that `render_pose` is using.) type: int32 default: -1 -hand_render_threshold (Analogous to `render_threshold`, but applied to the hand keypoints.) type: double default: 0.20000000000000001 -hand_scale_number (Analogous to `scale_number` but applied to the hand keypoint detector. Our best results were found with `hand_scale_number` = 6 and `hand_scale_range` = 0.4.) type: int32 default: 1 -hand_scale_range (Analogous purpose than `scale_gap` but applied to the hand keypoint detector. Total range between smallest and biggest scale. The scales will be centered in ratio 1. E.g. if scaleRange = 0.4 and scalesNumber = 2, then there will be 2 scales, 0.8 and 1.2.) type: double default: 0.40000000000000002 -hand_tracking (Adding hand tracking might improve hand keypoints detection for webcam (if the frame rate is high enough, i.e. >7 FPS per GPU) and video. This is not person ID tracking, it simply looks for hands in positions at which hands were located in previous frames, but it does not guarantee the same person ID among frames.) type: bool default: false -heatmaps_add_PAFs (Same functionality as `add_heatmaps_parts`, but adding the PAFs.) type: bool default: false -heatmaps_add_bkg (Same functionality as `add_heatmaps_parts`, but adding the heatmap corresponding to background.) type: bool default: false -heatmaps_add_parts (If true, it will fill op::Datum::poseHeatMaps array with the body part heatmaps, and analogously face & hand heatmaps to op::Datum::faceHeatMaps & op::Datum::handHeatMaps. If more than one `add_heatmaps_X` flag is enabled, it will place then in sequential memory order: body parts + bkg + PAFs. It will follow the order on POSE_BODY_PART_MAPPING in `src/openpose/pose/poseParameters.cpp`. Program speed will considerably decrease. Not required for OpenPose, enable it only if you intend to explicitly use this information later.) type: bool default: false -heatmaps_scale (Set 0 to scale op::Datum::poseHeatMaps in the range [-1,1], 1 for [0,1]; 2 for integer rounded [0,255]; and 3 for no scaling.) type: int32 default: 2 -identification (Whether to enable people identification across frames. Not available yet, coming soon.) type: bool default: false -image_dir (Process a directory of images. Use `examples/media/` for our default example folder with 20 images. Read all standard formats (jpg, png, bmp, etc.).) type: string default: "" -ip_camera (String with the IP camera URL. It supports protocols like RTSP and HTTP.) type: string default: "" -keypoint_scale (Scaling of the (x,y) coordinates of the final pose data array, i.e. the scale of the (x,y) coordinates that will be saved with the `write_keypoint` & `write_keypoint_json` flags. Select `0` to scale it to the original source resolution, `1`to scale it to the net output size (set with `net_resolution`), `2` to scale it to the final output size (set with `resolution`), `3` to scale it in the range [0,1], and 4 for range [-1,1]. Non related with `scale_number` and `scale_gap`.) type: int32 default: 0 -logging_level (The logging level. Integer in the range [0, 255]. 0 will output any log() message, while 255 will not output any. Current OpenPose library messages are in the range 0-4: 1 for low priority messages and 4 for important ones.) type: int32 default: 3 -model_folder (Folder path (absolute or relative) where the models (pose, face, ...) are located.) type: string default: "models/" -model_pose (Model to be used. E.g. `COCO` (18 keypoints), `MPI` (15 keypoints, ~10% faster), `MPI_4_layers` (15 keypoints, even faster but less accurate).) type: string default: "COCO" -net_resolution (Multiples of 16. If it is increased, the accuracy potentially increases. If it is decreased, the speed increases. For maximum speed-accuracy balance, it should keep the closest aspect ratio possible to the images or videos to be processed. Using `-1` in any of the dimensions, OP will choose the optimal aspect ratio depending on the user's input value. E.g. the default `-1x368` is equivalent to `656x368` in 16:9 resolutions, e.g. full HD (1980x1080) and HD (1280x720) resolutions.) type: string default: "-1x368" -no_gui_verbose (Do not write text on output images on GUI (e.g. number of current frame and people). It does not affect the pose rendering.) type: bool default: false -num_gpu (The number of GPU devices to use. If negative, it will use all the available GPUs in your machine.) type: int32 default: -1 -num_gpu_start (GPU device start number.) type: int32 default: 0 -number_people_max (This parameter will limit the maximum number of people detected, by keeping the people with top scores. The score is based in person area over the image, body part score, as well as joint score (between each pair of connected body parts). Useful if you know the exact number of people in the scene, so it can remove false positives (if all the people have been detected. However, it might also include false negatives by removing very small or highly occluded people. -1 will keep them all.) type: int32 default: -1 -output_resolution (The image resolution (display and output). Use "-1x-1" to force the program to use the input image resolution.) type: string default: "-1x-1" -part_candidates (Also enable `write_json` in order to save this information. If true, it will fill the op::Datum::poseCandidates array with the body part candidates. Candidates refer to all the detected body parts, before being assembled into people. Note that the number of candidates is equal or higher than the number of final body parts (i.e. after being assembled into people). The empty body parts are filled with 0s. Program speed will slightly decrease. Not required for OpenPose, enable it only if you intend to explicitly use this information.) type: bool default: false -part_to_show (Prediction channel to visualize (default: 0). 0 for all the body parts, 1-18 for each body part heat map, 19 for the background heat map, 20 for all the body part heat maps together, 21 for all the PAFs, 22-40 for each body part pair PAF.) type: int32 default: 0 -process_real_time (Enable to keep the original source frame rate (e.g. for video). If the processing time is too long, it will skip frames. If it is too fast, it will slow it down.) type: bool default: false -profile_speed (If PROFILER_ENABLED was set in CMake or Makefile.config files, OpenPose will show some runtime statistics at this frame number.) type: int32 default: 1000 -render_pose (Set to 0 for no rendering, 1 for CPU rendering (slightly faster), and 2 for GPU rendering (slower but greater functionality, e.g. `alpha_X` flags). If -1, it will pick CPU if CPU_ONLY is enabled, or GPU if CUDA is enabled. If rendering is enabled, it will render both `outputData` and `cvOutputData` with the original image and desired body part to be shown (i.e. keypoints, heat maps or PAFs).) type: int32 default: -1 -render_threshold (Only estimated keypoints whose score confidences are higher than this threshold will be rendered. Generally, a high threshold (> 0.5) will only render very clear body parts; while small thresholds (~0.1) will also output guessed and occluded keypoints, but also more false positives (i.e. wrong detections).) type: double default: 0.050000000000000003 -scale_gap (Scale gap between scales. No effect unless scale_number > 1. Initial scale is always 1. If you want to change the initial scale, you actually want to multiply the `net_resolution` by your desired initial scale.) type: double default: 0.29999999999999999 -scale_number (Number of scales to average.) type: int32 default: 1 -video (Use a video file instead of the camera. Use `examples/media/video.avi` for our default example video.) type: string default: "" -write_coco_json (Full file path to write people pose data with JSON COCO validation format.) type: string default: "" -write_heatmaps (Directory to write body pose heatmaps in PNG format. At least 1 `add_heatmaps_X` flag must be enabled.) type: string default: "" -write_heatmaps_format (File extension and format for `write_heatmaps`, analogous to `write_images_format`. For lossless compression, recommended `png` for integer `heatmaps_scale` and `float` for floating values.) type: string default: "png" -write_images (Directory to write rendered frames in `write_images_format` image format.) type: string default: "" -write_images_format (File extension and format for `write_images`, e.g. png, jpg or bmp. Check the OpenCV function cv::imwrite for all compatible extensions.) type: string default: "png" -write_json (Directory to write OpenPose output in JSON format. It includes body, hand, and face pose keypoints (2-D and 3-D), as well as pose candidates (if `--part_candidates` enabled).) type: string default: "" -write_keypoint ((Deprecated, use `write_json`) Directory to write the people pose keypoint data. Set format with `write_keypoint_format`.) type: string default: "" -write_keypoint_format ((Deprecated, use `write_json`) File extension and format for `write_keypoint`: json, xml, yaml & yml. Json not available for OpenCV < 3.0, use `write_keypoint_json` instead.) type: string default: "yml" -write_keypoint_json ((Deprecated, use `write_json`) Directory to write people pose data in JSON format, compatible with any OpenCV version.) type: string default: "" -write_video (Full file path to write rendered frames in motion JPEG video format. It might fail if the final path does not finish in `.avi`. It internally uses cv::VideoWriter.) type: string default: "" Flags from src/gflags.cc: -flagfile (load flags from file) type: string default: "" -fromenv (set flags from the environment [use 'export FLAGS_flag1=value']) type: string default: "" -tryfromenv (set flags from the environment if present) type: string default: "" -undefok (comma-separated list of flag names that it is okay to specify on the command line even if the program does not define a flag with that name. IMPORTANT: flags in this list that have arguments MUST use the flag=value format) type: string default: "" Flags from src/gflags_completions.cc: -tab_completion_columns (Number of columns to use in output for tab completion) type: int32 default: 80 -tab_completion_word (If non-empty, HandleCommandLineCompletions() will hijack the process and attempt to do bash-style command line flag completion on this value.) type: string default: "" Flags from src/gflags_reporting.cc: -help (show help on all flags [tip: all flags can have two dashes]) type: bool default: false currently: true -helpfull (show help on all flags -- same as -help) type: bool default: false -helpmatch (show help on modules whose name contains the specified substr) type: string default: "" -helpon (show help on the modules named by this flag value) type: string default: "" -helppackage (show help on all modules in the main package) type: bool default: false -helpshort (show help on only the main module for this program) type: bool default: false -helpxml (produce an xml version of help) type: bool default: false -version (show version and build info and exit) type: bool default: false Flags from src/logging.cc: -alsologtoemail (log messages go to these email addresses in addition to logfiles) type: string default: "" -alsologtostderr (log messages go to stderr in addition to logfiles) type: bool default: false -colorlogtostderr (color messages logged to stderr (if supported by terminal)) type: bool default: false -drop_log_memory (Drop in-memory buffers of log contents. Logs can grow very quickly and they are rarely read before they need to be evicted from memory. Instead, drop them from memory as soon as they are flushed to disk.) type: bool default: true -log_backtrace_at (Emit a backtrace when logging at file:linenum.) type: string default: "" -log_dir (If specified, logfiles are written into this directory instead of the default logging directory.) type: string default: "" -log_link (Put additional links to the log files in this directory) type: string default: "" -log_prefix (Prepend the log prefix to the start of each log line) type: bool default: true -logbuflevel (Buffer log messages logged at this level or lower (-1 means don't buffer; 0 means buffer INFO only; ...)) type: int32 default: 0 -logbufsecs (Buffer log messages for at most this many seconds) type: int32 default: 30 -logemaillevel (Email log messages logged at this level or higher (0 means email all; 3 means email FATAL only; ...)) type: int32 default: 999 -logmailer (Mailer used to send logging email) type: string default: "/bin/mail" -logtostderr (log messages go to stderr instead of logfiles) type: bool default: false -max_log_size (approx. maximum log file size (in MB). A value of 0 will be silently overridden to 1.) type: int32 default: 1800 -minloglevel (Messages logged at a lower level than this don't actually get logged anywhere) type: int32 default: 0 -stderrthreshold (log messages at or above this level are copied to stderr in addition to logfiles. This flag obsoletes --alsologtostderr.) type: int32 default: 2 -stop_logging_if_full_disk (Stop attempting to log to disk if the disk is full.) type: bool default: false Flags from src/utilities.cc: -symbolize_stacktrace (Symbolize the stack trace in the tombstone) type: bool default: true Flags from src/vlog_is_on.cc: -v (Show all VLOG(m) messages for m <= this. Overridable by --vmodule.) type: int32 default: 0 -vmodule (per-module verbose level. Argument is a comma-separated list of <module name>=<log level>. <module name> is a glob pattern, matched against the filename base (that is, name ignoring .cc/.h./-inl.h). <log level> overrides any value given by --v.) type: string default:
オプションを指定して、保存しましょう。
/openpose$ ./build/examples/openpose/openpose.bin --image_dir examples/media/ -write_images write_images -write_images_format png
これで、 write_images ディレクトリに、加工済みの画像が保存されます。
Windows10 で LIS
思い出しながらのメモ
Python2.7 をインストール
CUDA と library tools を入れた気がする
Unity インストール
起動には、ユーザー登録が必要
Git インストール
git for windows からインストール
LIS の取得
$ git clone https://github.com/wbap/lis.git
必要な Python ライブラリを入れる
$ pip install -r python-agent\requirements.txt
Chainer のバージョンを合わせる?
どうやら、下記で使用されている Chainer では、FunctionSet を使用しているので、どうやら、1系列っぽい。
インストールが通らなかったので、
???.h と x???.h をネットで拾ってきて入れた上で、
chainer の version を 1.5 で試したら、通ったので、それでやった。
しばらく学習させた結果