Table of Contents

xpos()

Function Definition: xpos(landmark_name = "center")

Parameters

NameTypeDescriptionExpected ValuesDefault Value
landmark_namestringThe landmark name for which the X position is required."center", "toprightcorner", "topleftcorner", "bottomrightcorner", "bottomleftcorner", "toprightfinderpattern", "topleftfinderpattern", "bottomleftfinderpattern""center"

Description

The function returns the X position of the specified landmark points of the QR code:

  1. center – Center
  2. toprightcorner – Top Right Corner
  3. topleftcorner – Top Left  Corner
  4. bottomrightcorner – Bottom Right Corner
  5. bottomleftcorner – Bottom Left  Corner
  6. toprightfinderpattern – Top Right Finder Pattern
  7. topleftfinderpattern – Top Left Finder Pattern
  8. bottomleftfinderpattern – Bottom Left Finder Pattern

Example

The example demonstrates how to make a QR Code reader in the Python Coding Environment.

Code

sprite = Sprite('Square Box')
qr = QRCodeScanner()

qr.video("on flipped", 0)
qr.disablebox()

while True:
  qr.analysecamera()
  if qr.isdetected():
    sprite.setx(qr.xpos("center"))
    sprite.sety(qr.ypos("center"))
    sprite.setdirection(qr.angle())
    sprite.say(qr.codedata())
    sprite.show()
  else:
    sprite.hide()

Output

Read More
All articles loaded
No more articles to load