CharucoDetector.create constructor

CharucoDetector.create(
  1. CharucoBoard board,
  2. CharucoDetectorParameters? charucoParameters, {
  3. ArucoDetectorParameters? detectorParameters,
  4. ArucoRefineParameters? refineParameters,
})

Implementation

factory CharucoDetector.create(
  CharucoBoard board,
  CharucoDetectorParameters? charucoParameters, {
  ArucoDetectorParameters? detectorParameters,
  ArucoRefineParameters? refineParameters,
}) {
  final p = calloc<cvg.CharucoDetector>();
  final ownedCharucoParameters = charucoParameters == null ? CharucoDetectorParameters.empty() : null;
  final ownedDetectorParameters = refineParameters != null && detectorParameters == null
      ? ArucoDetectorParameters.empty()
      : null;
  final charucoParams = charucoParameters ?? ownedCharucoParameters!;
  final detectorParams = detectorParameters ?? ownedDetectorParameters;
  try {
    cvRun(() {
      if (refineParameters != null) {
        return ccontrib.cv_aruco_charucoDetector_create_4(
          board.ref,
          charucoParams.ref,
          detectorParams!.ref,
          refineParameters.ref,
          p,
        );
      }
      if (detectorParams != null) {
        return ccontrib.cv_aruco_charucoDetector_create_3(
          board.ref,
          charucoParams.ref,
          detectorParams.ref,
          p,
        );
      }
      if (charucoParameters != null) {
        return ccontrib.cv_aruco_charucoDetector_create_2(
          board.ref,
          charucoParams.ref,
          p,
        );
      }
      return ccontrib.cv_aruco_charucoDetector_create_1(board.ref, p);
    });
  } finally {
    ownedDetectorParameters?.dispose();
    ownedCharucoParameters?.dispose();
  }
  return CharucoDetector._(p);
}