Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #!/usr/bin/env python3
  2.  
  3. import cv2
  4. import depthai as dai
  5. from depthai_sdk.fps import FPSHandler
  6.  
  7. # Create pipeline
  8. pipeline = dai.Pipeline()
  9.  
  10. # Define sources and output
  11. camRgb = pipeline.create(dai.node.ColorCamera)
  12. # Properties
  13. camRgb.setBoardSocket(dai.CameraBoardSocket.RGB)
  14. camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_12_MP)
  15. camRgb.setFps(30)
  16. camRgb.setIspScale(1, 2)
  17. camRgb.setPreviewKeepAspectRatio(keep=False)
  18.  
  19. # Linking
  20. xoutRgb = pipeline.create(dai.node.XLinkOut)
  21. xoutRgb.setStreamName('rgb')
  22. camRgb.isp.link(xoutRgb.input)
  23.  
  24. # Connect to device and start pipeline
  25. with dai.Device(pipeline) as device:
  26.  
  27.     print('Connected cameras:', device.getConnectedCameraFeatures())
  28.     # Print out usb speed
  29.     print('Usb speed:', device.getUsbSpeed().name)
  30.     # Bootloader version
  31.     if device.getBootloaderVersion() is not None:
  32.         print('Bootloader version:', device.getBootloaderVersion())
  33.     # Device name
  34.     print('Device name:', device.getDeviceName())
  35.  
  36.     fps = FPSHandler()
  37.  
  38.     # Output queue will be used to get the rgb frames from the output defined above
  39.     qRgb = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)
  40.  
  41.     while True:
  42.         inRgb = qRgb.get()  # blocking call, will wait until a new data has arrived
  43.         fps.nextIter()
  44.         print(fps.fps())
  45.  
  46.         # Retrieve 'bgr' (opencv format) frame
  47.         # cv2.imshow("rgb", inRgb.getCvFrame())
  48.  
  49.         if cv2.waitKey(1) == ord('q'):
  50.             break
  51.