Git Product home page Git Product logo

omnicamera's Introduction

OmniCamera

A library for querying and capturing from cameras, based on nokhwa crate.

Examples

Query available cameras:

print(*omni_camera.query(), sep='\n')

Example output:

CameraInfo(index=2, name='UVC Camera (046d:0809)', description='Video4Linux Device @ /dev/video2', misc='')
CameraInfo(index=0, name='USB2.0 VGA UVC WebCam: USB2.0 V', description='Video4Linux Device @ /dev/video0', misc='')

Save an image (note: requires pillow to be installed):

import omni_camera
import time
cam = omni_camera.Camera(camerata.query()[0]) # Open a camera
while cam.poll_frame_pil() is None: # Note that .poll_frame_* functions never blocks
    time.sleep(0.1) # Wait until we get at least one frame from the camera
#time.sleep(1) # You might want to wait a bit longer while camera is calibrating
img = cam.poll_frame_pil()
img.save("img.png")

See examples/ for more

omnicamera's People

Contributors

intquant avatar

Stargazers

 avatar  avatar NguyenKhoa avatar  avatar Sihan Zhu avatar

Watchers

 avatar  avatar

omnicamera's Issues

Fail to build with python 3.12.3+

Too old Py3O causes fail during build

[   66s]   ๐Ÿ Found CPython 3.12 at /usr/bin/python3.12
[   66s]      Compiling pyo3-build-config v0.15.2
[   66s]      Compiling pyo3-macros-backend v0.15.2
[   66s]      Compiling pyo3 v0.15.2
[   68s]      Compiling pyo3-macros v0.15.2
[   68s]   error[E0425]: cannot find function, tuple struct or tuple variant `PyUnicode_READY` in module `ffi`
[   68s]      --> /home/abuild/rpmbuild/BUILD/omni_camera-0.6.0/vendor/pyo3/src/types/string.rs:232:30
[   68s]       |
[   68s]   232 |             let ready = ffi::PyUnicode_READY(ptr);
[   68s]       |                              ^^^^^^^^^^^^^^^ help: a function with a similar name exists: `PyUnicode_IS_READY`
[   68s]       |
[   68s]      ::: /home/abuild/rpmbuild/BUILD/omni_camera-0.6.0/vendor/pyo3/src/ffi/cpython/unicodeobject.rs:224:1
[   68s]       |[
[   68s]   224 | pub unsafe fn PyUnicode_IS_READY(op: *mut PyObject) -> c_uint {
[   68s]       | ------------------------------------------------------------- similarly named function `PyUnicode_IS_READY` defined here
[   68s] 
[   70s]   For more information about this error, try `rustc --explain E0425`.
[   70s]   error: could not compile `pyo3` (lib) due to 1 previous error
[   70s]   ๐Ÿ’ฅ maturin failed
[   70s]     Caused by: Failed to build a native library through cargo
[   70s]     Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_ENVIRONMENT_SIGNATURE="cpython-3.12-64bit" PYO3_PYTHON="/usr/bin/python3.12" PYTHON_SYS_EXECUTABLE="/usr/bin/python3.12" "cargo" "rustc" "--message-format" "json-render-diagnostics" "--manifest-path" "/home/abuild/rpmbuild/BUILD/omni_camera-0.6.0/Cargo.toml" "--release" "--lib"`
[   70s]   Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/usr/bin/python3.12', '--compatibility', 'off'] returned non-zero exit status 1
[   70s]   error: subprocess-exited-with-error
[   70s]   
[   70s]   ร— Building wheel for omni_camera (pyproject.toml) did not run successfully.
[   70s]   โ”‚ exit code: 1
[   70s]   โ•ฐโ”€> See above for output.

Support for Python 3.12

Hi, thank you for all your hard work on this library. However, omni-camera doesn't compile on Python 3.12 due to outdated requirement on pyo3, which added support for Python 3.12 in version 0.20. Could you please take a look at it?

The error is:

[   57s]   Running `maturin pep517 build-wheel -i /usr/bin/python3.12 --compatibility off`
[   57s]   ๐Ÿ“ฆ Including license file "/home/abuild/rpmbuild/BUILD/omni_camera-0.6.0/LICENSE"
[   57s]   ๐Ÿน Building a mixed python/rust project
[   57s]   ๐Ÿ”— Found pyo3 bindings
[   57s]   ๐Ÿ Found CPython 3.12 at /usr/bin/python3.12
[   58s]      Compiling pyo3-build-config v0.15.2
[   58s]      Compiling pyo3-macros-backend v0.15.2
[   58s]      Compiling pyo3 v0.15.2
[   59s]      Compiling pyo3-macros v0.15.2
[   60s]   error[E0425]: cannot find function, tuple struct or tuple variant `PyUnicode_READY` in module `ffi`
[   60s]      --> /home/abuild/rpmbuild/BUILD/omni_camera-0.6.0/vendor/pyo3/src/types/string.rs:232:30
[   60s]       |
[   60s]   232 |             let ready = ffi::PyUnicode_READY(ptr);
[   60s]       |                              ^^^^^^^^^^^^^^^ help: a function with a similar name exists: `PyUnicode_IS_READY`
[   60s]       |
[   60s]      ::: /home/abuild/rpmbuild/BUILD/omni_camera-0.6.0/vendor/pyo3/src/ffi/cpython/unicodeobject.rs:224:1
[   60s]       |
[   60s]   224 | pub unsafe fn PyUnicode_IS_READY(op: *mut PyObject) -> c_uint {
[   60s]       | ------------------------------------------------------------- similarly named function `PyUnicode_IS_READY` defined here
[   60s] 
[   61s]   For more information about this error, try `rustc --explain E0425`.
[   61s]   error: could not compile `pyo3` (lib) due to 1 previous error
[   61s]   ๐Ÿ’ฅ maturin failed
[   61s]     Caused by: Failed to build a native library through cargo
[   61s]     Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_ENVIRONMENT_SIGNATURE="cpython-3.12-64bit" PYO3_PYTHON="/usr/bin/python3.12" PYTHON_SYS_EXECUTABLE="/usr/bin/python3.12" "cargo" "rustc" "--message-format" "json-render-diagnostics" "--manifest-path" "/home/abuild/rpmbuild/BUILD/omni_camera-0.6.0/Cargo.toml" "--release" "--lib"`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.