Python (Ubuntu)

This topic introduces how to run the Python samples on Ubuntu.

Sample List

Samples are divided into 5 categories, Basic, Advanced, Util, Laser and UHP.

  • Basic: camera connection and basic capturing functions.

  • Advanced: advanced capturing functions.

  • Util: obtain information from a camera and set camera parameters.

  • Laser: for the Laser, DEEP and LSR series cameras only.

  • UHP: for the UHP series cameras only.

The samples in each category and their descriptions are provided below.

  • ConnectToCamera: Connects to a camera.

  • ConnectAndCaptureImage: Connects to a camera and obtains the 2D image, depth map and point cloud data.

  • CaptureColorMap: Obtains and saves the 2D image from a camera.

  • CaptureDepthMap: Obtains and saves the depth map from a camera.

  • CapturePointCloud: Obtains and save untextured and textured point clouds generated from images captured with a single exposure time.

  • CaptureHDRPointCloud: Obtains and save untextured and textured point clouds generated from images captured with multiple exposure times.

  • CapturePointCloudROI: Obtains and save untextured and textured point clouds of the objects in the ROI from a camera.

  • CapturePointCloudFromTextureMask: Constructs and saves untextured and textured point clouds generated from a depth map and masked 2D image.

  • GetCameraIntri: Gets and prints a camera’s intrinsic parameters.

  • PrintDeviceInfo: Gets and prints a camera’s information such as model, serial number, firmware version and temperatures.

  • SetDepthRange: Sets the range of depth values to be retained by a camera.

  • SetParameters: Sets specified parameters to a camera.

  • SetUserSets: Performs functions related to parameter groups, such as obtaining the names of all available parameter groups, selecting a parameter group, and saving the parameter values to the current parameter group. The parameter group feature allows user to save and quickly apply a set of parameter values.

  • SetLaserFramePartitionCount: Divides the projector FOV into partitions and project structured light in one partition at a time. The output of the entire FOV is composed from images of all partitions.

  • SetLaserFrameRange: Sets the projection range of the structured light. The entire projector FOV is from 0 to 100.

  • SetLaserFringeCodingMode: Sets the coding mode of the structured light pattern.

  • SetLaserPowerLevel: Sets the output power of the laser projector in percentage of max power. This affects the intensity of the laser light.

  • SetUHPCaptureMode: Sets the capture mode (capture images with 2D camera 1, with 2D camera 2, or with both 2D cameras and compose the outputs).

  • SetUHPFringeCodingMode: Sets the coding mode of the structured light pattern.

The following samples require third-party libraries to be installed (instructions provided below):

Samples open3d opencv-python









  1. Connect the camera and computer correctly.

  2. Make sure that the version of Python installed is between 3.6.5 and 3.10.

  3. Download and install the latest version of Mech-Eye SDK.

  4. (Optional) Install OpenCV.

    sudo apt-get install libopencv-dev
    sudo apt-get install python3-opencv
  5. (Optional) Install Open3D.

    sudo pip install open3d


Install Required Software

  1. Install pip.

    sudo apt install python3-pip

    If you have already installed pip, please make sure that the version of pip is 20.3 or above. Use the following command to upgrade pip:

    python3 -m pip install --upgrade pip
  2. Install Mech-Eye API.

    sudo pip3 install MechEyeApi

Run Samples

  1. Download the samples.

    cd ~
    git clone
  2. Open a sample folder and run the sample (taking as an example).

    cd ~/mecheye_python_samples/source/Basic
    sudo python3

    You will be prompted to enter the index of the camera that you want to connect:

    Find Mech-Eye device...
    Mech-Eye device index : 0
    Camera Model Name: Mech-Eye Pro M Enhanced
    Camera ID:         NEC15221A3000001
    Camera IP Address: 192.168.xx.xx
    Hardware Version:  Vx.x.x
    Firmware Version:  Vx.x.x
    Please enter the device index you want to connect: 0

    Please enter the index and press Enter to confirm. Below is an example of the full output of (0 is entered for the index):

    Connected to the Mech-Eye device successfully.
    Disconnected from the Mech-Eye device successfully.
  • For samples that involve point cloud acquisition, a regular user is unable to write point cloud files, so please use the sudo command to run the sample as the admin.

  • For samples that involve image and point cloud acquisition, when the sample execution is complete, the image and point cloud data is by default saved to the folder of the sample.

When writing your own program, use the import command to import Mech-Eye API first, and import Mech-Eye API before importing Open3D:

import MechEye
import open3d