Comments (2)
I'm sorry, but in my use case the streamed image frames which flow as slow as 5 fps can be lost/dropped, where actually only a 4 μs-duration-operation is spent on each arrival of frames. So I suspect that the bottleneck might be at your lib.
Since it is common for most drivers to obtain a captured image frame-by-frame
( rather than byte-by-byte or line-by-line), I think we should shorten the handling time after we got the frame and keep capturing as soon as possible. Here is the idea based on this rule, how do you think about it (the code pattern is given as below) ?
The lib API looks like
/// set stream on, and return `rx` to user for receiving `Buffer`
pub fn stream_on(&mut self) -> mpsc::Receiver<Buffer> {
/*
set the stream on
*/
let (tx, rx) = mpsc::channel();
self.tx = Some(tx);
rx
}
/// infinite loop for requesting the next samples, and use a thread to handle each sample.
pub fn frames(&mut self) {
loop {
let imf_sample: Option<IMFSample> = match unsafe { MFCreateSample() } {
Ok(sample) => {
Some(sample)
}
Err(why) => {
return Err(NokhwaError::ReadFrameError(why.to_string()));
}
};
/*
here, can we handle imf_sample in a background thread?
e.g. handle_task.send(Wrapper<imf_sample>);
thus we can wait for the next frame as soon as possible
*/
}
}
/// the handle thread
pub fn sample_handle_thread(tx : mpsc::Sender<Buffer>) {
while let Ok(Wrapper<imf_sample>) = handle_task.recv(){
/*
handle the imf_sample and get `Buffer`
*/
tx.send(buffer);
}
}
Thus users can obtain the Buffer
by receiving from rx
.
from nokhwa.
Hello, the frame drop problem in my case finally ends up with setting the priority of the capture thread to "Time Critical" (it's on Windows). By doing this, the drop ratio can decrease from about 500 out of 10000
to a relatively low number, which is about 25 out of 10000
.
Actually, my use case was to capture video with resolution 5000x5000
at 5Hz
and then display&handle&save the images. I found it hard to understand the process/winapi of Windows camera capturing. Thanks to your crate, it let me achieve this goal much more easier and don't need to turn to Linux. Thank you very much, it is really a great project.
from nokhwa.
Related Issues (20)
- Multiple AVFoundation cameras on macOS panics with an NSException
- yuv422 confusions? HOT 2
- Compile issues on v4l2_pix_format in linux kernel 6.2 HOT 3
- Can't compile on archlinux 6.5.5-arch1-1 HOT 1
- Unable to access capture card on windows HOT 1
- Use AVCaptureDeviceTypeExternal on macOS
- what FrameFormat::GRAY is?
- Incorrect pixel format HOT 1
- AVFoundation backend is not passing the frame format HOT 1
- Meta: Current Status, Progress and Future Plans for this Project HOT 12
- Support for macOS continuity camera HOT 3
- Possible unsoundness HOT 1
- Switching devices leads to assertion failure at the device list. HOT 1
- threaded camera deadlock on stop stream HOT 1
- [Windows] Panic when no cams are connected
- [Request] BGR and GBR support HOT 1
- [Web] Update `jscam` example to function correctly in the latest version
- Build fails on multiple versions on Pop_OS! HOT 2
- v4l camera indexing isn't necessarily accurate
- Support AV1 coder
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 nokhwa.