고급 카메라 교정 - Helsparrow/OpenpnpDocs_KR GitHub Wiki

목적

고급 카메라 보정의 목적은 다음과 같습니다:

  1. 헤드 오프셋(또는 하단 카메라의 절대 위치) 및 카메라 방향을 결정합니다.
  2. 카메라 픽셀에 대한 머신 유닛의 스케일링, 즉 픽셀당 유닛과 머신 Z에 따라 어떻게 달라지는지 결정합니다.
  3. 카메라 장착 방식의 결함, 즉 X, Y 및 Z 축에 대한 이상적인 회전에서 수정합니다. 그리고,
  4. 렌즈 결함(예: 배럴 / 핀쿠션 / 접선 왜곡)을 수정합니다.

perpendicular-constant-xy-diff-z

작동 방식

Advanced Camera Calibration(고급 카메라 보정)은 기본적으로 기계 3D 좌표를 가져와 이미지 픽셀 2D 좌표에 매핑하는 카메라의 수학적 모델을 만드는 방식으로 작동합니다. 대규모 기계 3D 좌표 세트와 해당 영상 픽셀 2D 좌표로 구성된 보정 데이터가 수집됩니다. 그런 다음 카메라 모델이 데이터에 "일치"되어 모델링된 이미지 좌표와 실제 이미지 좌표 간의 차이가 최소화됩니다. 그런 다음 카메라 모델은 위에서 언급한 카메라의 결함을 수정하기 위해 물리적 카메라에서 이미지 픽셀의 재매핑을 생성하는 데 사용됩니다. 카메라 모델에는 헤드 오프셋(또는 하단 카메라의 절대 위치)을 결정하는 데 사용되는 정보뿐만 아니라 주어진 Z 좌표에서 카메라 픽셀에 대한 기계 단위의 스케일링을 결정하는 데 사용되는 정보도 포함됩니다.

활성화/비활성화

다음은 특정 카메라에 대해 고급 카메라 캘리브레이션을 활성화/비활성화하는 방법입니다. 기계 설정 트리에서 해당 카메라를 선택한 후, 실험적 캘리브레이션 탭을 선택하고 "옛 스타일 이미지 변환 및 왜곡 보정 덮어쓰기를 위해 실험적 캘리브레이션 사용" 체크 상자를 선택/해제하면 됩니다(아래 참조). 일반 설정 섹션 아래의 설정 이외에는 이 체크 상자를 해제하면 기계 작동에 영향을 미치지 않습니다(고급 카메라 캘리브레이션 실행 전의 모든 설정이 복원됩니다): Experimental Calibration Tab

일반 설정

General Settings

이 설정은 다른 탭에서 사용할 수 있는 설정의 복사본입니다. Advanced Calibration(고급 보정)을 실행하기 전에 원하는 값으로 설정해야 하므로 편의를 위해 여기에 제공됩니다. 여기서 변경한 내용은 즉시 적용되며 변경된 내용이 나타나는 다른 탭의 해당 값이 변경됩니다.

크롭된 너비크롭된 높이는 이 보정에 의해 적용되기 전에 원본 카메라 이미지에 적용됩니다. 따라서 보정 데이터는 크롭된 이미지에서만 수집되며, 어떠한 보정도 원본 이미지의 해당 부분에만 적용됩니다.

교정 셋업

Calibration Setup

Primary Cal ZSecondary Cal Z 설정은 카메라 보정에 사용되는 보정 테스트 패턴의 Z 좌표를 결정합니다. 상부 카메라의 경우, 이들은 각각 주요 보정 기준점과 보조 보정 기준점의 Z 좌표로 설정되며, 이곳에서 편집할 수 없습니다. 하부 카메라의 경우, Primary Cal Z는 오토포커스에 의해 노즐 팁이 최적 초점 위치에 있는 Z 좌표로 설정되며(여기에서는 편집할 수 없음), Secondary Cal Z는 기본적으로 주요 설정의 절반으로 설정됩니다. 작업자는 노즐 팁이 합리적인 초점에 머무르면서 가능한 한 높은(양수) 값을 설정해야 합니다.

Radial Lines Per Cal Z 설정은 교정 프로세스 중에 수집되는 교정 데이터 포인트의 수를 제어하는 데 사용됩니다. 교정 데이터는 영상의 중심에서 시작하여 영상의 가장자리까지 이어지는 선을 따라 수집됩니다. 이 설정은 이러한 라인이 사용되는 수를 제어합니다. 대칭을 유지하기 위해 이 설정은 4의 다음 배수로 반올림됩니다. 이 수를 줄이면 수집 시퀀스의 지속 시간이 단축되지만 품질이 떨어지거나 교정에 실패할 위험이 있습니다. 이 숫자를 늘리면 수집 기간이 늘어나지만 품질 보정이 더 높아질 수 있습니다.

