Python¶
This section will show you how to run a Python sample in Windows.
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.
Basic
ConnectToCamera: Connect to a Mech-Eye Industrial 3D Camera.
ConnectAndCaptureImage: Connect to a camera and obtain the 2D image, depth map and point cloud data.
CaptureColorMap: Obtain and save the 2D image from a camera.
CaptureDepthMap: Obtain and save the depth map from a camera.
CapturePointCloud: Obtain and save untextured and textured point clouds generated from images captured with a single exposure time.
CaptureHDRPointCloud: Obtain and save untextured and textured point clouds generated from images captured with multiple exposure times.
CapturePointCloudROI: Obtain and save untextured and textured point clouds of the objects in the ROI from a camera.
CapturePointCloudFromTextureMask: Construct and save untextured and textured point clouds generated from a depth map and masked 2D image.
Advanced
CaptureCloudFromDepth: Construct and save point clouds from the depth map and 2D image obtained from a camera.
CaptureSequentiallyMultiCamera: Obtain and save 2D images, depth maps and point clouds sequentially from multiple cameras.
CaptureSimultaneouslyMultiCamera: Obtain and save 2D images, depth maps and point clouds simultaneously from multiple cameras.
CaptureTimedAndPeriodically: Obtain and save 2D images, depth maps and point clouds periodically for the specified duration from a camera.
Util
GetCameraIntri: Get and print a camera’s intrinsic parameters.
PrintDeviceInfo: Get and print a camera’s information such as model, serial number, firmware version and temperatures.
SetDepthRange: Set the range of depth values to be retained by a camera.
SetParameters: Set specified parameters to a camera.
SetUserSets: Perform functions related to parameter groups, such as switching to a different parameter group, adding and deleting parameter groups, etc. The parameter group feature allows user to save and quickly apply a set of parameter values.
Laser
SetLaserFramePartitionCount: Divide 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: Set the projection range of the structured light. The entire projector FOV is from 0 to 100.
SetLaserFringeCodingMode: Set the coding mode of the structured light pattern.
SetLaserPowerLevel: Set the output power of the laser projector in percentage of max power. This affects the intensity of the laser light.
UHP
SetUHPCaptureMode: Set the capture mode (capture images with camera 1, with camera 2, or with both 2D cameras and compose the outputs).
SetUHPFringeCodingMode: Set the coding mode of the structured light pattern.
Requirements¶
Download samples from GitHub: select .
Make sure that the version of Python installed is between 3.6.5 and 3.10
Attention
If Add Python to PATH was not selected during installation, please add the following two directories to the Path environment variable:
xxx\AppData\LocalProgramsPython\Python36\
xxx\AppData\LocalProgramsPython\Python36\Scripts\
Instructions¶
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.
Required: 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 and opencv-python.
Samples |
open3d |
opencv-python |
CaptureColorMap |
√ |
|
CaptureDepthMap |
√ |
|
CapturePointCloud |
√ |
|
CaptureHDRPointCloud |
√ |
|
CapturePointCloudROI |
√ |
|
CapturePointCloudFromTextureMask |
√ |
|
CaptureCloudFromDepth |
√ |
pip install opencv-python
Run Sample Program¶
The example below shows how to run CaptureColorMap.py.
Navigate to the directory where CaptureColorMap.py is located.
cd xxx\mecheye_python_samples\source\Basic
Run the sample.
python.exe CaptureColorMap.py
After running the program, you will get colorMap in samples directory.