rscam icon indicating copy to clipboard operation
rscam copied to clipboard

Documentation for Camera::resolutions

Open spacekookie opened this issue 6 years ago • 1 comments

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.

spacekookie avatar Feb 23 '18 20:02 spacekookie

Hi, thanks for the question. I will try to add some information to the documentation in the future.

If you run formats example, you'll see something like this:

MJPG (Motion-JPEG, compressed)
  1280x720  Discretes: 30fps
  848x480  Discretes: 30fps
  960x540  Discretes: 30fps
YUYV (YUYV 4:2:2)
  640x480  Discretes: 30fps
  160x120  Discretes: 30fps
  320x180  Discretes: 30fps
  320x240  Discretes: 30fps
  424x240  Discretes: 30fps
  640x360  Discretes: 30fps
RGB3 (RGB3, emulated)
  1280x720  Discretes: 30fps
  848x480  Discretes: 30fps
  960x540  Discretes: 30fps
  640x480  Discretes: 30fps
  160x120  Discretes: 30fps
  320x180  Discretes: 30fps
  320x240  Discretes: 30fps
  424x240  Discretes: 30fps
  640x360  Discretes: 30fps
...

For every format (hardware supported by the camera or emulated by the driver) there is list of supported resolutions (sizes of frames) that you can get using Camera::resolutions method.

The result of the method is a simple structure:

pub enum ResolutionInfo {         // Examples
    Discretes(Vec<(u32, u32)>),   // Discretes(vec![(640, 360), (424, 240), (320, 240)])
    Stepwise {                    // Stepwise {
        min: (u32, u32),          //     min: (320, 240),
        max: (u32, u32),          //     max: (640, 360),
        step: (u32, u32)          //     step: (10, 10)
    }                             // }
}

Every variant (Discretes or Stepwise) represents a set of sizes (pairs (width, height)).

In the example Stepwise variant represents

{ ∀k≥0,m≥0 | (min(320 + k*step.0, 640), min(240 + m*step.1, 360)) }

Did I answer the question?

loyd avatar Feb 25 '18 06:02 loyd