Git Product home page Git Product logo

rscam's People

Contributors

forgemo avatar joelgallant avatar johnb8 avatar loyd avatar newpavlov avatar palladinium avatar yohanesu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rscam's Issues

Pushing a frame to a vector causing unbounded blocking

I want to create a vector of 10 frames. The following code will block.

fn main() {
    let mut camera = rscam::new("/dev/video0").unwrap();

    camera.start(&rscam::Config {
        interval: (1, 30),      // 30 fps.
        resolution: (1280, 720),
        format: b"MJPG",
        ..Default::default()
    }).unwrap();

    let mut vec = Vec::with_capacity(10);

    for i in 0..vec.capacity() {
        let frame = camera.capture().unwrap();
        vec.push(frame);
    }
}

Using "RGB3" mode crashes system

I'm using rscam 0.5.0 on a TX2 system ( aarch64-unknown-linux-gnu ) with an attached capture device that is accessible through /dev/video0.

Running the format example shows (among others) these settings:

UYVY (UYVY 4:2:2)
  640x480  Discretes: 60fps
  720x480  Discretes: 60fps
  720x576  Discretes: 50fps
  1280x720  Discretes: 50fps, 60fps
  1920x1080  Discretes: 24fps, 25fps, 30fps, 50fps, 60fps
  3840x2160  Discretes: 30fps
  4096x2160  Discretes: 30fps
RGB3 (24-bit RGB 8-8-8)
  640x480  Discretes: 60fps
  720x480  Discretes: 60fps
  720x576  Discretes: 50fps
  1280x720  Discretes: 50fps, 60fps
  1920x1080  Discretes: 24fps, 25fps, 30fps, 50fps, 60fps
  3840x2160  Discretes: 30fps
  4096x2160  Discretes: 30fps

Running the capture example with default values works as expected.

Running the capture example with the format specified as "RGB3" either does not produce any output (without terminating) or freezes the whole system followed by a restart.

Using v4l through VLC and specifying RGB3 seems to work fine, so it seems this might be an issue with rscam.

Relicense under dual MIT/Apache-2.0

This issue was automatically generated. Feel free to close without ceremony if
you do not agree with re-licensing or if it is not possible for other reasons.
Respond to @cmr with any questions or concerns, or pop over to
#rust-offtopic on IRC to discuss.

You're receiving this because someone (perhaps the project maintainer)
published a crates.io package with the license as "MIT" xor "Apache-2.0" and
the repository field pointing here.

TL;DR the Rust ecosystem is largely Apache-2.0. Being available under that
license is good for interoperation. The MIT license as an add-on can be nice
for GPLv2 projects to use your code.

Why?

The MIT license requires reproducing countless copies of the same copyright
header with different names in the copyright field, for every MIT library in
use. The Apache license does not have this drawback. However, this is not the
primary motivation for me creating these issues. The Apache license also has
protections from patent trolls and an explicit contribution licensing clause.
However, the Apache license is incompatible with GPLv2. This is why Rust is
dual-licensed as MIT/Apache (the "primary" license being Apache, MIT only for
GPLv2 compat), and doing so would be wise for this project. This also makes
this crate suitable for inclusion and unrestricted sharing in the Rust
standard distribution and other projects using dual MIT/Apache, such as my
personal ulterior motive, the Robigalia project.

Some ask, "Does this really apply to binary redistributions? Does MIT really
require reproducing the whole thing?" I'm not a lawyer, and I can't give legal
advice, but some Google Android apps include open source attributions using
this interpretation. Others also agree with
it
.
But, again, the copyright notice redistribution is not the primary motivation
for the dual-licensing. It's stronger protections to licensees and better
interoperation with the wider Rust ecosystem.

How?

To do this, get explicit approval from each contributor of copyrightable work
(as not all contributions qualify for copyright, due to not being a "creative
work", e.g. a typo fix) and then add the following to your README:

## License

Licensed under either of

 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.

and in your license headers, if you have them, use the following boilerplate
(based on that used in Rust):

// Copyright 2016 rscam Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

It's commonly asked whether license headers are required. I'm not comfortable
making an official recommendation either way, but the Apache license
recommends it in their appendix on how to use the license.

Be sure to add the relevant LICENSE-{MIT,APACHE} files. You can copy these
from the Rust repo for a plain-text
version.

And don't forget to update the license metadata in your Cargo.toml to:

license = "MIT OR Apache-2.0"

I'll be going through projects which agree to be relicensed and have approval
by the necessary contributors and doing this changes, so feel free to leave
the heavy lifting to me!

Contributor checkoff

To agree to relicensing, comment with :

I license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to chose either at their option.

Or, if you're a contributor, you can check the box in this repo next to your
name. My scripts will pick this exact phrase up and check your checkbox, but
I'll come through and manually review this issue later as well.

Failing to create camera with EINVAL in mmap

I'm trying to use a PS Eye with a Raspberry pi, and when I try to run the example script in the docs, the mmap returns an OS Error (EINVAL). The exact code adapted for acceptable framerates, resolutions, etc. is:

extern crate rscam;

use rscam::{Camera, Config};

fn main() {
    let mut camera = Camera::new("/dev/video0").unwrap();

    camera.start(&Config {
        interval: (1, 30),
        resolution: (320, 240),
        format: b"RGB3",
        ..Default::default()
    }).unwrap();

    for i in 0..10 {
        let frame = camera.capture().unwrap();
    }
}

Iterator<Item=(u32, u32)> for Discrete/Stepwise enums (`ResolutionInfo` and `IntervalInfo`)

Re: #10

In the example Stepwise variant represents
{ ∀k≥0,m≥0 | (min(320 + kstep.0, 640), min(240 + mstep.1, 360)) }

It would be useful to have an iterator over this, for all enums with Discrete/Stepwise, i.e. ResolutionInfo and IntervalInfo.

E.g. it could be done by merging both types into one, as they are basically the same, and then making both an alias for that type. And then implementing Iterator<Item=(u32, u32)> for this type.

Having an iterator would make it easier to find the best setting to choose, as they can be zipped and mapped with a custom weighing function between fps and resolution, and then find the .max() :)

Jpeg files written from captured frames are corrupted

Hi.

I captured some frames and saved it to files.
And I copied the files to local machine and tried to open it by photo viewer, but it said that "The format is not supported.".
By using ImageMagick's imdisplay command, I can see the image with a warning dialog says that some extraneous bytes before marker 0xdxx.

The output of lsusb command is as follows.

$ lsusb
Bus 001 Device 005: ID 046d:0825 Logitech, Inc. Webcam C270
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

My source is as follows.

let mut camera = Camera::new("/dev/video0").unwrap();
camera.start(&Config {
    interval: (1, 30),
    resolution: (640, 480),
    format: b"MJPG",
    ..Default::default()
}).expect("Failed to start the camera device.")

for i in 0..10 {
    let frame = camera.capture().unwrap();
    let mut file = File::create(&format!( "assets/frame-{}.jpg", i )).unwrap();
    file.write_all(&frame).unwrap();
}

Binary data of one of the files are as follows.

