Skip to main content

Python wrapper for USB, blackfly, Raspi, Jetson Nano camerasWorks on Windows, Raspian, JetsonNano, MacOS

Project description

A collection of python threaded camera support routines for

  • USB and laptop internal webcams

  • RTSP streams

  • MIPI CSI cameras (Raspberry Pi, Jetson Nano)

  • FLIR blackfly (USB)

Save data as

  • HD5

  • tiff

  • avi

Works on

  • Windows

  • MacOS

  • Unix

Documentation

For detailed documentation please Readme.md.

Example Program using camera

import cv2
import logging
import time
from queue import Queue

configs = {
 'camera_res'      : (1920, 1080),   # CAP_PROP_FRAME_WIDTH, CAP_PROP_FRAME_HEIGHT
 'exposure'        : -6,             # depends on camera: e.g. -5 =(2^-5)=1/32, 0 = auto, 1...max=frame interval in microseconds
 'autoexposure'    : 3.0,            # depends on camera: 0.25 or 0.75(auto), -1,0,1
 'fps'             : 30,             # fps
 'fourcc'          : "MJPG",         # cv2 camera only: MJPG, YUY2, YUYV
 'buffersize'      : -1,             # default is 4 for V4L2, max 10,
 'output_res'      : (-1, -1),       # output resolution (-1 = no change)
 'flip'            : 0,              # 0 = norotation
 'displayfps'      : 5               # frame rate for display server
}

if configs['displayfps'] >= configs['fps']: display_interval = 0
else: display_interval = 1.0/configs['displayfps']

cv2.namedWindow('Camera', cv2.WINDOW_AUTOSIZE) # or WINDOW_NORMAL

# Setting up logging
logging.basicConfig(level=logging.DEBUG) # options are: DEBUG, INFO, ERROR, WARNING

# Setting up input and/or output Queue
captureQueue = Queue(maxsize=32)
storageQueue = Queue(maxsize=64)

# Setting up storage
from camera.streamer.mkvstorageserver import mkvServer
mkv = mkvServer("C:\\temp\\" + "Test.mkv", configs['fps'], configs['camera_res'])
mkv.start(storageQueue)

# Create camera interface
from camera.capture.cv2capture import cv2Capture
camera = cv2Capture(configs, 0)
camera.start(captureQueue)

while(cv2.getWindowProperty('Camera', 0) >= 0):
   current_time = time.time()

   # Wait for new image
   (frame_time, frame) = captureQueue.get(block=True, timeout=None)
   # put image into storage queue
   if not storageQueue.full():
      storageQueue.put((frame_time, frame), block=False)

   # Display
   if (current_time - last_display) >= display_interval:
      cv2.imshow('Camera', frame)
      if cv2.waitKey(1) & 0xFF == ord('q'):
            break
      last_display = current_time

   # Do other things

# Clean up
camera.stop()
cv2.destroyAllWindows()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

camera-util-1.0.1.tar.gz (52.6 kB view details)

Uploaded Source

Built Distribution

camera_util-1.0.1-py2.py3-none-any.whl (38.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file camera-util-1.0.1.tar.gz.

File metadata

  • Download URL: camera-util-1.0.1.tar.gz
  • Upload date:
  • Size: 52.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for camera-util-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d58cd2da4c594ec19a868ca2e804a707216b3fd86d2eae84801bede1cfdef748
MD5 1812aa93464bc4fd7f65c66e36dce95b
BLAKE2b-256 ee6e0fa98bd1114b9f05f326d885272c8c22f3d94831ddf8fabd50a84be7cc78

See more details on using hashes here.

File details

Details for the file camera_util-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: camera_util-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 38.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for camera_util-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1923f47261fba3cebd7a48d5cb7980c28e79e6894703cfc7b869d882af0e3bd6
MD5 e69454319d3dd5ae22ad0f27bfab1bf2
BLAKE2b-256 1bf2d72b201241935611c56596572fd002c8a320e95083c2798cd4d85ae5afd9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page