I am toying with the idea of using MediaPipe for hand tracking and use that for drawing GreasePencil strokes.

The hand-tracking part is quite well documented, but how would I then relate that to positions on the screen?

And now that I think of it, it could probably lend itself to other cases as well.


1 Answer 1


I don't know anything about your hand tracking system inputs. But few basic guidance below about grease pencil object creation.

import bpy

name='hand track'

# Create a new gp data, 
# link it to an object 
# and link the object to the scene
hand_track = bpy.data.grease_pencils.new(name)
obj = bpy.data.objects.new(name, hand_track)

# Create a new layer, 
# new frame 
# and new stroke
layer = hand_track.layers.new(name)
frame = layer.frames.new(0)
stroke = frame.strokes.new()

# Simulate capture of 10 hand positions 
for i in range(10):
    # get the index of the point we'll add below (index of the last)
    index = len(stroke.points)
    # Add a stroke point
    # Set it to the wanted position
    stroke.points[index].co = (i, 0, 0)

# Set the object as selected, active and update the scene
bpy.context.view_layer.objects.active = obj

(A lot) more details in the documentation.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .