Comments (10)
Thanks for your interest in my crate! Right now, adding camera support isn't super high on my priority list, but I have a small C library that does camera capture on Linux which wouldn't be too difficult to port to Rust (https://github.com/OxyDeadbeef/lib-car-wreck).
Honestly, I could probably port it in a small amount of time (unless you want to). Then, I could make a crate (probably called adi_camera) that incorporates your custom version of escapi and my ported C code, which this crate can depend on.
What do you think?
from cala.
I just tested the rscam crate on linux, and I wish there was something like that for windows.
The problem is, my modified version of escapi is currently blind because escapi doesn't allow querying for supported formats, so I had to hardcode it for my specific camera, but I want it to work with all cameras.
More details here: jarikomppa/escapi#14
So what I would ideally want to do with escapi is: find the highest resolution with at least 20 fps and use that format (and when it's MJPEG I can decode it myself).
With rscam, it is possible, but not with escapi right now.. But I need windows support much more than linux support because my linux laptop has no GPU and I need to heavily postprocess the webcam frames etc., and I need to load a lot of windows-specific VST dlls for audio processing..
from cala.
It probably wouldn't be too difficult to add as a feature. Just find the right winapi functions and wrap them in Rust. I'd need to look at the escapi project a bit more. It looks like it is not entirely written in Rust? Ideally, webcam support in this crate would be pure Rust (depending on the winapi crate on WIndows).
If possible, I would like to see the diff file of your hacks on the escapi crate.
from cala.
escapi is written in C++, I had written some Rust bindings for v2 but then v3 came out with its own Rust bindings but which weren't really suitable for my use case because they didn't allow getting a device's name before opening it, which I need because before I'm opening the camera device, I have to find its number by the name that I'm reading from a config file.. So I adapted my own Rust bindings to work with v3, which was easy, because the API didn't really change, only the implementation switched to windows media foundation (from directshow)..
Then I had to modify the C++ code of escapi to impl mjpeg support (pass-thru of the buffer in escapi and decoding in my Rust app)..
My modified version of escapi is here:
Boscop/escapi@0a25e95
My Rust bindings are here: https://github.com/Boscop/escapi-rs
In my app I'm using my Rust bindings with my escapi fork + mozjpeg-sys to decode the frames.
By winapi do you mean directshow? I've never worked with directshow or WMF directly but IIRC, the guy who wrote OBS said on IRC that directshow is much easier to work with, and there's no real reason to use WMF, because directshow won't be deprecated..
He also wrote this lib: https://github.com/obsproject/libdshowcapture
It's used in OBS for camera capture.
Maybe it would make sense to write Rust bindings for that? But it's C++..
But this is the most flexible and working solution for webcam reading I found, also allows querying the cam for supported formats/resolutions/framerates..
Or maybe it wouldn't be too difficult to just port this lib to Rust, and then write a wrapper crate that abstracts over the platform differences by providing a uniform cross-platform interface and uses the rscam crate on linux.
from cala.
directshow won't be deprecated? https://en.wikipedia.org/wiki/DirectShow says "Microsoft plans to completely replace DirectShow gradually with Media Foundation in future Windows versions". It sounds like deprecation to me. But OBS is a respectable source, so I could be wrong.
I actually haven't done any webcam stuff on Windows before. My experience is entirely on Linux in this field, so I thought webcam stuff might be built into the winapi which seems to be huge an all encompassing.
Either way, I would like to avoid writing wrapper crates around C++ APIS, and have a rust crate that calls to directshow or WMF directly, which will be abstracted by a cross platform crate.
from cala.
directshow is good enough for now. If Windows deprecates it in the future, we can always add WMF support later.
from cala.
Are you sure directshow is easier? This stackoverflow post says otherwise: https://stackoverflow.com/a/1259459/5286593
from cala.
Not sure, since I also haven't worked with it directly but I IIRC that's what the OBS creator said on IRC..
But it probably makes sense to look more into it before making a decision.
Btw, the wiki article also says:
Microsoft's MSFT Becky Weiss also confirms that "you'll notice that working with the Media Foundation requires you to work at a slightly lower level than working with DirectShow would have. And there are still DirectShow features that aren't (yet) in Media Foundation".
Not sure if the last sentence is still true at this point in time, but the first one probably is.
from cala.
I'm starting to lean towards WMF, since it's newer (And it looks like it's still higher level than v4l2).
from cala.
Makes sense..
from cala.
Related Issues (19)
- Add bluetooth support
- Add API for safe SIMD & GPU vulkan operations
- C API, Python bindings
- Rendering Optimization HOT 1
- Dependabot couldn't fetch all your path-based dependencies
- Dependabot couldn't fetch all your path-based dependencies
- Dependabot couldn't fetch all your path-based dependencies
- Clock module doesn't compile HOT 1
- Windows audio support
- Add Arduino Serial API
- Replace net module APIs
- MacOS audio support.
- Windows controller support
- MacOS controller support.
- Move Into Ardaku Organization
- Figure Out Why CI Is Broken
- Window and graphics support on Windows
- Window and graphics support on MacOS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cala.