Python (Windows)

You are viewing an old version of the documentation. You can switch to the documentation of the latest version by clicking the top-right corner of the page.

This topic introduces how to obtain and run the Mech-Eye API Python samples on Windows.

Sample List

The following samples are currently provided:

  • acquire_profile_data: Acquire the profile data, generate the intensity image and depth map, and save the images.

  • acquire_profile_data_using_callback: Acquire the profile data using a callback function, generate the intensity image and depth map, and save the images.

  • acquire_point_cloud: Acquire the profile data, generate the point cloud, and save the point cloud in the CSV and PLY formats.

  • manage_user_sets: Manage parameter groups, such as obtaining the names of all parameter groups, adding a parameter group, switching the parameter group, and saving parameter settings to the parameter group.

  • register_profiler_event: Define and register the callback function for monitoring the laser profiler connection status.

Prerequisites

In order to use the Python samples of Mech-Eye API, the following prerequisites must be satisfied:

  • Connect the laser profiler and computer correctly.

  • Make sure that the variant of Python installed is 64-bit, and that the version is between 3.7 and 3.11.

    If Add Python to PATH was not selected during installation, please add the following two paths to the Path environment variable:

    • xxx/AppData/LocalProgramsPython/Python36/

    • xxx/AppData/LocalProgramsPython/Python36/Scripts/

  • Obtain the samples.

  • Install the required software.

  • (Optional) Install software libraries on which the samples depend.

Obtain Samples

Python samples are included in the installation path of Mech-Eye SDK or can be obtained from GitHub by cloning. The samples in the installation path are the version at the time of Mech-Eye SDK release. The version on GitHub may contain the latest changes.

  • The samples in the installation path are located in xxx/Mech-Eye SDK-2.2.2/API/samples/python/profiler.

  • The samples cloned from GitHub are located in xxx/mecheye_python_samples/profiler.

Install Required Software

In order to use the Python samples of Mech-Eye API, Mech-Eye SDK and Python Mech-Eye API must be installed.

Install the Latest Version of Mech-Eye SDK

Please install or upgrade Mech-Eye SDK according to Mech-Eye SDK Installation Guide.

Install the Latest Version of Python Mech-Eye API

Follow these steps to install the latest version of Python Mech-Eye API:

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

  2. Execute the following command to install Python Mech-Eye API:

    pip install MechEyeAPI

(Optional) Install Dependent Software Libraries

Some samples contain functions that depend on OpenCV. If you need to use the samples listed in the table below, OpenCV must be installed (latest version recommended).

  • AcquireProfileData

  • AcquireProfileDataUsingCallback

Execute the following command to install the latest version of OpenCV:

pip install opencv-python

Run Samples

The paths provided in this section correspond to the samples included in the installation path. If you are using the samples cloned from GitHub, please modify the paths correspondingly.

Follow these steps to run the samples:

  1. Navigate to the folder where a sample is located.

    cd xxx/Mech-Eye SDK-2.2.2/API/samples/python/profiler
  2. Run the sample: replace sample_name with the name of the sample. While the sample is running, input the index of the laser profiler to which you want to connect according to the instruction, and press Enter to connect to the laser profiler.

    python sample_name.py
  3. If image and/or point cloud files are saved by the sample, you can find the files in the folder where the sample is located.

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.