Rpi5 camera doesn't work

I want to use my raspberry pi 5 for pose estimation.

The past week I have been using my rpi4 with a webcam and the pose estimation as worked pretty well. However, I wanted to migrate to the rpi5 for better compute power, and I want to move towards a built in camera because it is less clunky…

After I set up my rpi5 with the camera and opencv + mediapipe I ran the code provided below. I receive no errors but the camera feed does not open :confused:

when I use the rpicam-still command my camera opens just fine! please help :upside_down_face:

import cv2
import mediapipe as mp

# Initialize MediaPipe Pose model
mp_pose = mp.solutions.pose
pose = mp_pose.Pose()

# Initialize Raspberry Pi camera
cap = cv2.VideoCapture(0)  # 0 for the first camera, 1 for the second, and so on

while cap.isOpened():
    # Read frame from the camera
    ret, frame = cap.read()
    if not ret:
        break

    # Convert the image to RGB
    frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

    # Perform pose estimation
    results = pose.process(frame_rgb)

    # Draw the detected poses
    if results.pose_landmarks:
        mp_drawing = mp.solutions.drawing_utils
        mp_drawing.draw_landmarks(frame, results.pose_landmarks, mp_pose.POSE_CONNECTIONS)

    # Display the frame with detected poses
    cv2.imshow('Pose Estimation', frame)

    # Check for exit key
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# Release resources
cap.release()
cv2.destroyAllWindows()

my original post: https://forums.raspberrypi.com/viewtopic.php?t=369106
camera im using: https://www.amazon.co.uk/gp/product/B00N1YJKFS/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1

Of course, the problem that you neef help for, has nothing to do with pose estimation - just with that device configuration
#postingTitles

I really wish those raspberry pi people would google a little before asking the same questions every day without pause.

OpenCV supports V4L/V4L2. That is the standard for video devices on Linux.

“Pi cameras” refuse to support this. That is Raspberry Pi’s problem, not OpenCV’s problem.

That is all. Please take this back to the rpi forum.