4. Python¶
This section will show you how to run a Python sample in Windows.
4.1. Sample List¶
Samples are divided into four categories, Basic, Advanced, Util and Laser.
Basic
ConnectToCamera: connect to a camera.
ConnectAndCaptureImage: connect to a camera and capture color images and depth maps.
CaptureColorMap: capture color images from a camera.
CaptureDepthMap: capture depth maps from a camera.
CapturePointCloud: capture point clouds from a camera.
CaptureHDRPointCloud: capture point clouds in HDR mode from a camera.
CapturePointCloudROI: set an ROI and capture point clouds from a camera.
Advanced
CaptureCloudFromDepth: generate point clouds from depth maps and color images.
CaptureTimedAndPeriodically: capture images periodically for a specified length of time.
CaptureSimultaneouslyMultiCamera: capture images from multiple cameras simultaneously.
CaptureSequentiallyMultiCamera: capture images from multiple cameras sequentially.
Util
GetCameraIntri: obtain and print the intrinsic parameters of the camera.
PrintDeviceInfo: print version information of Mech-Eye SDK and the camera firmware.
SetDepthRange: set the depth range of a camera.
SetUserSets: provide functions related to parameter groups, such as switching to a different parameter group, adding and deleting parameter groups, etc.
SetParameters: provide functions related to camera parameters, including all the functions of SetUserSets.
Laser
SetLaserFramePartitionCount: set the laser scan partition number for a laser camera.
SetLaserFrameRange: set the field of view for a laser camera.
SetLaserFringeCodingMode: set the fringe coding mode for a laser camera.
SetLaserPowerLevel: set the power level for a laser camera.
4.2. Requirements¶
Make sure that the Python you installed is version 3.6.8 or above
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.
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.