VisionPro
This topic introduces how to use the VisionPro sample provided by Mech-Mind to connect to the camera and obtain 2D and 3D data through C# Mech-Eye API.
Sample List
The following sample is currently provided:
AcquireColorAndRangeImages: Obtain 2D and depth data and generate the Cognex-format 2D image (CogImage24PlanarColor) and depth map (CogImage16Range).
Prerequisites
In order to use the VisionPro sample, the following prerequisites must be satisfied:
-
Obtain the sample.
-
Install the required software.
Obtain Sample
VisionPro sample is included in the installation path of Mech-Eye SDK or can be obtained from GitHub by cloning. The sample in the installation path is the version at the time of Mech-Eye SDK release. The version on GitHub may contain the latest changes.
-
The sample in the installation path is located in xxx/Mech-Eye SDK-2.2.2/API/samples/visionpro/area_scan_3d_camera.
-
The sample cloned from GitHub is located in xxx/mecheye_visionpro_samples/area_scan_3d_camera.
Install Required Software
In order to use the VisionPro sample, Mech-Eye SDK and VisionPro must be installed.
-
Mech-Eye SDK: Install the latest version or upgrade according to Mech-Eye SDK Installation Guide.
-
Cognex VisionPro: Version 9.8 SR1 has been tested.
Configure and Run Sample
The sample can be run after the necessary configurations are completed.
Copy Dynamic-Link Libraries
To call Mech-Eye API in VisionPro, the dynamic-link libraries of Mech-Eye SDK must be copied to the installation path of VisionPro first.
Follow these steps to copy the dynamic-link libraries:
-
Go to the installation path of Mech-Eye SDK and open the following folder: xxx/Mech-Eye SDK-2.2.2/API/dll.
-
Copy the following dynamic-line library files (.dll) in the above folder:
-
MechEyeApi
-
MechEyeAPiNet
-
MechEyeApiWrapper
-
-
Go to the installation path of VisionPro, open the bin folder, and paste the copied dynamic-link library files.
Configure Referenced Assembly of Script
After copying the dynamic-link libraries, you need to configure the path of the referenced assembly in the script of the sample.
Follow these steps to configure the referenced assembly:
-
Open VisionPro QuickBuild and select Open QuickBuild Application in the File menu.
-
In the pop-up window, select the VisionPro sample to be used, and click the Open button.
-
The following window will pop-up. Click the No button in the window to close it.
-
The following window may pop-up. If it pops up, click the OK button in the window to close it.
-
In the left panel of VisionPro QuickBuild, double-click Mech-Eye Industrial 3D Camera.
-
In the left panel of the popped up Job Editor window, double-click Image Acquisition.
-
In the toolbar of the popped up Image Acquisition window, click the button.
-
In the toolbar of the popped up Image Acquisition Script window, click the button.
-
In the popped up Add / Remove Referenced Assemblies window, scroll down to the bottom and double-click the MechEyeApiNet.dll row.
-
In the popped up Enter Assembly Name window, click the Browse...… button, navigate to the folder where the dynamic-link libraries are located in the Mech-Eye SDK installation path (xxx/Mech-Eye SDK-2.2.2/API/dll), and select the MechEyeApiNet dynamic-link library file.
-
Click the OK button in the Enter Assembly Name window to close it, and then click the OK button in the Add / Remove Referenced Assemblies window to close it.
Set Camera IP Address
Before running the sample, you need to set the IP address of the camera in the script, so that the camera can be successfully connected.
You can modify the IP address of the camera using Mech-Eye Viewer or the IP configuration tool. |
Follow these steps to set the IP address of the camera:
-
In the Image Acquisition Script window, locate the following line and change the IP address in it to the actual IP address of the camera to be connected.
status = camera.Connect("192.168.20.15", 10000)
-
Click the button in the toolbar to make the change take effect.
-
Close the Image Acquisition Script and Image Acquisition windows to return to the Job Editor window.
Run Sample
Follow these steps to run the sample and view the obtained 2D image and depth map:
-
In the toolbar of the Job Editor window, click the button to run the sample.
-
In the left panel, double-click the corresponding tool to view the obtained 2D image or depth map:
-
2D image: Double-click CogAffineTransformTool1.
-
Depth map: Double-click Cog3DVisionDataReRenderTool1.
-
-
If the obtained images do not meet your requirements, refer to the next section and adjust the camera parameters to improve the quality of the data.
Adjust Camera Parameters
The camera parameters can be adjusted in Mech-Eye Viewer or in the sample through C# Mech-Eye API. It is recommended to use Mech-Eye Viewer to adjust parameters, as it provides a graphical user interface where you can acquire data immediately after adjusting the parameters to see the effect.
-
Adjust parameters using Mech-Eye Viewer: Please refer to How to Use for instructions on connecting to the camera, acquiring data, viewing current parameter values, and adjusting parameters in Mech-Eye Viewer.
-
Adjust parameters in the sample through C# Mech-Eye API: To adjust the camera parameters in the sample, you need to add the corresponding methods of C# Mech-Eye API to the script of the sample. Please refer to the following contents and edit the script of the sample.
-
C# Mech-Eye API samples: Refer to C# for an overview of the available samples, where to obtain them, and how to use them.
-
Mech-Eye API Reference: Explanations of the methods in C++ Mech-Eye API are provided here.
-