Navigation

    VEYE IMAGING Forum

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

    jetson nano使用cv2打开摄像头卡顿,直接用指令预览不卡

    VEYE MIPI camera
    2
    5
    488
    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.
    • O
      odu last edited by odu

      使用的摄像头是imx385 mipi这是我测试的代码

      import sys
      import time
      import cv2
      
      def read_cam():
          cap = cv2.VideoCapture("v4l2src device=/dev/video0 ! video/x-raw, format=UYVY, width=1920, height=1080, framerate=30/1 ! videoconvert ! video/x-raw, format=I420 ! appsink", cv2.CAP_GSTREAMER)
          if cap.isOpened():
              while True:
                  print(time.time())
                  ret_val, img = cap.read()
                  print(time.time())
                  print("---")
                  img2 = cv2.cvtColor(img, cv2.COLOR_YUV2BGR_I420)
                  
                  if not ret_val:
                      print("无法获取图像")
                      break
      
                  cv2.imshow("CSI Camera", img2)
                  if cv2.waitKey(1) == ord('q'):
                      break
          else:
              print("camera open failed")
          cv2.destroyAllWindows()
      if __name__ == '__main__':
          read_cam()
          
      

      运行结果如下,读取一次花0.2秒多,该怎么办
      4cdd2dc6-f165-460e-ba97-02000c4c954e-13bf70827358f4f45e77ff096d0c9b5.jpg
      如果直接使用指令预览不会卡

      gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! "video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1920, height=(int)1080" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)NV12" ! nv3dsink sync=false
      
      veye_xumm 1 Reply Last reply Reply Quote 0
      • veye_xumm
        veye_xumm @odu last edited by

        @odu 是这样的,现在opencv的这个demo主要用于演示怎样把图像导入到opencv,是个简单化的demo。不是用于实际应用的范例。
        这里面,主要由于使用了纯软件的方法进行图像格式转换和搬运,因此效率比较低。

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

          @veye_xumm 那我该怎么样应用才不卡呢

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

            @odu 你想做什么功能的app

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

              @veye_xumm 想在cv2使用

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