Start Calibration 버튼을 누르면 교정 데이터 수집 프로세스가 시작됩니다. 보정을 시작하기 전에 버튼 위에 있는 이 탭의 모든 설정을 설정해야 합니다. 보정 수집 프로세스 중에 지침/상태가 카메라 보기 아래에 표시되어 작업자에게 프로세스를 안내합니다. 작업자가 보정 수집을 중단할 수 있는 취소 버튼도 표시됩니다: Instructions/Status

Detection Diameter 스피너는 사용되는 기준/노즐 팁의 크기를 설정합니다. 교정 수집 프로세스 중에 작업자에게 적절한 시간에 이 값을 설정하라는 지시가 표시됩니다.

보정 데이터가 수집되고 성공적으로 처리되면 Apply Calibration 확인란이 자동으로 선택되어 보정을 카메라에 적용하고 보정된 영상을 카메라 보기에 표시할 수 있습니다. 이 확인란의 선택을 취소하면 카메라 보기에 수정되지 않은 원시 이미지가 표시됩니다.

이 섹션 하단의 Crop All Invalid Pixels <--> Show All Valid Pixels 슬라이더는 보정된 카메라 이미지의 가장자리에 있는 무효 픽셀의 크롭을 조절하는 데 사용됩니다. 이미지 처리로 인해(카메라 부착 및 렌즈 왜곡 오류 보상), 이미지 가장자리의 무효 픽셀(일반적으로 검은 색으로 표시)이 발생할 수 있습니다. 이 설정을 변경하면 대부분 미적인 효과가 발생하지만, 카메라의 픽셀 당 단위도 변경됩니다. 슬라이더를 가장 오른쪽으로 설정하면 카메라에서 사용 가능한 모든 픽셀이 표시됩니다. 슬라이더를 가장 왼쪽으로 설정하면 이미지의 가장자리가 교차선을 기준으로 직사각형으로 대칭적으로 크롭되어 가장자리에 유효하지 않은 픽셀이 남지 않도록 보장됩니다. 중간 설정값은 두 극단 사이의 결과를 생성합니다. 이 작업 방식을 시각화한 애니메이션은 아래에서 확인할 수 있습니다:

Slider Animation

교정 데이터 수집

Start Calibration 버튼을 클릭하면 다음과 같이 보정이 진행됩니다:

Top Cameras

  1. 사용자는 Primary Calibration Fiduicial이 중심에 오도록 카메라를 조그해야 합니다.
  2. 사용자는 기준에서 안정적인 감지가 가능하도록 검출 직경 스피너를 조정해야 합니다.
  3. 카메라는 기본 보정 기준의 Z 좌표에서 픽셀당 카메라 단위의 추정치를 얻기 위해 몇 가지 작은 단계로 이동합니다.
  4. Primary Calibration Fiduccial이 정확히 중앙에 오도록 카메라가 움직입니다.
  5. 카메라가 방사형 선을 따라 단계적으로 이동하여 기준이 이미지 중심에서 이미지 가장자리로 이동합니다. 방사형 선은 중심을 중심으로 동일한 각도로 간격을 두고 있지만 랜덤 순서로 방문됩니다. 모든 라인에 대한 단계가 완료되면 카메라가 중앙에서 다음 단계로 이동하고 모든 라인이 무작위 순서로 다시 방문됩니다. 이 작업은 모든 라인이 완료될 때까지 계속됩니다.
  6. 보조 보정 기준을 사용하여 1~5단계를 반복합니다.
  7. 교정 데이터가 처리되고, 성공하면 결과가 적용됩니다.

Bottom Cameras

  1. 사용자는 가장 작은 노즐 팁을 장착해야 합니다.
  2. 사용자는 노즐 팁이 카메라 뷰에서 대략 중앙에 오도록 조그해야 합니다.
  3. 노즐 팁이 Primary Calibration Z로 이동되고 작업자는 노즐 팁이 여전히 중심에 있는지 확인해야 합니다.
  4. 사용자는 노즐 팁에서 안정적인 감지가 가능하도록 검출 직경 스피너를 조정해야 합니다.
  5. 노즐 팁은 기본 보정 기준에서 픽셀당 카메라 단위의 추정치를 얻기 위해 몇 가지 작은 단계로 이동합니다.
  6. 노즐 팁이 정확히 중앙에 오도록 이동합니다.
  7. 노즐 팁이 방사형 선을 따라 단계적으로 이동하여 이미지 중심에서 이미지 가장자리로 이동합니다. 방사형 선은 중심을 중심으로 동일한 각도로 간격을 두고 있지만 랜덤 순서로 방문됩니다. 모든 라인에 대한 단계가 완료되면 노즐 팁이 중앙에서 다음 단계로 이동하고 모든 라인이 무작위 순서로 다시 방문됩니다. 이 작업은 모든 라인이 완료될 때까지 계속됩니다.
  8. 보조 보정 Z에서 3~7단계를 반복합니다
  9. 교정 데이터가 처리되고, 성공하면 결과가 적용됩니다.

