Navigation

    VEYE IMAGING Forum

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

    UNSOLVED 树莓派CM4+imx327S MIPI x2 运行python opencv脚本如何达到30fps

    VEYE MIPI camera
    2
    4
    332
    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
      sjchen last edited by

      树莓派CM4+imx327S MIPI x2,使用如下脚本测试帧率只有13.4FPS,如何提高到30FPS?谢谢

      import D_mipicamera as Dcam
      import cv2
      import time
      
      frame_width = 1920
      frame_length = 1080
      
      def align_down(size, align):
          return (size & ~((align)-1))
      
      def align_up(size, align):
          return align_down(size + align - 1, align)
      
      camera_L = Dcam.mipi_camera()
      camera_R = Dcam.mipi_camera()
      print("Open camera 0...\n")
      camera_L.init_camera((0,0,(0,0),(0,0)))
      print("Open camera 1...\n")
      camera_R.init_camera((1,1,(1,1),(1,1)))
      
      framecnt = 0
      starttime = round(time.time() * 1000)
      
      while(True):
          image_L = camera_L.capture(encoding = 'i420')
          image_R = camera_R.capture(encoding = 'i420')
          height = int(align_up(frame_length, 16))
          width = int(align_up(frame_width, 32))
          frame_L = image_L.as_array.reshape(int(height * 1.5), width)
          frame_L = cv2.cvtColor(frame_L, cv2.COLOR_YUV2BGR_I420)
          frame_R = image_R.as_array.reshape(int(height * 1.5), width)
          frame_R = cv2.cvtColor(frame_R, cv2.COLOR_YUV2BGR_I420)
          
          # Release memory
          camera_L.release_buffer(image_L)
          del image_L
          camera_R.release_buffer(image_R)
          del image_R
      
          framecnt = framecnt+1
          if framecnt == 100:
              break
      
      print("Close camera...")
      camera_L.close_camera()
      camera_R.close_camera()
      
      endtime = round(time.time() * 1000)
      
      timedelta = endtime - starttime
      
      print("frame rate: %f" %(100/timedelta*1000))
      
      veye_xumm 1 Reply Last reply Reply Quote 0
      • veye_xumm
        veye_xumm @sjchen last edited by

        @sjchen
        你好,capture这个函数,本身是通过在码流中截取一张的方式来实现的。整个调用要初始化接收-->得到下一张-->返回并关闭接收。所以帧率不行。
        需要满帧的话,得注册YUV数据的回调函数,让底层库收到之后就回调到上层。
        请试一下 D_start_yuv_stream函数。
        D_mipicamera.py

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

          @veye_xumm 谢谢回复。我看到里面有一个python 的封装叫“start_yuv_stream”,但是没有demo可参考。能否给一个简单的example说明回调函数func有哪些参数,另外userdata参数具体是什么?我要怎样使用?
          谢谢!

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

            @sjchen 不好意思,这个我们暂时还没有提供demo,功能上讲,这个就是提供一个回调函数的注册接口。底层的库,有一个线程,在有数据的时候就会调一下这个回调函数。
            userdata可以不用管它。

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