Internal - LIPS Developer Documentation
  • WELCOME
    • LIPS® Developer Documentation
  • INSTALLATION & SETUP
    • LIPSedge™ AE400 / AE450
      • SDK Release
        • Firmware
        • SDK
        • User Guide
      • Installation
        • Linux
        • Windows
        • ROS Wrapper
        • NVIDIA ISAAC Wrapper
    • LIPSedge™ AE430 / AE470
      • Installation
        • Linux
        • Windows
    • LIPSedge™ DL & M3 Series
      • SDK Release
      • Installation
        • Ubuntu
        • Windows
    • LIPSFace™ HW110/115 On-Device 3D Facial Recognition
      • User Guide & SDK Download
    • LIPSFace™ HW120/125 On-Device 3D Facial Recognition
    • LIPSMetric™ HA110 Handheld Dimensioner
      • User Guide
    • LIPSMetric™ ST115 Static Dimensioner
      • User Manual
  • SDK CODE SAMPLES AND LANGUAGES WRAPPERS
    • LIPSedge™ SDK
      • Sample Applications & Viewer & Utilities
      • C++
        • ni-hello
        • ni-simple-read
      • Python
        • ni-hello
        • ni-simple-read
      • Java
        • ni-hello
      • C#
      • OpenCV
      • ROS
    • LIPSFace™ SDK
      • LIPSFace™ SDK Overview
      • LIPSFace™ SDK Developer Guide
Powered by GitBook
On this page
  • Overview
  • Expect Output
  • Tutorial
  • Full code
  1. SDK CODE SAMPLES AND LANGUAGES WRAPPERS
  2. LIPSedge™ SDK
  3. Python

ni-simple-read

Overview

This example demonstrate how to get the distance (depth) value from camera for a specific point

Expect Output

...
Distance is      492 mm
Distance is      495 mm
Distance is      497 mm
Distance is      499 mm
Distance is      503 mm
Distance is      505 mm
Distance is      511 mm
...

Tutorial

  • Import openni package

from openni import openni2
  • Initialize SDK

openni2.initialize()
  • Connect to camera

dev = openni2.Device.open_any()
  • Create depth stream and start it

depth_stream = dev.create_depth_stream()
depth_stream.start()
  • Depth data is store in one dimension array in ordered, from top left to bottom right. We calculate the index of the center point of the frame according to the width and height first.

video_mode = depth_stream.get_video_mode()
middleIndex = int((video_mode.resolutionY + 1) * video_mode.resolutionX / 2)
  • Read frame from camera and retrieve the depth data of middleIndex

frame = depth_stream.read_frame()
pDepth = frame.get_buffer_as_uint16()
print(f'''Distance is {pDepth[middleIndex]} mm''')

Full code

Previousni-helloNextJava

Last updated 2 years ago

ni-simple-read.py