l1npengtul / nokhwa

Cross Platform Rust Library for Powerful Webcam/Camera Capture
Apache License 2.0
482 stars 111 forks source link

Heavy Processing on one frame #140

Open marcown opened 10 months ago

marcown commented 10 months ago

Hey,

thanks for the nice repo!

Would be possible to do some heavy processing after each frame (up to 2s using some machine learning model and the ort lib (you have to create a session at the start of the program loading the model to the ram)) and when you capture the next frame it should get the last image of the camera and not some old buffer?

I tried to use the threaded camera in the examples folder, but, I don't know why, it was way slower than the not threaded example (i did all the heavy processing in the callback function, if you do it in the loop outside the threaded.last_frame or threaded.poll_frame are also quite slow)

Could you help me with some boilerplate code how to do it right? I am rather new to rust.

Thanks!