質問内容
現在次のサイト:python+keras+LeapMotionで手の形の判別をしてみた。を参考に「Leap Motionを用いて数種類の手の形状のデータセットを作成し、それをCNNによって学習させ、OpenCVのカメラ画像に映った手の形状が何を表すかを判別する」といったことをやりたいと思っています。
上記したサイトを参考にCNNによって学習まではできたのですが、そのあとが出来ません。なのでOpenCVのプログラムに合わせてwhile文で指の関節のデータの取得を行いたいと考えています。どのようにすれば指の関節のデータの取得ができるでしょうか?
ソースコード
leapmotion_pd.py:上記したサイト内にあるデータセット作成に用いたソースコード
このプログラムうちのの以下のデータに取得を行いたいと思っています。
if self.finger_names[finger.type] == 'Thumb': if self.bone_names[bone.type] == 'Metacarpal': Thumb_fin_meta_direction_x.append(bone.direction.x) Thumb_fin_meta_direction_y.append(bone.direction.y) Thumb_fin_meta_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Proximal': Thumb_fin_prox_direction_x.append(bone.direction.x) Thumb_fin_prox_direction_y.append(bone.direction.y) Thumb_fin_prox_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Intermediate': Thumb_fin_inter_direction_x.append(bone.direction.x) Thumb_fin_inter_direction_y.append(bone.direction.y) Thumb_fin_inter_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Distal': Thumb_fin_dist_direction_x.append(bone.direction.x) Thumb_fin_dist_direction_y.append(bone.direction.y) Thumb_fin_dist_direction_z.append(bone.direction.z) if self.finger_names[finger.type] == 'Index': if self.bone_names[bone.type] == 'Metacarpal': Index_fin_meta_direction_x.append(bone.direction.x) Index_fin_meta_direction_y.append(bone.direction.y) Index_fin_meta_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Proximal': Index_fin_prox_direction_x.append(bone.direction.x) Index_fin_prox_direction_y.append(bone.direction.y) Index_fin_prox_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Intermediate': Index_fin_inter_direction_x.append(bone.direction.x) Index_fin_inter_direction_y.append(bone.direction.y) Index_fin_inter_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Distal': Index_fin_dist_direction_x.append(bone.direction.x) Index_fin_dist_direction_y.append(bone.direction.y) Index_fin_dist_direction_z.append(bone.direction.z) if self.finger_names[finger.type] == 'Middle': if self.bone_names[bone.type] == 'Metacarpal': Middle_fin_meta_direction_x.append(bone.direction.x) Middle_fin_meta_direction_y.append(bone.direction.y) Middle_fin_meta_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Proximal': Middle_fin_prox_direction_x.append(bone.direction.x) Middle_fin_prox_direction_y.append(bone.direction.y) Middle_fin_prox_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Intermediate': Middle_fin_inter_direction_x.append(bone.direction.x) Middle_fin_inter_direction_y.append(bone.direction.y) Middle_fin_inter_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Distal': Middle_fin_dist_direction_x.append(bone.direction.x) Middle_fin_dist_direction_y.append(bone.direction.y) Middle_fin_dist_direction_z.append(bone.direction.z) if self.finger_names[finger.type] == 'Ring': if self.bone_names[bone.type] == 'Metacarpal': Ring_fin_meta_direction_x.append(bone.direction.x) Ring_fin_meta_direction_y.append(bone.direction.y) Ring_fin_meta_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Proximal': Ring_fin_prox_direction_x.append(bone.direction.x) Ring_fin_prox_direction_y.append(bone.direction.y) Ring_fin_prox_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Intermediate': Ring_fin_inter_direction_x.append(bone.direction.x) Ring_fin_inter_direction_y.append(bone.direction.y) Ring_fin_inter_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Distal': Ring_fin_dist_direction_x.append(bone.direction.x) Ring_fin_dist_direction_y.append(bone.direction.y) Ring_fin_dist_direction_z.append(bone.direction.z) if self.finger_names[finger.type] == 'Pinky': if self.bone_names[bone.type] == 'Metacarpal': Pinky_fin_meta_direction_x.append(bone.direction.x) Pinky_fin_meta_direction_y.append(bone.direction.y) Pinky_fin_meta_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Proximal': Pinky_fin_prox_direction_x.append(bone.direction.x) Pinky_fin_prox_direction_y.append(bone.direction.y) Pinky_fin_prox_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Intermediate': Pinky_fin_inter_direction_x.append(bone.direction.x) Pinky_fin_inter_direction_y.append(bone.direction.y) Pinky_fin_inter_direction_z.append(bone.direction.z) if self.bone_names[bone.type] == 'Distal': Pinky_fin_dist_direction_x.append(bone.direction.x) Pinky_fin_dist_direction_y.append(bone.direction.y) Pinky_fin_dist_direction_z.append(bone.direction.z) -----------------------------------省略---------------------------------------------- arm_direction_x.append(arm.direction.x) arm_direction_y.append(arm.direction.y) arm_direction_z.append(arm.direction.z)
OpenCVのプログラム
import cv2 import Leap, sys, time controller = Leap.Controller() now=0 # 動画表示 cap = cv2.VideoCapture(0) # 無限ループ while(cap.isOpened()): ret, frame = cap.read() #LeapMotionの挙動 f = controller.frame() #LeapMotionに手をかざしてないとき if f.hands.is_empty: #LeapMotionに手をかざしたとき if not f.hands.is_empty: cv2.imshow("frame",frame) # カメラ画像を表示 # qキーが押されたら途中終了 if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() # カメラを解放 cv2.destroyAllWindows() # ウィンドウを消す
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。