VEYE IMAGING Forum
    • Categories
    • Tags
    • Recent
    • Popular
    • Users
    • WIKI
    • veye.cc
    • Register
    • Login

    树莓派CM4+CS-MIPI-SC132 x2 运行python opencv报错

    Scheduled Pinned Locked Moved VEYE MIPI camera
    2 Posts 2 Posters 718 Views 1 Watching
    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 Offline
      sjchen
      last edited by

      由于CS-MIPI-SC132最大支持1280x1080,故修改capture2opencv脚本如下:

      import D_mipicamera as Dcam
      import time
      import cv2 #sudo apt-get install python-opencv
      
      def align_down(size, align):
          return (size & ~((align)-1))
      
      def align_up(size, align):
          return align_down(size + align - 1, align)
      
      if __name__ == "__main__":
          try:
              camera = Dcam.mipi_camera()
              print("Open camera...")
              camera.init_camera()
              while cv2.waitKey(10) != 27:
                  frame = camera.capture(encoding = 'i420')
                  height = int(align_up(1080, 16))
                  width = int(align_up(1280, 32)) #修改了分辨率
                  image = frame.as_array.reshape(int(height * 1.5), width)
                  image = cv2.cvtColor(image, cv2.COLOR_YUV2BGR_I420)
                  cv2.imshow("D-Cam", image)
                  # Release memory
                  camera.release_buffer(frame)
                  del frame
              
              print("Close camera...")
              camera.close_camera()
          except Exception as e:
              print(e)
      

      运行后报错:QQ截图20211217141752.jpg

      veye_xummV 1 Reply Last reply Reply Quote 0
      • veye_xummV Offline
        veye_xumm @sjchen
        last edited by

        @sjchen
        除了你已经修改的地方之外,
        需要用
        D_init_camera_ex函数代替D_init_camera,这个函数具备分辨率的定义参数。

        Questions will be answered as soon as possible, please be patient.
        如果你使用中文,请直接用中文提问。
        May the force be with YOU. (This is the translation of the mysterious Chinese symbol above.)

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post