기술나눔

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. 높은 정밀도 : 메크마인드의 구조광 카메라는 단시간에 고정밀 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. 개방적이고 사용하기 쉽습니다.: 카메라는 사용자의 2차 개발 및 통합을 용이하게 하기 위해 친숙한 사용자 인터페이스와 개방형 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()