Python (Ubuntu)

This section describes how to run Python samples on Ubuntu.

Sample List

Samples are divided into five 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 Laser, LSR and DEEP series cameras only.

  • UHP: for UHP series cameras only.

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

Samples

open3d

opencv-python

CaptureColorMap

CaptureDepthMap

CapturePointCloud

CaptureHDRPointCloud

CapturePointCloudROI

CapturePointCloudFromTextureMask

CaptureCloudFromDepth

Requirements

  1. Connect a functioning camera.

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

  3. Download and install 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
    

Instructions

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 MechEyeApi:

    sudo pip3 install MechEyeApi
    

Run the Sample

  1. Download the samples:

    cd ~
    git clone https://github.com/MechMindRobotics/mecheye_python_samples.git
    
  2. Open a sample folder and run the sample (taking ConnectToCamera.py as an example):

    cd ~/mecheye_python_samples/source/Basic
    sudo python3 ConnectToCamera.py
    

    For ConnectToCamera, you will be prompted to enter the index of the camera that you want to connect:

    Please enter the device index you want to connect:
    

    Please enter the index and press Enter to confirm.

    Below is an example of the full output of ConnectToCamera.py (0 is entered for the index):

    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
    Connected to the Mech-Eye device successfully.
    Disconnected from the Mech-Eye device successfully.
    

Attention

  • For samples that involve point cloud capturing, 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 capturing, when the sample execution is complete, the image and point cloud data is by default saved to the folder of the sample.

Note

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

python3
import MechEye