LIPS® Developer Documentation
  • WELCOME
    • LIPS® Developer Documentation
    • About 3D Depth Cameras
    • Depth Image
    • Understanding Depth
    • An Ideal Depth Camera
    • LIPSedge™ AE Series Camera Selection Guide
  • LIPSedge™ SDK 1.x
    • LIPSedge™ SDK 1.x
    • Benefits from LIPSedge™ SDK implementation
    • LIPSedge™ SDK 1.x Installation Architecture
    • How to identify each camera SDK
    • New Features for v1.02
      • Installing and identifying packages on Windows
      • Saving Captures and Videos with the DepthViewer
      • Saving Point Cloud with PointCloudViewer
      • Live On-Screen displaying Depth, FPS
      • Live On-Screen displaying XYZ parameters in RawfileViewer
      • Distance measurement on-screen from point-to-point
      • Mouse Pointer Change
      • LIPSedge™ AE and S series Colormap new feature addition
      • Simple naming for LIPSedge™ SDK Tools
      • Importing parameters from .json files for LIPSedge™ AE and S series
    • LIPSedge™ SDK v1.02 Tools
      • DepthViewer
      • PointCloudViewer
      • CameraParameterViewer
      • CameraCenterViewer
      • CameraEventListener
      • CameraPowerTest
      • LensModeSelector
      • LIPSImuReader
      • CameraSimpleViewer
      • RawFileViewer
    • Features Articles
      • LIPSedge™ SDK Persistent Connection for PoE and USB
    • Tutorials
    • Development and Deployment on arm64
  • DOCUMENTS, INSTALLATION & SETUP
    • LIPSedge™ AE400 / AE450
      • User Guide
        • Previous Releases (Archive)
      • SDK Release
        • Previous Releases (Archive)
      • Installation
        • Linux
        • Windows
        • ROS Wrapper
        • NVIDIA ISAAC Wrapper
        • Persistent Connection
      • STEP files for CAD Use
      • Certifications Documents
      • Firmware
    • LIPSedge™ AE430 / AE470
      • User Guide
        • Previous Releases (Archive)
      • SDK Release
        • Previous Releases (Archive)
      • Firmware
      • STEP files for CAD Use
    • LIPSedge™ AE430-DK / AE470-DK
      • User Guide
    • LIPSedge™ DL & M3 Series
      • User Guide
        • Previous Releases (Archive)
      • SDK Release
        • Previous Releases (Archive)
        • Changelog
      • STEP files for CAD Use
      • Installation
        • Ubuntu
        • Windows
    • LIPSedge™ L215u / L210u
      • User Guide
        • Previous Releases (Archive)
      • SDK Release
        • Previous Releases (Archive)
        • Changelog
      • Installation
        • Windows
        • Linux
      • STEP files for CAD Use
    • LIPSFace™ HW110/115 On-Device 3D Facial Recognition
      • User Guide & SDK Download
      • STEP files for CAD Use
    • LIPSFace™ HW120/125 On-Device 3D Facial Recognition
      • User Guide
      • SDK
      • STEP files for CAD Use
    • LIPScan 3D ™ Middleware
      • LIPScan 3D™ SDK
        • SDK Download
          • Previous Releases
        • User Guide
        • Release Notes
    • LIPSMetric™ HA110 Handheld Dimensioner
      • User Guide
    • LIPSMetric™ ST115 Static Dimensioner
      • User Guide
    • LIPSMetric™ ST130 Pallet Dimensioner
      • User Guide
  • LIPSedge™ SDK Languages & Libraries
    • C++
      • environment-setup
      • hello-lipsedge-sdk
      • opencv-viewer
      • roi
      • depth-data
      • align-depth-color
      • range-filter
      • remove-background
      • record
      • pointcloud
      • config-resolution
      • camera-parameter
    • Python
      • environment-setup
      • hello-lipsedge-sdk
      • opencv-viewer
      • roi
      • depth-data
      • align-depth-color
      • range-filter
      • remove-background
      • record
    • Java
      • ni-hello
    • C#
      • ni-hello
      • simple-read
    • OpenCV
  • LIPSedge™ SDK Frameworks
    • GenICam (for Halcon / Aurora Vision)
      • User Manual
      • Driver(.cti) and Nodemap (.xml)
      • Supported LIPSedge™ Camera SDK
      • Installation Example
    • ROS
    • ROS2
    • NVIDIA Isaac Wrapper
    • Flutter
  • LIPSedge™ SDK Sample Codes
    • Sample Applications & Viewer & Utilities
      • ni-viewer
      • ni-pointcloud-gl
      • ni-camera-matrix
  • LIPSFace™ SDK
    • LIPSFace™ SDK Overview
    • Updates
Powered by GitBook
On this page
  • Overview
  • Expect Output
  • Tutorial - C++
  • Tutorial - Python
  • Full code
  1. LIPSedge™ SDK Languages & Libraries

OpenCV

Previoussimple-readNextLIPSedge™ SDK Frameworks

Last updated 2 years ago

Overview

This article shows how to convert OpenNI2 video frames to OpenCV Mat format. Once you have frame in Mat format, you can leverage all OpenCV functions.

Expect Output

Tutorial - C++

  • After connect to camera and start each sensor (color, depth and IR). Read the frame into VideoFrameRef

VideoFrameRef colorFrame;
VideoFrameRef depthFrame;
VideoFrameRef irFrame;

color.readFrame(&colorFrame);
depth.readFrame(&depthFrame);
ir.readFrame(&irFrame);
  • Convert VideoFrameRef to cv::Mat

// Color frame
cv::Mat colorMat = cv::Mat(colorFrame.getHeight(), colorFrame.getWidth(), CV_8UC3, (void *)colorFrame.getData());

// Depth frame
cv::Mat depthMat = cv::Mat(depthFrame.getHeight(), depthFrame.getWidth(), CV_16UC1, (void *)depthFrame.getData());

// IR frame
cv::Mat irMat = cv::Mat(irFrame.getHeight(), irFrame.getWidth(), CV_16UC1, (void *)irFrame.getData());
  • For better visualization, you can do the following conversion

// For color frame
cv::cvtColor(colorMat, colorMat, cv::COLOR_BGR2RGB);

// For depth frame
depthMat.convertTo(depthMat, CV_8U, 255.0 / 1024.0);
cv::applyColorMap(depthMat, depthMat, cv::COLORMAP_JET);

// For IR frame
irMat.convertTo(irMat, CV_8U, 255.0 / 1024.0);

Tutorial - Python

  • After connect to camera and start each sensor (color, depth and IR). Read the video frames

colorFrame = colorStream.read_frame()
depthFrame = depthStream.read_frame()
irFrame = irStream.read_frame()
  • Convert video frame to OpenCV format which is numpy array

# Color frame
colorMat = np.fromstring(colorFrame.get_buffer_as_uint8(), dtype=np.uint8).reshape(480, 640, 3)

# Depth frame
depthMat = np.fromstring(depthFrame.get_buffer_as_uint16(), dtype=np.uint16).reshape(480, 640)

# IR frame
irMat = np.fromstring(irFrame.get_buffer_as_uint16(), dtype=np.uint16).reshape(480, 640)
  • For better visualization, you can do the following conversion

# For color frame
colorMat = cv2.cvtColor(colorMat, cv2.COLOR_BGR2RGB)

# For depth frame
depthMat = np.uint8(depthMat.astype(float) * 255 / 1024)
depthMat = cv2.applyColorMap(depthMat, cv2.COLORMAP_JET)

# For IR frame
irMat = np.uint8(irMat.astype(float) * 255 / 1024)

Full code

C++
Python