raymanfx / eye-rs

Cross platform camera capture in Rust
MIT License
140 stars 10 forks source link

Laggy webcam preview image on MacOS (Ventura 13.4) #7

Closed anfen closed 1 year ago

anfen commented 1 year ago

It feels like the buffer has all the frames, they just can't be painted quick enough, so there is a slow motion effect. Is this expected?

raymanfx commented 1 year ago

What kind of application are you using when you say “painted”? Did you compile in release mode?

anfen commented 1 year ago

Hi @raymanfx, I ran the following from the 'eye' folder: cargo run --example glium

It output to console this:

Selected stream: Descriptor { width: 1280, height: 720, pixfmt: Rgb(24), interval: 33.333335ms } [DBG ] FOURCC = 420v

raymanfx commented 1 year ago

Did you try running it in release mode instead?

cargo run —release —example glium
anfen commented 1 year ago

That fixed it! Very impressive library, well done. I'm new to Rust, so that was probably a school boy error. Do you know why the performance would be so different when not using --release?

raymanfx commented 1 year ago

Thanks for the kind words :)

Well it’s kind of expected with any compiled language. The debug (default) mode in Rust will turn off any optimizations. Modern compilers do lots of transformations of your code before generating the final instructions, e.g. loop unrolling, vectorization, inlining and more.