roboflex.webcam-uvc


Nameroboflex.webcam-uvc JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttps://github.com/flexrobotics/roboflex_webcamuvc
SummaryRoboflex Library that supports UVC-Compatible Webcams
upload_time2023-12-05 23:31:54
maintainer
docs_urlNone
authorColin Prepscius
requires_python>=3.6
licenseMIT
keywords webcam uvc robotics middleware flexbuffers python c++ c++20
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # roboflex.webcam_uvc

Support for web cameras on linux - actually just a thin wrapper around libuvc, so if your camera supports libuvc, you should be good to go.

## System dependencies

    apt-get install libusb-1.0-0-dev
    apt-get install libjpeg-dev

    # ...or, on mac:

    brew install libusb

## pip install

    pip install roboflex.webcam_uvc

## Import

    import roboflex.webcam_uvc as rcw

## Nodes

There is only one: **WebcamSensor**

    # all parameters optional: below are the defaults
    webcam_sensor = rcw.WebcamSensor(
        width,
        height,
        fps,
        device_index = -1,
        format = UVC_FRAME_FORMAT_ANY,
        name = "WebcamSensor",
    )

    # must be started!
    webcam_sensor.start()

    # you can do this:
    webcam_sensor.print_device_info()

## Messages

    from roboflex.webcam_uvc import WebcamDataRGB

API:

    # the timestamp just before reading from device
    message.t0 -> Float

    # the timestamp just after reading from device
    message.t1 -> Float

    # the capture time from the device
    message.capture_time -> Float

    # the sequence number from the device
    message.sequence -> Int

    # numpy array of shape=(width, height, channels), dtype=short
    message.rgb -> np.ndarray

DYNOFLEX:

    # the timestamp just before reading from device
    message["t0"] -> Double

    # the timestamp just after reading from device
    message["t1"] -> Double

    # the capture time from the device
    message["t"] -> Double

    # the sequence number from the device
    message["s"] -> Double

    # numpy array of shape=(width, height, channels), dtype=short
    message["rgb"] -> np.ndarray


## Other


Description of a device:

    from roboflex.webcam_uvc import DeviceDescriptor

    dd.idVendor -> int
    dd.idProduct -> int
    dd.bcdUVC -> int
    dd.serialNumber -> str
    dd.manufacturer -> str
    dd.product -> str

    # you probably just want to print it:
    str(dd)


Free function: get list of connected devices (webcams) - list of DeviceDescriptor, above.

    get_device_list() -> [DeviceDescriptor]

Available frame formats: pass to constructor of WebcamSensor for the format parameter.

    from roboflex.webcam_uvc import uvc_frame_format

    uvc_frame_format.UVC_FRAME_FORMAT_ANY
    uvc_frame_format.UVC_FRAME_FORMAT_UNCOMPRESSED
    uvc_frame_format.UVC_FRAME_FORMAT_COMPRESSED

    # YUYV/YUV2/YUV422: YUV encoding with one luminance value per pixel and
    # one UV (chrominance) pair for every two pixels.
    uvc_frame_format.UVC_FRAME_FORMAT_YUYV
    uvc_frame_format.UVC_FRAME_FORMAT_UYVY

    # 24-bit RGB
    uvc_frame_format.UVC_FRAME_FORMAT_RGB
    uvc_frame_format.UVC_FRAME_FORMAT_BGR

    # Motion-JPEG (or JPEG) encoded images
    uvc_frame_format.UVC_FRAME_FORMAT_MJPEG
    uvc_frame_format.UVC_FRAME_FORMAT_H264

    # Greyscale images
    uvc_frame_format.UVC_FRAME_FORMAT_GRAY16
    uvc_frame_format.UVC_FRAME_FORMAT_GRAY8

    # Raw colour mosaic images
    uvc_frame_format.UVC_FRAME_FORMAT_BY8
    uvc_frame_format.UVC_FRAME_FORMAT_BA81
    uvc_frame_format.UVC_FRAME_FORMAT_SGRBG8
    uvc_frame_format.UVC_FRAME_FORMAT_SGBRG8
    uvc_frame_format.UVC_FRAME_FORMAT_SRGGB8
    uvc_frame_format.UVC_FRAME_FORMAT_SBGGR8

    # YUV420: NV12
    uvc_frame_format.UVC_FRAME_FORMAT_NV12

    # Number of formats understood
    uvc_frame_format.UVC_FRAME_FORMAT_COUNT


