4. Python

This section will show you how to run a Python sample in Windows.

4.1. 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 series cameras only.

  • UHP: for UHP series cameras only.

4.2. Requirements

  1. Download and install Mech-Eye SDK

  2. Download or clone Python samples

  3. Make sure that the Python you installed is version 3.6.8 or above

  4. Connect to a real camera that functions properly

4.3. Instructions

4.3.1. Setting up Python

Press Win + R on the keyboard to open Run box. Type “PowerShell” and then press Ctrl+Shift+Enter to run PowerShell as Administrator.

  • Compulsory: MechEyeAPI 。

    pip install MechEyeAPI
    

    If an error occurs, please enter the command as below:

    pip install MechEyeAPI -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
    
  • Optional: open3d, opencv-python, opencv-contrib-python 。

Samples

open3d

opencv-python

opencv-contrib-python

CaptureColorMap

CaptureDepthMap

CapturePointCloud

CaptureHDRPointCloud

CapturePointCloudROI

CaptureCloudFromDepth

pip install opencv-python
pip install opencv-contrib-python

Attention

The version of opencv-python should be the same as that of opencv-contrib-python.

4.3.2. Run Sample Program

The example below shows how to run CaptureColorMap.py.

  1. Navigate to the directory where CaptureColorMap.py is located.

    cd  XXX\mecheye_python_samples/source/Basic
    
  2. Run the sample.

    python.exe CaptureColorMap.py
    
  3. After running the program, you will get colorMap in samples directory.

    ../../../_images/python_color.png