Navigation

    VEYE IMAGING Forum

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Recent
    • Popular
    • Users
    • WIKI
    • veye.cc

    RAW-MIPI-SC132M camera working in raspberry pi 5. Cannot be configured to work with the libcamera2 and opencv libraries

    CS MIPI camera
    1
    1
    33
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Sheko last edited by Sheko

      The camera works fine in veye_viewer v1.1.4

      20260209_11h24m49s_grim.png

      When starting the sample opencv

      mport cv2
      import argparse
      import subprocess
      
      def main():
          # Set up command-line argument parser
          parser = argparse.ArgumentParser(description='Real-time display of GREY image from /dev/video0')
          parser.add_argument('--width', type=int, default=640, help='image width (default: 640)')
          parser.add_argument('--height', type=int, default=480, help='image height (default: 480)')
          parser.add_argument('--fps', type=int, default=30, help='frame rate (default: 30)')
          parser.add_argument('--ctldev', type=str, default='/dev/video0', help='For rpi5 only,subdevice for param setting')
          args = parser.parse_args()
          
          v4l2_cmd = f"v4l2-ctl -d {args.ctldev} --set-ctrl roi_x=0"
          subprocess.run(v4l2_cmd, shell=True)
          v4l2_cmd = f"v4l2-ctl -d {args.ctldev} --set-ctrl roi_y=0"
          subprocess.run(v4l2_cmd, shell=True)
          v4l2_cmd = f"v4l2-ctl -d '/dev/video0' --set-fmt-video=width={args.width},height={args.height}"
          subprocess.run(v4l2_cmd, shell=True)
          
          v4l2_cmd = f"v4l2-ctl -d {args.ctldev} --set-ctrl frame_rate={args.fps}"
          subprocess.run(v4l2_cmd, shell=True)
          
          # Open the /dev/video0 device
          cap = cv2.VideoCapture('/dev/video0')
          if not cap.isOpened():
              print("Failed to open video device")
              return
      
          # Set the image size
          cap.set(cv2.CAP_PROP_FRAME_WIDTH, args.width)
          cap.set(cv2.CAP_PROP_FRAME_HEIGHT, args.height)
      
          # Loop over frames and display them
          while True:
              # Read a frame
              ret, frame = cap.read()
      
              # Check if reading was successful
              if not ret:
                  print("Failed to read frame")
                  break
      
              # Display the frame
              cv2.imshow('VEYE MV camera GREY image preview', frame)
      
              # Exit if 'q' key is pressed
              if cv2.waitKey(1) & 0xFF == ord('q'):
                  break
      
          # Release resources
          cap.release()
          cv2.destroyAllWindows()
      
      if __name__ == '__main__':
          main()
      
      

      it returns an error

      [ WARN:0@0.135] global ./modules/videoio/src/cap_gstreamer.cpp (2401) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module source reported: Could not read from resource.
      [ WARN:0@0.136] global ./modules/videoio/src/cap_gstreamer.cpp (1356) open OpenCV | GStreamer warning: unable to start pipeline
      [ WARN:0@0.136] global ./modules/videoio/src/cap_gstreamer.cpp (862) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
      Failed to read frame
      
      
      ------------------
      (program exited with code: 0)
      Press return to continue
      
      
      

      Please help me figure it out

      1 Reply Last reply Reply Quote 0
      • First post
        Last post