Results/Diagnostics

Results/Diagnostics

The first item displayed here is the Calibrated Head Offsets (for top cameras) or the Camera Location (for bottom cameras). For top cameras, this is the horizontal offset compensation needed due to the optical axis of the physical camera not being perfectly vertical. This keeps coordinates captured with the top camera at the height of the primary calibration fiducial prior to this calibration consistent with coordinates captured after this calibration. For bottom cameras, this is the X-Y coordinates of the physical camera and Z is the Z coordinate determined by auto focus.

Units Per Pixel displays the computed units per pixel at default Z for this camera. Note that images are scaled such that the units per pixel is the same in both the X and Y directions.

Estimated Locating Accuracy displays an estimate of the expected accuracy of locations that are captured by using this camera. This includes not only inaccuracies due to uncompensated residual camera errors but also inaccuracies due to machine mechanics such as stepper motor non-linearities, mechanical backlash, etcetera. As this is a statistical measure, it should be expected that about 63 percent of all measurements will be better than this and that 98 percent of all measurements will be better than double this value. See Circular Error Probable for more information.

Physical Field-Of-View displays the estimated angular field-of-view for the physical camera. Note that width and height here refer to the camera's raw images without regard to how it may be mounted to the machine.

Effective Field-Of-View displays the estimated angular field-of-view for the camera after all corrections are applied.

Camera Mounting Error shows the estimated mounting errors of the camera as measured by the right hand rule about each machine axis. See here for how mounting errors effect the images as seen in the camera view pane.

The Select Cal Z For Plotting spinner selects the data to be displayed in the plots below.

The Show Outliers checkbox enables data points that were judged to be bad measurements to be displayed in the plots.

The three plots at the bottom of this section all display the residual errors of the calibration data although in different ways. Residual error is defined as the difference between where the fitted model predicts where the detected fiducial/nozzle tip should have appeared in the image and where it actually appeared in the image. To be more meaningful to the operator, the residual errors are converted from differences in pixels to differences in machine units at the Z level at which the calibration data was collected.

The Residual Errors In Collection Order plot shows the individual X and Y components of residual error as a time ordered sequence. The residual errors should have zero mean and appear as random noise. If there are significant steps in the mean level or trends in the errors; depending on their magnitude, there may be a problem with the calibration. Some possible causes are: calibration fiducial/nozzle tip movement/slippage during the collection; camera or lens moving in its mount; motors missing steps; belt/cog slippage; thermal expansion/contraction; etcetera.

The Residual Error X-Y Scatter Plot shows the residual error for each collected data point as a dot on a scatter plot where the magnitude of the residual error is the distance of the dot from the origin. A green circle marks the approximate boundary at which points are considered to be outliers and are not used for determining the fit of the camera model. The residual errors should form a single circular cluster centered at (0, 0) and should appear randomly distributed. If two or more distinct clusters are present or the cluster is significantly non-circular; depending on the magnitude of the errors, there may be a problem with the calibration. Some possible causes are: bad vision detection of the calibration fiducial/nozzle tip, calibration fiducial/nozzle tip movement/slippage during the collection; camera or lens moving in its mount; under or over compensated backlash; motors missing steps; belt/cog slippage; etcetera.

The Residual Error Map shows how the residual errors are distributed across the camera image. Dark blue areas have very low errors while dark red areas have the highest errors. Note that the color range is always scaled so that zero error is the darkest blue and the maximum magnitude error is the darkest red. Therefore, this plot cannot be used to judge the magnitude of the error but only its distribution about the image. This distribution should look more or less random with no discernible patterns. If patterns such as rings or stripes are clearly visible and the residual errors observed in the other plots are larger than expected, the mathematical model of the camera does not fit very well with the physics of the camera and may indicate something is wrong with the camera and/or lens.

Comparison of Uncalibrated to Calibrated Images

The animated gif below shows a piece of 2 millimeter graph paper face up on the machine table and imaged by the top camera. The camera's virtual Z axis was jogged to match the Z height of the graph paper and a Grid Reticle with 2 Units per Tick was selected. The gif alternates between uncorrected raw images and corrected images (note the state of the Apply Calibration checkbox):

Before And After Calibration Image