def METHOD_NAME(frozen: SimpleNamespace) -> SimpleNamespace:
    """Add detected_text method to frozen PhotoInfo object"""
    def detected_text(confidence_threshold=TEXT_DETECTION_CONFIDENCE_THRESHOLD):
        """Detects text in photo and returns lists of results as (detected text, confidence)
        confidence_threshold: float between 0.0 and 1.0. If text detection confidence is below this threshold,
        text will not be returned. Default is TEXT_DETECTION_CONFIDENCE_THRESHOLD
        If photo is edited, uses the edited photo, otherwise the original; falls back to the preview image if neither edited or original is available
        Returns: list of (detected text, confidence) tuples
        """
        try:
            return frozen._detected_text_cache[confidence_threshold]
        except (AttributeError, KeyError) as e:
            if isinstance(e, AttributeError):
                frozen._detected_text_cache = {}
            try:
                detected_text = frozen._detected_text()
            except Exception as e:
                logging.warning(f"Error detecting text in photo {frozen.uuid}: {e}")
                detected_text = []
            frozen._detected_text_cache[confidence_threshold] = [
                (text, confidence)
                for text, confidence in detected_text
                if confidence >= confidence_threshold
            ]
            return frozen._detected_text_cache[confidence_threshold]
    def _detected_text():
        """detect text in photo, either from cached extended attribute or by attempting text detection"""
        path = (
            frozen.path_edited
            if frozen.hasadjustments and frozen.path_edited
            else frozen.path
        )
        path = path or frozen.path_derivatives[0] if frozen.path_derivatives else None
        if not path:
            return []
        md = OSXMetaData(path)
        try:
            def decoder(val):
                """Decode value from JSON"""
                return json.loads(val.decode("utf-8"))
            detected_text = md.get_xattr(
                "osxphotos.metadata:detected_text", decode=decoder
            )
        except KeyError:
            detected_text = None
        if detected_text is None:
            orientation = frozen.orientation or None
            detected_text = detect_text(path, orientation)
            def encoder(obj):
                """Encode value as JSON"""
                val = json.dumps(obj)
                return val.encode("utf-8")
            md.set_xattr(
                "osxphotos.metadata:detected_text", detected_text, encode=encoder
            )
        return detected_text
    frozen.detected_text = detected_text
    frozen._detected_text = _detected_text
    return frozen