Table of Contents

Function Definition: video(video_state = "on", transparency = 1)

Parameters

NameTypeDescriptionExpected ValuesDefault Value
video_statestringSet the state of the camera feed on the stage to the specified state."on", "off", or "on flipped""on"
transparencyintSet the transparency of the video on the stage.0-1001

Description

This function helps turn the video on/off on the stage with a defined level of transparency.

  • On, the default option turns the video on, off switches it off, and on flipped turns on the camera feed, but flipped.
  • The transparency percentage can be set by entering a numeric value as an argument.

Example

The example demonstrates how to use human body detection to track the nose and make someone clown.

Code

sprite = Sprite('Ball')
pose = Posenet()

pose.video("on", 0)
pose.enablebox()

while True:
  pose.analysestage()
  
  if (pose.isdetected(0, 1)):
    sprite.setx(pose.x(0, 1))
    sprite.sety(pose.y(0, 1))
    sprite.show()
  
  else:
    sprite.hide()

Output

Read More
The example demonstrates how to use hand recognition to track the different parts of the fingers in Python Coding Environment.

Code

thumb = Sprite('Thumb')
index = Sprite('Index')
middle = Sprite('Middle')
ring = Sprite('Ring')
pinky = Sprite('Pinky')

hand = Posenet()
hand.video("on", 0)
hand.enablebox()

thumb.switchcostume("ball-a")
thumb.setsize(50)
index.switchcostume("ball-b")
index.setsize(50)
middle.switchcostume("ball-c")
middle.setsize(50)
ring.switchcostume("ball-d")
ring.setsize(50)
pinky.switchcostume("ball-e")
pinky.setsize(50)

while True:
  hand.analysehand()
  
  if hand.ishanddetected():
    thumb.setx(hand.gethandposition(1, 4))
    thumb.sety(hand.gethandposition(2, 4))
    thumb.show()
    
    index.setx(hand.gethandposition(1, 8))
    index.sety(hand.gethandposition(2, 8))
    index.show()
    
    middle.setx(hand.gethandposition(1, 12))
    middle.sety(hand.gethandposition(2, 12))
    middle.show()
    
    ring.setx(hand.gethandposition(1, 16))
    ring.sety(hand.gethandposition(2, 16))
    ring.show()
    
    pinky.setx(hand.gethandposition(1, 20))
    pinky.sety(hand.gethandposition(2, 20))
    pinky.show()
  
  else:
    thumb.hide()
    index.hide()
    middle.hide()
    ring.hide()
    pinky.hide()

Output

Read More
All articles loaded
No more articles to load