00000000: ff d8 ff e0 00 21 41 56 49 31 00 01 01 01 00 78 |   .....!AVI1.....x 
00000010: 00 78 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |   .x..............
00000020: 00 00 00 00 00 ff db 00 43 00 08 05 06 07 06 05 |   ........C.......
00000030: 08 07 06 07 09 08 08 09 0c 14 0d 0c 0b 0b 0c 18 |   ................
00000040: 11 12 0e 14 1d 19 1e 1e 1c 19 1c 1f 20 24 2e 27 |   ............ $.'
00000050: 20 22 2b 22 1b 1c 28 34 28 2b 2f 31 33 34 33 1f |    "+"..(4(+/1343.
00000060: 26 38 3c 38 32 3c 2e 32 33 31 ff db 00 43 01 08 |   &8<82<.231...C..
00000070: 09 09 0c 0a 0c 17 0d 0d 17 31 21 1c 21 31 31 31 |   .........1!.!111
00000080: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 |   1111111111111111
00000090: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 |   1111111111111111
000000a0: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 ff |   111111111111111.
...(omit)...
000064e0: 15 ec 63 e5 90 6d 63 ef da b9 9a 51 77 43 62 a9 |   ..c..mc....QwCb.
000064f0: c7 34                                           |   .4

Jpeg files start at ffd8 and end at ffd9, so I think that just a part of the captured data is written to the file.
(Additionally, it might be strange that a number of 00 bytes and 31 bytes are repeated...)

What should I do about it?
Have I missed any dependencies or procedures?

Pi Camera Module 3 not working with rscam

How do you take pictures with stepwise camera using this crate?

I didn't find any issues using this crate to take pictures using discrete cameras.

I am using pi cam module 3 and it only supports stepwise. Could anybody advise me on how to proceed?

InvalidInput for Camera::start with a valid config, only in release mode

When running a --release build (no non-standard options), Camera::start, which functions correctly with debug mode, throws the error: Io(Os { code: 22, kind: InvalidInput, message: "Invalid argument" }). I cannot adjust the options correctly to get it to not do this, and the options I select do show up when doing camera.resolution, etc.

As far as I can tell, it derives from here:
https://github.com/loyd/rscam/blob/5e7a429fe1faed82925832c5ea5d3c9dadb6b239/src/v4l2.rs#L87-90

This led me down the path of enabling the no_wrapper feature, which did work in release mode, but changed the available formats, frame rates, etc. that it would allow me to use. I assume that differences between release and debug are not intentional, so I'd rather avoid that road.

It's worth mentioning that I am cross compiling for armv7-unknown-linux-gnueabihf.

I'm going to look in to this issue since it does matter to me for my project, but if you have any ideas I'd love any tips you might have?

v4l2 support in Rust

Apologies for this non-issue issue, but I wasn't sure the best channel to open communication.

I am interested in working with /dev/radioX rather than /dev/videoX. rscam as is doesn't really support this, but looks to have a good approach to supporting v4l2 in Rust. I have created the crate v4l2-sys using bindgen as a first step to using /dev/radioX from Rust. Is useful/of interest to the rscam folk? Is there merit in creating a more generalised Rust side binding to v4l2 based on v4l2-sys?

https://crates.io/crates/v4l2-sys

Fails to compile on MacOS

I'm using this crate as a dependant from oli-obk/camera_capture

I'm getting the following error:

error[E0425]: cannot find value `VIDIOC_STREAMON` in module `v4l2`
   --> /Users/teo/.cargo/registry/src/github.com-1ecc6299db9ec823/rscam-0.5.4/src/lib.rs:649:42
    |
649 |         try!(v4l2::xioctl(self.fd, v4l2::VIDIOC_STREAMON, &mut typ));
    |                                          ^^^^^^^^^^^^^^^ not found in `v4l2`

error[E0425]: cannot find value `VIDIOC_STREAMOFF` in module `v4l2`
   --> /Users/teo/.cargo/registry/src/github.com-1ecc6299db9ec823/rscam-0.5.4/src/lib.rs:656:42
    |
656 |         try!(v4l2::xioctl(self.fd, v4l2::VIDIOC_STREAMOFF, &mut typ));
    |                                          ^^^^^^^^^^^^^^^^ not found in `v4l2`

Using the latest rscam and camera_capture

Documentation for Camera::resolutions

Hey there. Your bindings look really cool, thanks for writing them :)

I'm having a big of an issue though with camera.resolutions(...). It's nowhere documented what numbers to provide it and since I can't really find any good docs online either I was wondering if you could add some explanation to the function comment.

camera struct does not destruct properly

First off, I wanted to say I've been using this library for a bit and it's been great.
I've hit a snag though: I can't reopen my cameras!

Take this code:

extern crate rscam;

use rscam::{Camera, Config};

fn main() {
    let path = "/dev/video0";
    {
        let mut camera = Camera::new(path).unwrap();
        camera.start(&Config {
            interval: (1, 30),
            resolution: (640, 480),
            format: b"MJPG",
            .. Default::default()
        }).unwrap();
        camera.capture().unwrap();
    }
    {
        let mut camera = Camera::new(path).unwrap();
        camera.start(&Config {
            interval: (1, 30),
            resolution: (640, 480),
            format: b"MJPG",
            .. Default::default()
        }).unwrap();
        camera.capture().unwrap();
    }
}

I should be able to take a picture twice, although this panics on the second call to start.
I get this error, which implies that something didn't get destructed properly:
libv4l2: error setting pixformat: Device or resource busy

Bad Support for RGB3 frame format

Hello,

I can not get correct image data with RGB3 frame format, but YUYV is ok, So sugguest to check the support for RGB3 frame format.

Thanks

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.