Skip to main content

Python library for grabbing images from webcams

Project description

Python library to download images from network accessible webcams.

Features

  • Out of the box, handles any webcam which provides a publically accessible URL to a JPG snapshot of their current image.

  • Easily swap in different downloaders to handle cams which expose their snapshots in a more complex way.

  • Highly configurable.

  • Provides a simple base for more advanced functionality, such as motion detection, CCTV systems, image analysis, etc.

Installation

pip install camgrab

Quick start

To simply grabbing images from a webcam every 2 seconds and start saving them to the default grabbed_images directory:

from camgrab import Grabber
grabber = Grabber('http://78.100.133.169:8888/out.jpg')
grabber.begin()

Examples

Adding a custom image handler

Grab an image every 5 seconds and it to a custom callable, without saving it, and print the image’s dimensions.

from camgrab import Grabber

url = 'http://62.163.242.211:8080/out.jpg'


def print_dimensions(im, **meta):
    width, height = im.size
    print('{width} pixels wide, {height} pixels high!'.format(width=width, height=height))

grabber = Grabber(url, every=5, send_to_callable=print_dimensions)
grabber.save = False
grabber.begin()

Take control of the main loop

As the main loop created by the begin() method is unthreaded, provides no output, has a static delay between grab attempts, etc. it might be too simple for your needs.

To get around this, simply call the tick() method within your own loop:

from random import random
from time import sleep

from camgrab import Grabber

url = 'http://62.163.242.211:8080/out.jpg'
grabber = Grabber(url)

while True:
    grabber.tick()

    # Wait somewhere between 0 and 10 seconds
    sleep(random() * 10)

License

camgrab is free software, distributed under the MIT license.

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

camgrab-0.8.1.tar.gz (200.8 kB view details)

Uploaded Source

Built Distribution

camgrab-0.8.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file camgrab-0.8.1.tar.gz.

File metadata

  • Download URL: camgrab-0.8.1.tar.gz
  • Upload date:
  • Size: 200.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for camgrab-0.8.1.tar.gz
Algorithm Hash digest
SHA256 dc5cd35e27ae6bfa4c3477e73ce895b30d7636bce485be566fbe05f15b197404
MD5 2677aa1ab0fca2da027dd9369c89788e
BLAKE2b-256 1a18452c4f99378e88a5109477a7a571e7e2123690e5f645e9e20bbb9752ce86

See more details on using hashes here.

File details

Details for the file camgrab-0.8.1-py3-none-any.whl.

File metadata

File hashes

Hashes for camgrab-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d18ba16bcfa0e0ff639f4acee512c639bdf2b2a09e3cc3b71476721f1624e919
MD5 e29cc06e54e95e46ebd2d3cbccedd4a5
BLAKE2b-256 7f69eae709e7462a579804c6968bf41ef8e40313de22c068c7bd3feaf78c4f26

See more details on using hashes here.

Supported by

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