2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Mech Mind's structured light cameras, especially the Mech-Eye series, are industrial-grade, high-precision 3D cameras that are widely used in industrial automation, robot navigation, quality inspection and other fields. The following is a detailed analysis of Mech Mind's structured light cameras:
Mech Mind's structured light cameras, such as Mech-Eye PRO, use high-speed structured light technology to provide excellent resistance to ambient light while maintaining high precision and high speed. These cameras usually contain a variety of visual algorithm modules and can be applied to multiple typical practical scenarios, such as loading and unloading of workpieces in the manufacturing industry, high-precision positioning, assembly, screw tightening, and academic research.
Mech Mind's structured light cameras mainly use the principle of structured light projection. They project specific patterns (such as structured light generated by lasers) onto the object being photographed, and capture the outline and shape of the object through the camera. This technology can accurately calculate the position and shape of the object by analyzing the reflection and refraction of light on the object.
Mech Mind's structured light cameras are widely used in the fields of automobiles, aviation, mold manufacturing, industrial automation, etc. In the automotive field, they can quickly and accurately obtain the shape information of the body surface; in the aviation field, they can obtain the three-dimensional shape information of the aircraft, providing accurate data support for the design and manufacture of the aircraft.
Mech Mind's structured light camera plays an important role in industrial automation and robot navigation with its high precision, high speed, large field of view, large depth of field, strong resistance to ambient light, and stable and reliable characteristics. With the continuous advancement of technology and the continuous expansion of application scenarios, Mech Mind's structured light camera is expected to demonstrate its unique value in more fields.
Creating a Virtual Environment
Download opencv-python package
Download Mecha-Mind Camera Pack
- pip install MechEyeAPI
- pip install python-opencv
Connecting the Camera
- def ConnectCamera(self):
- camera_infos = Camera.discover_cameras()
- if len(camera_infos) != 1:
- print("相机连接出现异常,检查网线")
- return
- error_status = self.camera.connect(camera_infos[0])
- if not error_status.is_ok():
- show_error(error_status)
- return
Disconnect the camera
- def DisConnectCamera(self):
- self.camera.disconnect()
- print("Disconnected from the camera successfully.")
Collect 2D and 3D images
- def connect_and_capture(self):
-
- # Obtain the 2D image resolution and the depth map resolution of the camera.
- resolution = CameraResolutions()
- show_error(self.camera.get_camera_resolutions(resolution))
- print_camera_resolution(resolution)
-
- time1 = time.time()
- # Obtain the 2D image.
- frame2d = Frame2D()
- show_error(self.camera.capture_2d(frame2d))
- row, col = 222, 222
- color_map = frame2d.get_color_image()
- print("The size of the 2D image is {} (width) * {} (height).".format(
- color_map.width(), color_map.height()))
- rgb = color_map[row * color_map.width() + col]
- print("The RGB values of the pixel at ({},{}) is R:{},G:{},B{}n".
- format(row, col, rgb.b, rgb.g, rgb.r))
-
- Image2d = color_map.data()
-
- time2 = time.time()
- print('grab 2d image : '+str((time2-time1)*1000)+'ms')
-
-
- # if not confirm_capture_3d():
- # return
-
- # Obtain the depth map.
- frame3d = Frame3D()
- show_error(self.camera.capture_3d(frame3d))
- depth_map = frame3d.get_depth_map()
- print("The size of the depth map is {} (width) * {} (height).".format(
- depth_map.width(), depth_map.height()))
- depth = depth_map[row * depth_map.width() + col]
- print("The depth value of the pixel at ({},{}) is depth :{}mmn".
- format(row, col, depth.z))
- Image3d = depth_map.data()
- time3 = time.time()
- print('grab depth image : '+str((time3-time2)*1000)+'ms')
-
-
- return Image2d,Image3d
- # Obtain the point cloud.
- # point_cloud = frame3d.get_untextured_point_cloud()
- # print("The size of the point cloud is {} (width) * {} (height).".format(
- # point_cloud.width(), point_cloud.height()))
- # point_xyz = point_cloud[row * depth_map.width() + col]
- # print("The coordinates of the point corresponding to the pixel at ({},{}) is X: {}mm , Y: {}mm, Z: {}mmn".
- # format(row, col, point_xyz.x, point_xyz.y, point_xyz.z))
- # With this sample, you can connect to a camera and obtain the 2D image, depth map, and point cloud data.
- import time
-
- from mecheye.shared import *
- from mecheye.area_scan_3d_camera import *
- from mecheye.area_scan_3d_camera_utils import *
- import cv2
-
-
- class ConnectAndCaptureImages(object):
- def __init__(self):
- self.camera = Camera()
-
- def connect_and_capture(self):
-
- # Obtain the 2D image resolution and the depth map resolution of the camera.
- resolution = CameraResolutions()
- show_error(self.camera.get_camera_resolutions(resolution))
- print_camera_resolution(resolution)
-
- time1 = time.time()
- # Obtain the 2D image.
- frame2d = Frame2D()
- show_error(self.camera.capture_2d(frame2d))
- row, col = 222, 222
- color_map = frame2d.get_color_image()
- print("The size of the 2D image is {} (width) * {} (height).".format(
- color_map.width(), color_map.height()))
- rgb = color_map[row * color_map.width() + col]
- print("The RGB values of the pixel at ({},{}) is R:{},G:{},B{}n".
- format(row, col, rgb.b, rgb.g, rgb.r))
-
- Image2d = color_map.data()
-
- time2 = time.time()
- print('grab 2d image : '+str((time2-time1)*1000)+'ms')
-
-
- # if not confirm_capture_3d():
- # return
-
- # Obtain the depth map.
- frame3d = Frame3D()
- show_error(self.camera.capture_3d(frame3d))
- depth_map = frame3d.get_depth_map()
- print("The size of the depth map is {} (width) * {} (height).".format(
- depth_map.width(), depth_map.height()))
- depth = depth_map[row * depth_map.width() + col]
- print("The depth value of the pixel at ({},{}) is depth :{}mmn".
- format(row, col, depth.z))
- Image3d = depth_map.data()
- time3 = time.time()
- print('grab depth image : '+str((time3-time2)*1000)+'ms')
-
-
- return Image2d,Image3d
- # Obtain the point cloud.
- # point_cloud = frame3d.get_untextured_point_cloud()
- # print("The size of the point cloud is {} (width) * {} (height).".format(
- # point_cloud.width(), point_cloud.height()))
- # point_xyz = point_cloud[row * depth_map.width() + col]
- # print("The coordinates of the point corresponding to the pixel at ({},{}) is X: {}mm , Y: {}mm, Z: {}mmn".
- # format(row, col, point_xyz.x, point_xyz.y, point_xyz.z))
-
- def main(self):
- # List all available cameras and connect to a camera by the displayed index.
- if find_and_connect(self.camera):
- d2,d3 = self.connect_and_capture()
- self.camera.disconnect()
- print("Disconnected from the camera successfully.")
- return d2,d3
-
- def GrabImages(self):
- d2, d3 = self.connect_and_capture()
- return d2, d3
-
- def ConnectCamera(self):
- camera_infos = Camera.discover_cameras()
- if len(camera_infos) != 1:
- print("相机连接出现异常,检查网线")
- return
- error_status = self.camera.connect(camera_infos[0])
- if not error_status.is_ok():
- show_error(error_status)
- return
- def DisConnectCamera(self):
- self.camera.disconnect()
- print("Disconnected from the camera successfully.")
-
-
-
-
-
- if __name__ == '__main__':
-
- #pip install MechEyeAPI
-
- print('初始化相机对象')
- MechMindGraber = ConnectAndCaptureImages()
- # d2,d3 = a.main()
- print('连接相机')
- MechMindGraber.ConnectCamera()
-
- for i in range(60):
- print(str(i)+'rn')
- print('采集亮度图和深度图')
- d2,d3 = MechMindGraber.GrabImages()
-
-
- cv2.imshow('1',d2)
- cv2.waitKey()
- cv2.imshow('1', d3)
- cv2.waitKey()
- print('断开连接')
- MechMindGraber.DisConnectCamera()