# Look at image

This code shows how to display the video stream from Reachy Mini and make it look where you click on the frame.

```python

import argparse
import sys
from typing import Any

try:
    import cv2
except ImportError:
    print("Error: OpenCV is required for this example but not installed.")
    print("Install it with: pip install reachy_mini[opencv]")
    sys.exit(1)

from reachy_mini import ReachyMini

# from reachy_mini.media.camera_constants import CameraResolution

def click(event: int, x: int, y: int, flags: int, param: Any) -> None:
    """Handle mouse click events to get the coordinates of the click."""
    if event == cv2.EVENT_LBUTTONDOWN:
        param["just_clicked"] = True
        param["x"] = x
        param["y"] = y

def main(backend: str) -> None:
    """Show the camera feed from Reachy Mini and make it look at clicked points."""
    state = {"x": 0, "y": 0, "just_clicked": False}

    cv2.namedWindow("Reachy Mini Camera")
    cv2.setMouseCallback("Reachy Mini Camera", click, param=state)

    print("Click on the image to make ReachyMini look at that point.")
    print("Press 'q' to quit the camera feed.")
    with ReachyMini(media_backend=backend) as reachy_mini:
        # Uncomment these three lines to change resolution
        # reachy_mini.media.camera.close()
        # reachy_mini.media.camera.set_resolution(CameraResolution.R3072x1728at10fps)
        # reachy_mini.media.camera.open()
        try:
            while True:
                frame = reachy_mini.media.get_frame()

                if frame is None:
                    print("Failed to grab frame.")
                    continue

                cv2.imshow("Reachy Mini Camera", frame)
                if cv2.waitKey(1) & 0xFF == ord("q"):
                    print("Exiting...")
                    break

                if state["just_clicked"]:
                    reachy_mini.look_at_image(state["x"], state["y"], duration=0.3)
                    state["just_clicked"] = False
        except KeyboardInterrupt:
            print("Interrupted. Closing viewer...")
        finally:
            cv2.destroyAllWindows()

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="Display Reachy Mini's camera feed and make it look at clicked points."
    )
    parser.add_argument(
        "--backend",
        type=str,
        choices=["default", "local", "webrtc"],
        default="default",
        help="Media backend to use.",
    )

    args = parser.parse_args()
    main(backend=args.backend)
```

