Ich bin derzeit dabei mit tkinter, opencv und mit Media Pipe Framework zu arbeiten. Dabei möchte ich Bilder Hochladen können und die hochgeladenen Bilder soll mithilfe von Mediapipe die Hand Landmarks erfassen. Mit Hand Landmarks meine ich alle 21 Positionen eines Hand zu erkennen (Hier findet ihr mehr Infos dazu: https://google.github.io/mediapipe/solutions/hands.html ). Leider bekomme ich mit meiner erstellten Implementierung folgende Fehlermeldung:
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:/Users/bj/projects/pro1/pictureMp.py", line 31, in imageLandmarks
height, width, _ = image.shape
AttributeError: 'PhotoImage' object has no attribute 'shape'
Was kann ich dagegen machen? Hier ist mein aktueller Code:
def imageLandmarks():
global panelA
with mpHands.Hands(static_image_mode=True, max_num_hands=2, min_detection_confidence=0.5) as hands:
select_image.path = filedialog.askopenfilename()
filename = os.path.basename(select_image.path)
if len(select_image.path) > 0:
image = cv2.imread(select_image.path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = Image.fromarray(image)
image = ImageTk.PhotoImage(image)
height, width, _ = image.shape
results = hands.process(image)
num_cords = 21
landmarks = ['class']
for val in range(1, num_cords + 1):
landmarks += ['x{}'.format(val), 'y{}'.format(val), 'z{}'.format(val)]
if results.multi_hand_landmarks:
for num, hand in enumerate(results.multi_hand_landmarks):
mpDraw.draw_landmarks(image, hand, mpHands.HAND_CONNECTIONS)