///|
/// Represents a detected ArUco Diamond Marker (3x3 grid composed of 4 individual markers).
pub(all) struct DiamondDetection {
  ids : Array[Int] // 4 marker IDs
  corners : Array[Point2D] // 4 outer corners of the diamond
  pose : Pose3D?
} derive(Debug, Eq)

///|
/// Detects ArUco Diamond Markers from detected marker corners.
/// A diamond consists of 4 markers arranged in a 3x3 layout.
pub fn detect_diamond_markers(
  detections : Array[MarkerDetection],
  square_length : Double,
  marker_length : Double,
  camera? : CameraIntrinsics,
) -> Array[DiamondDetection] {
  let diamonds : Array[DiamondDetection] = []
  let n = detections.length()
  if n < 4 {
    return diamonds
  }

  // Look for 4-marker diamond patterns (center square empty, 4 neighbor markers)
  for i in 0..
                estimate_marker_pose(
                  diamond_quad,
                  cam,
                  square_length * 3.0 - marker_length,
                )
              None => None
            }

            diamonds.push({ ids, corners: diamond_quad.corners, pose })
          }
        }
      }
    }
  }

  diamonds
}