Simple Python native access library for Video4Linux camera devices
==================================================================
*Warning*: Work (slowly) in progress. Currently hardwired to YUV format.
This will be fixed soon
This is a simple library that allows one to access camera devices
accessible via Video4Linux from Python without using libraries with huge
dependency chains that allows easy and fast testing of ideas and
algorithms for image processing before implementing them in a proper way
in some programming language such as C. It’s built in the most simple
way on purpose.
Tested on:
- Python 3.8:
- FreeBSD 12 (amd64, aarch64)
- FreeBSD 13 (amd64, aarch64)
Currently not implemented / not optimal
---------------------------------------
- Currently the library does not support anything else than YUV422
captures from the cameras and only outputs RGB888 images as nested
Python lists. This will be fixed as soon as possible but will
introduce a breaking change.
Installing via PyPi
===================
Note that you have to install some native packages on FreeBSD before
building the extension. Those are:
- ``multimedia/v4l_compat``
- ``multimedia/webcamd``
To install and start the required services:
::
pkg install multimedia/v4l_compat multimedia/webcamd
echo "webcamd_enable=\"YES\"" >> /etc/rc.conf
echo "cuse_load=\"YES\"" >> /boot/loader.conf
kldload cuse
/etc/rc.d/devd restart
/usr/local/etc/rc.d/webcamd start
The package is available as a source distribution via PyPi:
::
pip install simplepycam-tspspi
Building
========
Use ``setup.py`` in ``cext``:
::
$ python setup.py build
Example usage
=============
More sophisticated examples can be found in the ``samples`` directory.
Using the stream callback interface, the default format and with
----------------------------------------------------------------
::
import simplepycam
def processFrame(camera, frame):
if shouldStopProcessing:
return False
else:
return True
with simplepycam.Camera("/dev/video0") as cam:
cam.frameCallback = [ processFrame ]
cam.stream()
Using the stream callback interface, the default format and open/close
----------------------------------------------------------------------
::
import simplepycam
def processFrame(camera, frame):
if shouldStopProcessing:
return False
else:
return True
cam = simplepycam.Camera("/dev/video0")
cam.open()
cam.frameCallback = [ processFrame ]
cam.stream()
cam.close()
Using the polling API, the default format and with
--------------------------------------------------
::
import simplepycam
with simplepycam.Camera("/dev/video0") as cam:
cam.streamOn()
for i in range(100):
frame = cam.nextFrame()
cam.streamOff()
Using the polling API, the default format and open/close
--------------------------------------------------------
::
import simplepycam
cam = simplepycam.Camera("/dev/video0")
cam.open()
cam.streamOn()
for i in range(100):
frame = cam.nextFrame()
cam.streamOff()
cam.close()
API documentation
=================
.. figure::
https://raw.githubusercontent.com/tspspi/simplepycam/master/doc/pythonuml.png
:alt: UML diagram of Python side
UML diagram of Python side
Raw data
{
"_id": null,
"home_page": "https://github.com/tspspi/simplepycam",
"name": "simplepycam-tspspi",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Thomas Spielauer",
"author_email": "pypipackages01@tspi.at",
"download_url": "https://files.pythonhosted.org/packages/f1/27/0e8c5039deb1b8f05005c5c64f75fd5ff80e937a2aa5fbcf2421e29fee7c/simplepycam-tspspi-0.1.7.tar.gz",
"platform": null,
"description": "Simple Python native access library for Video4Linux camera devices\n==================================================================\n\n*Warning*: Work (slowly) in progress. Currently hardwired to YUV format.\nThis will be fixed soon\n\nThis is a simple library that allows one to access camera devices\naccessible via Video4Linux from Python without using libraries with huge\ndependency chains that allows easy and fast testing of ideas and\nalgorithms for image processing before implementing them in a proper way\nin some programming language such as C. It\u2019s built in the most simple\nway on purpose.\n\nTested on:\n\n- Python 3.8:\n\n - FreeBSD 12 (amd64, aarch64)\n - FreeBSD 13 (amd64, aarch64)\n\nCurrently not implemented / not optimal\n---------------------------------------\n\n- Currently the library does not support anything else than YUV422\n captures from the cameras and only outputs RGB888 images as nested\n Python lists. This will be fixed as soon as possible but will\n introduce a breaking change.\n\nInstalling via PyPi\n===================\n\nNote that you have to install some native packages on FreeBSD before\nbuilding the extension. Those are:\n\n- ``multimedia/v4l_compat``\n- ``multimedia/webcamd``\n\nTo install and start the required services:\n\n::\n\n pkg install multimedia/v4l_compat multimedia/webcamd\n echo \"webcamd_enable=\\\"YES\\\"\" >> /etc/rc.conf\n echo \"cuse_load=\\\"YES\\\"\" >> /boot/loader.conf\n kldload cuse\n /etc/rc.d/devd restart\n /usr/local/etc/rc.d/webcamd start\n\nThe package is available as a source distribution via PyPi:\n\n::\n\n pip install simplepycam-tspspi\n\nBuilding\n========\n\nUse ``setup.py`` in ``cext``:\n\n::\n\n $ python setup.py build\n\nExample usage\n=============\n\nMore sophisticated examples can be found in the ``samples`` directory.\n\nUsing the stream callback interface, the default format and with\n----------------------------------------------------------------\n\n::\n\n import simplepycam\n\n def processFrame(camera, frame):\n if shouldStopProcessing:\n return False\n else:\n return True\n\n with simplepycam.Camera(\"/dev/video0\") as cam:\n cam.frameCallback = [ processFrame ]\n cam.stream()\n\nUsing the stream callback interface, the default format and open/close\n----------------------------------------------------------------------\n\n::\n\n import simplepycam\n\n def processFrame(camera, frame):\n if shouldStopProcessing:\n return False\n else:\n return True\n\n cam = simplepycam.Camera(\"/dev/video0\")\n cam.open()\n cam.frameCallback = [ processFrame ]\n cam.stream()\n cam.close()\n\nUsing the polling API, the default format and with\n--------------------------------------------------\n\n::\n\n import simplepycam\n\n with simplepycam.Camera(\"/dev/video0\") as cam:\n cam.streamOn()\n for i in range(100):\n frame = cam.nextFrame()\n cam.streamOff()\n\nUsing the polling API, the default format and open/close\n--------------------------------------------------------\n\n::\n\n import simplepycam\n\n cam = simplepycam.Camera(\"/dev/video0\")\n cam.open()\n cam.streamOn()\n for i in range(100):\n frame = cam.nextFrame()\n cam.streamOff()\n cam.close()\n\nAPI documentation\n=================\n\n.. figure::\n https://raw.githubusercontent.com/tspspi/simplepycam/master/doc/pythonuml.png\n :alt: UML diagram of Python side\n\n UML diagram of Python side\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Simple Python native access library for Video4Linux camera devices",
"version": "0.1.7",
"project_urls": {
"Homepage": "https://github.com/tspspi/simplepycam"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f1270e8c5039deb1b8f05005c5c64f75fd5ff80e937a2aa5fbcf2421e29fee7c",
"md5": "172daa05836e8b73ad99873070ea12fc",
"sha256": "cf9d554c1372e4590752ce93f2ea0e89783bd8aa1ae4ea0bd3a10d245fdffc12"
},
"downloads": -1,
"filename": "simplepycam-tspspi-0.1.7.tar.gz",
"has_sig": false,
"md5_digest": "172daa05836e8b73ad99873070ea12fc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 12820,
"upload_time": "2024-03-27T16:22:33",
"upload_time_iso_8601": "2024-03-27T16:22:33.446289Z",
"url": "https://files.pythonhosted.org/packages/f1/27/0e8c5039deb1b8f05005c5c64f75fd5ff80e937a2aa5fbcf2421e29fee7c/simplepycam-tspspi-0.1.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-27 16:22:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tspspi",
"github_project": "simplepycam",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "simplepycam-tspspi"
}