• MechMind结构光相机 采图SDK python调用


    测试效果

    Mech-Mind结构光相机

    Mech Mind(梅卡曼德)的结构光相机,特别是Mech-Eye系列,是工业级的高精度3D相机,广泛应用于工业自动化、机器人导航、质量检测等多个领域。以下是对Mech Mind结构光相机的详细解析:

    一、产品概述

    Mech Mind的结构光相机,如Mech-Eye PRO,采用了高速结构光技术,能够在保持高精度、高速度的同时,提供优异的抗环境光性能。这些相机通常包含丰富的视觉算法模块,可应用于多个典型实际场景,如制造业工件上下料、高精度定位、装配、螺丝拧紧及学术研究等。

    二、工作原理

    Mech Mind的结构光相机主要利用了结构光投影的原理。它们将特定图案(如激光产生的结构光)投射到被拍摄物体上,并通过摄像头捕捉到物体的轮廓和形状。这种技术通过分析光线在物体上的反射和折射,能够精确地计算出物体的位置和形状。

    三、产品特点

    1. 高精度:Mech Mind的结构光相机能够在短时间内获取高精度的三维模型,对于不同的物体,只需一次拍摄即可获得准确的形状信息。例如,Mech-Eye PRO的Z向单点重复精度可达到0.05mm(在1.0m处)。
    2. 高速度:相机具备快速的数据采集和处理能力,如Mech-Eye PRO的典型采集时间为0.3~0.6秒。
    3. 大视野和大景深:部分型号如Mech-Eye Deep 3D相机,具备大视野和大景深的特点,可适用于多种常见垛型。
    4. 抗环境光性能强:Mech Mind的结构光相机在较强环境光干扰下(如>20000lx)仍能保持优异的成像效果。
    5. 部署灵活:相机适配了国内外大部分主流品牌的机器人,可以实现对已适配机器人的完全运动控制。
    6. 开放易用:相机提供了友好的用户接口和开放的API,方便用户进行二次开发和集成。
    7. 稳定可靠:Mech Mind的结构光相机具备高稳定性和可靠性,如Mech-Eye PRO的平均无故障运行时间(MTBF)≥40000小时。

    四、应用领域

    Mech Mind的结构光相机被广泛应用于汽车、航空、模具制造、工业自动化等领域。在汽车领域,它们能够快速精确地获取车身表面的形状信息;在航空领域,它们能够获取飞机的三维形状信息,为飞机的设计和制造提供准确的数据支持。

    五、总结

    Mech Mind的结构光相机以其高精度、高速度、大视野、大景深、强抗环境光性能以及稳定可靠的特点,在工业自动化和机器人导航等领域发挥着重要作用。随着技术的不断进步和应用场景的不断拓展,Mech Mind的结构光相机有望在更多领域展现其独特的价值。

    搭建Python开发环境

    创建虚拟环境

    下载opencv-python包

    下载梅卡曼德相机 采图包

    1. pip install MechEyeAPI
    2. pip install python-opencv

    步骤解析

    连接相机

    1. def ConnectCamera(self):
    2. camera_infos = Camera.discover_cameras()
    3. if len(camera_infos) != 1:
    4. print("相机连接出现异常,检查网线")
    5. return
    6. error_status = self.camera.connect(camera_infos[0])
    7. if not error_status.is_ok():
    8. show_error(error_status)
    9. return

    断开相机

    1. def DisConnectCamera(self):
    2. self.camera.disconnect()
    3. print("Disconnected from the camera successfully.")

    采集2d图和3d图

    1. def connect_and_capture(self):
    2. # Obtain the 2D image resolution and the depth map resolution of the camera.
    3. resolution = CameraResolutions()
    4. show_error(self.camera.get_camera_resolutions(resolution))
    5. print_camera_resolution(resolution)
    6. time1 = time.time()
    7. # Obtain the 2D image.
    8. frame2d = Frame2D()
    9. show_error(self.camera.capture_2d(frame2d))
    10. row, col = 222, 222
    11. color_map = frame2d.get_color_image()
    12. print("The size of the 2D image is {} (width) * {} (height).".format(
    13. color_map.width(), color_map.height()))
    14. rgb = color_map[row * color_map.width() + col]
    15. print("The RGB values of the pixel at ({},{}) is R:{},G:{},B{}\n".
    16. format(row, col, rgb.b, rgb.g, rgb.r))
    17. Image2d = color_map.data()
    18. time2 = time.time()
    19. print('grab 2d image : '+str((time2-time1)*1000)+'ms')
    20. # if not confirm_capture_3d():
    21. # return
    22. # Obtain the depth map.
    23. frame3d = Frame3D()
    24. show_error(self.camera.capture_3d(frame3d))
    25. depth_map = frame3d.get_depth_map()
    26. print("The size of the depth map is {} (width) * {} (height).".format(
    27. depth_map.width(), depth_map.height()))
    28. depth = depth_map[row * depth_map.width() + col]
    29. print("The depth value of the pixel at ({},{}) is depth :{}mm\n".
    30. format(row, col, depth.z))
    31. Image3d = depth_map.data()
    32. time3 = time.time()
    33. print('grab depth image : '+str((time3-time2)*1000)+'ms')
    34. return Image2d,Image3d
    35. # Obtain the point cloud.
    36. # point_cloud = frame3d.get_untextured_point_cloud()
    37. # print("The size of the point cloud is {} (width) * {} (height).".format(
    38. # point_cloud.width(), point_cloud.height()))
    39. # point_xyz = point_cloud[row * depth_map.width() + col]
    40. # print("The coordinates of the point corresponding to the pixel at ({},{}) is X: {}mm , Y: {}mm, Z: {}mm\n".
    41. # format(row, col, point_xyz.x, point_xyz.y, point_xyz.z))

    完整测试代码

    1. # With this sample, you can connect to a camera and obtain the 2D image, depth map, and point cloud data.
    2. import time
    3. from mecheye.shared import *
    4. from mecheye.area_scan_3d_camera import *
    5. from mecheye.area_scan_3d_camera_utils import *
    6. import cv2
    7. class ConnectAndCaptureImages(object):
    8. def __init__(self):
    9. self.camera = Camera()
    10. def connect_and_capture(self):
    11. # Obtain the 2D image resolution and the depth map resolution of the camera.
    12. resolution = CameraResolutions()
    13. show_error(self.camera.get_camera_resolutions(resolution))
    14. print_camera_resolution(resolution)
    15. time1 = time.time()
    16. # Obtain the 2D image.
    17. frame2d = Frame2D()
    18. show_error(self.camera.capture_2d(frame2d))
    19. row, col = 222, 222
    20. color_map = frame2d.get_color_image()
    21. print("The size of the 2D image is {} (width) * {} (height).".format(
    22. color_map.width(), color_map.height()))
    23. rgb = color_map[row * color_map.width() + col]
    24. print("The RGB values of the pixel at ({},{}) is R:{},G:{},B{}\n".
    25. format(row, col, rgb.b, rgb.g, rgb.r))
    26. Image2d = color_map.data()
    27. time2 = time.time()
    28. print('grab 2d image : '+str((time2-time1)*1000)+'ms')
    29. # if not confirm_capture_3d():
    30. # return
    31. # Obtain the depth map.
    32. frame3d = Frame3D()
    33. show_error(self.camera.capture_3d(frame3d))
    34. depth_map = frame3d.get_depth_map()
    35. print("The size of the depth map is {} (width) * {} (height).".format(
    36. depth_map.width(), depth_map.height()))
    37. depth = depth_map[row * depth_map.width() + col]
    38. print("The depth value of the pixel at ({},{}) is depth :{}mm\n".
    39. format(row, col, depth.z))
    40. Image3d = depth_map.data()
    41. time3 = time.time()
    42. print('grab depth image : '+str((time3-time2)*1000)+'ms')
    43. return Image2d,Image3d
    44. # Obtain the point cloud.
    45. # point_cloud = frame3d.get_untextured_point_cloud()
    46. # print("The size of the point cloud is {} (width) * {} (height).".format(
    47. # point_cloud.width(), point_cloud.height()))
    48. # point_xyz = point_cloud[row * depth_map.width() + col]
    49. # print("The coordinates of the point corresponding to the pixel at ({},{}) is X: {}mm , Y: {}mm, Z: {}mm\n".
    50. # format(row, col, point_xyz.x, point_xyz.y, point_xyz.z))
    51. def main(self):
    52. # List all available cameras and connect to a camera by the displayed index.
    53. if find_and_connect(self.camera):
    54. d2,d3 = self.connect_and_capture()
    55. self.camera.disconnect()
    56. print("Disconnected from the camera successfully.")
    57. return d2,d3
    58. def GrabImages(self):
    59. d2, d3 = self.connect_and_capture()
    60. return d2, d3
    61. def ConnectCamera(self):
    62. camera_infos = Camera.discover_cameras()
    63. if len(camera_infos) != 1:
    64. print("相机连接出现异常,检查网线")
    65. return
    66. error_status = self.camera.connect(camera_infos[0])
    67. if not error_status.is_ok():
    68. show_error(error_status)
    69. return
    70. def DisConnectCamera(self):
    71. self.camera.disconnect()
    72. print("Disconnected from the camera successfully.")
    73. if __name__ == '__main__':
    74. #pip install MechEyeAPI
    75. print('初始化相机对象')
    76. MechMindGraber = ConnectAndCaptureImages()
    77. # d2,d3 = a.main()
    78. print('连接相机')
    79. MechMindGraber.ConnectCamera()
    80. for i in range(60):
    81. print(str(i)+'\r\n')
    82. print('采集亮度图和深度图')
    83. d2,d3 = MechMindGraber.GrabImages()
    84. cv2.imshow('1',d2)
    85. cv2.waitKey()
    86. cv2.imshow('1', d3)
    87. cv2.waitKey()
    88. print('断开连接')
    89. MechMindGraber.DisConnectCamera()

  • 相关阅读:
    前端工作总结249-uni-关闭onshow的加载方法uni.hideLoading
    网络安全进阶学习第二十课——CTF之文件操作与隐写
    cloudreve配置ssl证书实现https访问cloudreve网盘
    A062-防火墙安全配置-配置Iptables防火墙策略
    linux多线程例程
    TLS/SSL通信基于NodeJS16
    ElasticSearch - 删除已经设置的认证密码(7.x)
    Unity之手游UI的点击和方向移动
    Ubuntu下无法输入中文问题解决
    60天零基础干翻C++————双指针问题
  • 原文地址:https://blog.csdn.net/linux_huangyu/article/details/140346324