代码拉取完成,页面将自动刷新
同步操作将从 XCZJust/人机交互期末项目 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import cv2
import mediapipe as mp
import pandas as pd
import os
import numpy as np
def image_processed(file_path):
# reading the static image
hand_img = cv2.imread(file_path)
# Image processing
# 1. Convert BGR to RGB
img_rgb = cv2.cvtColor(hand_img, cv2.COLOR_BGR2RGB)
# 2. Flip the img in Y-axis
img_flip = cv2.flip(img_rgb, 1)
# accessing MediaPipe solutions
mp_hands = mp.solutions.hands
# Initialize Hands
hands = mp_hands.Hands(static_image_mode=True,
max_num_hands=2, min_detection_confidence=0.7)
# Results
output = hands.process(img_flip)
hands.close()
try:
data = output.multi_hand_landmarks[0]
data = str(data)
data = data.strip().split('\n')
garbage = ['landmark {', ' visibility: 0.0', ' presence: 0.0', '}']
without_garbage = []
for i in data:
if i not in garbage:
without_garbage.append(i)
clean = []
for i in without_garbage:
i = i.strip()
clean.append(i[2:])
for i in range(0, len(clean)):
clean[i] = float(clean[i])
return([clean])
except:
return(np.zeros([1,63], dtype=int)[0])
def make_csv():
mypath = 'RESIZED_DATASET'
file_name = open('dataSet/final_datasetBSL.csv', 'a')
for each_folder in os.listdir(mypath):
if '._' in each_folder:
pass
else:
for each_number in os.listdir(mypath + '/' + each_folder):
if '._' in each_number:
pass
else:
label = each_folder
file_loc = mypath + '/' + each_folder + '/' + each_number
data = image_processed(file_loc)
try:
for i in data[0]:
file_name.write(str(i))
file_name.write(',')
file_name.write(label)
file_name.write('\n')
except:
file_name.write('-1')
file_name.write(',')
file_name.write('None')
file_name.write('\n')
file_name.close()
print('Data Created !!!')
if __name__ == "__main__":
make_csv()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。