技術共有

MechMind 構造化光カメラ画像キャプチャ SDK Python 呼び出し

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

テスト効果

Mech-Mind 構造化光カメラ

Mech Mind の構造化光カメラ、特に Mech-Eye シリーズは、産業オートメーション、ロボット ナビゲーション、品質検査などの分野で広く使用されている産業グレードの高精度 3D カメラです。以下は、Mech Mind 構造化光カメラの詳細な分析です。

1. 製品概要

Mech-Eye PRO などの Mech Mind の構造化光カメラは、高速構造化光技術を使用して、高精度と速度を維持しながら優れた耐環境光性を提供します。これらのカメラには通常、豊富なビジョン アルゴリズム モジュールが含まれており、製造ワークピースのロードとアンロード、高精度の位置決め、組み立て、ネジ締め、学術研究など、多くの典型的な実用的なシナリオに適用できます。

2.動作原理

Mech Mind の構造化光カメラは、主に構造化光投影の原理を利用しています。特定のパターン (レーザーによって生成された構造化光など) を撮影対象の物体に投影し、物体の輪郭と形状がカメラで捕捉されます。物体における光の反射や屈折を解析することで、物体の位置や形状を正確に算出する技術です。

3. 製品の特長

  1. 高精度 : Mech Mindの構造化光カメラは、短時間で高精度の3次元モデルを取得でき、さまざまな物体の正確な形状情報をワンショットで取得できます。たとえば、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) ≥ 40,000 時間など、高い安定性と信頼性を備えています。

4. 応用分野

Mech Mind の構造化光カメラは、自動車、航空、金型製造、産業オートメーションなどの分野で広く使用されています。自動車分野では車体表面の形状情報を迅速かつ正確に取得でき、航空分野では航空機の3次元形状情報を取得し、航空機の設計と製造に正確なデータを提供します。 。

5. まとめ

Mech Mind の構造化光カメラは、高精度、高速、広い視野、深い被写界深度、周囲光に対する強い耐性、安定性と信頼性により、産業オートメーションやロボット ナビゲーションなどの分野で重要な役割を果たしています。テクノロジーの継続的な進歩とアプリケーションシナリオの継続的な拡大により、Mech Mind の構造化光カメラはより多くの分野で独自の価値を発揮することが期待されています。

Python 開発環境をセットアップする

仮想環境を作成する

opencv-python パッケージをダウンロードする

Mecamander カメラ キャプチャ パッケージをダウンロードする

  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 :{}mmn".
  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: {}mmn".
  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 :{}mmn".
  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: {}mmn".
  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)+'rn')
  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()