## Linux webcam help

Access denied to your webcam?

First, list your usb devices and find your webcam:

    lsusb
    
For me, I see:

    Bus 002 Device 025: ID 32e4:9230 HD USB Camera HD USB Camera

create a file called '50-usb-webcam.rules' in /etc/udev/rules.d with a single line:

    SUBSYSTEM=="usb", ATTR{idVendor}="HD USB Camera", ATTR{idProduct}="HD USB Camera", MODE="0666"

then

    udevadm control --reload-rules && udevadm trigger


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/flexrobotics/roboflex_webcamuvc",
    "name": "roboflex.webcam-uvc",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "webcam,uvc,robotics,middleware,flexbuffers,python,c++,c++20",
    "author": "Colin Prepscius",
    "author_email": "colinprepscius@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/67/63/7bbfcfa95d34e58974f8f01a666fee0edd128306ba9722f3d28618cf4053/roboflex.webcam_uvc-0.1.6.tar.gz",
    "platform": null,
    "description": "# roboflex.webcam_uvc\n\nSupport for web cameras on linux - actually just a thin wrapper around libuvc, so if your camera supports libuvc, you should be good to go.\n\n## System dependencies\n\n    apt-get install libusb-1.0-0-dev\n    apt-get install libjpeg-dev\n\n    # ...or, on mac:\n\n    brew install libusb\n\n## pip install\n\n    pip install roboflex.webcam_uvc\n\n## Import\n\n    import roboflex.webcam_uvc as rcw\n\n## Nodes\n\nThere is only one: **WebcamSensor**\n\n    # all parameters optional: below are the defaults\n    webcam_sensor = rcw.WebcamSensor(\n        width,\n        height,\n        fps,\n        device_index = -1,\n        format = UVC_FRAME_FORMAT_ANY,\n        name = \"WebcamSensor\",\n    )\n\n    # must be started!\n    webcam_sensor.start()\n\n    # you can do this:\n    webcam_sensor.print_device_info()\n\n## Messages\n\n    from roboflex.webcam_uvc import WebcamDataRGB\n\nAPI:\n\n    # the timestamp just before reading from device\n    message.t0 -> Float\n\n    # the timestamp just after reading from device\n    message.t1 -> Float\n\n    # the capture time from the device\n    message.capture_time -> Float\n\n    # the sequence number from the device\n    message.sequence -> Int\n\n    # numpy array of shape=(width, height, channels), dtype=short\n    message.rgb -> np.ndarray\n\nDYNOFLEX:\n\n    # the timestamp just before reading from device\n    message[\"t0\"] -> Double\n\n    # the timestamp just after reading from device\n    message[\"t1\"] -> Double\n\n    # the capture time from the device\n    message[\"t\"] -> Double\n\n    # the sequence number from the device\n    message[\"s\"] -> Double\n\n    # numpy array of shape=(width, height, channels), dtype=short\n    message[\"rgb\"] -> np.ndarray\n\n\n## Other\n\n\nDescription of a device:\n\n    from roboflex.webcam_uvc import DeviceDescriptor\n\n    dd.idVendor -> int\n    dd.idProduct -> int\n    dd.bcdUVC -> int\n    dd.serialNumber -> str\n    dd.manufacturer -> str\n    dd.product -> str\n\n    # you probably just want to print it:\n    str(dd)\n\n\nFree function: get list of connected devices (webcams) - list of DeviceDescriptor, above.\n\n    get_device_list() -> [DeviceDescriptor]\n\nAvailable frame formats: pass to constructor of WebcamSensor for the format parameter.\n\n    from roboflex.webcam_uvc import uvc_frame_format\n\n    uvc_frame_format.UVC_FRAME_FORMAT_ANY\n    uvc_frame_format.UVC_FRAME_FORMAT_UNCOMPRESSED\n    uvc_frame_format.UVC_FRAME_FORMAT_COMPRESSED\n\n    # YUYV/YUV2/YUV422: YUV encoding with one luminance value per pixel and\n    # one UV (chrominance) pair for every two pixels.\n    uvc_frame_format.UVC_FRAME_FORMAT_YUYV\n    uvc_frame_format.UVC_FRAME_FORMAT_UYVY\n\n    # 24-bit RGB\n    uvc_frame_format.UVC_FRAME_FORMAT_RGB\n    uvc_frame_format.UVC_FRAME_FORMAT_BGR\n\n    # Motion-JPEG (or JPEG) encoded images\n    uvc_frame_format.UVC_FRAME_FORMAT_MJPEG\n    uvc_frame_format.UVC_FRAME_FORMAT_H264\n\n    # Greyscale images\n    uvc_frame_format.UVC_FRAME_FORMAT_GRAY16\n    uvc_frame_format.UVC_FRAME_FORMAT_GRAY8\n\n    # Raw colour mosaic images\n    uvc_frame_format.UVC_FRAME_FORMAT_BY8\n    uvc_frame_format.UVC_FRAME_FORMAT_BA81\n    uvc_frame_format.UVC_FRAME_FORMAT_SGRBG8\n    uvc_frame_format.UVC_FRAME_FORMAT_SGBRG8\n    uvc_frame_format.UVC_FRAME_FORMAT_SRGGB8\n    uvc_frame_format.UVC_FRAME_FORMAT_SBGGR8\n\n    # YUV420: NV12\n    uvc_frame_format.UVC_FRAME_FORMAT_NV12\n\n    # Number of formats understood\n    uvc_frame_format.UVC_FRAME_FORMAT_COUNT\n\n\n## Linux webcam help\n\nAccess denied to your webcam?\n\nFirst, list your usb devices and find your webcam:\n\n    lsusb\n    \nFor me, I see:\n\n    Bus 002 Device 025: ID 32e4:9230 HD USB Camera HD USB Camera\n\ncreate a file called '50-usb-webcam.rules' in /etc/udev/rules.d with a single line:\n\n    SUBSYSTEM==\"usb\", ATTR{idVendor}=\"HD USB Camera\", ATTR{idProduct}=\"HD USB Camera\", MODE=\"0666\"\n\nthen\n\n    udevadm control --reload-rules && udevadm trigger\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Roboflex Library that supports UVC-Compatible Webcams",
    "version": "0.1.6",
    "project_urls": {
        "Homepage": "https://github.com/flexrobotics/roboflex_webcamuvc"
    },
    "split_keywords": [
        "webcam",
        "uvc",
        "robotics",
        "middleware",
        "flexbuffers",
        "python",
        "c++",
        "c++20"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "67637bbfcfa95d34e58974f8f01a666fee0edd128306ba9722f3d28618cf4053",
                "md5": "3e9643634d0e1c4abb67d3beaa6ef413",
                "sha256": "b2f2b64f041bab0e3fbb5995290784418b01b5445ef2ffa3d5bdd32b13fa93e1"
            },
            "downloads": -1,
            "filename": "roboflex.webcam_uvc-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "3e9643634d0e1c4abb67d3beaa6ef413",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12822,
            "upload_time": "2023-12-05T23:31:54",
            "upload_time_iso_8601": "2023-12-05T23:31:54.818094Z",
            "url": "https://files.pythonhosted.org/packages/67/63/7bbfcfa95d34e58974f8f01a666fee0edd128306ba9722f3d28618cf4053/roboflex.webcam_uvc-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-05 23:31:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "flexrobotics",
    "github_project": "roboflex_webcamuvc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "roboflex.webcam-uvc"
}
        
Elapsed time: 0.14857s