MATLAB Answers

processing on a live webcam streaming video???

231 ビュー (過去 30 日間)
Hashem Burki
Hashem Burki 2011 年 5 月 11 日
コメント済み: Florian Morsch 2018 年 6 月 21 日
I am using an image acquisition toolbox to obtain the live stream from my webcam. I have my own code for skin color segmentation which works well on pictures (JPEG etc). I am only able to get a snapshot of the live video and then apply the code. I need to apply that code on the live webcam video stream. How can i do it???
  1 件のコメント
David Tarkowski
David Tarkowski 2011 年 5 月 11 日
I'm not sure what you mean, a video stream is just a series of snapshots at a specified interval. Can you elaborate on what you are doing and how it differs from what you would like?

サインインしてコメントする。

回答 (3 件)

Harsha Vardhan Rao  Avunoori
Harsha Vardhan Rao Avunoori 2011 年 5 月 19 日
Well I think you can try using the Image Acquisition ToolBox for your case it will definitely help you...
For more information on Image Acquisition ToolBox have a look at this website

Hashem Burki
Hashem Burki 2011 年 5 月 25 日
what i ment was that i want to perform a skin segmentation code on an input webcam video, and want to preview it as an output video. how can i do it?
  4 件のコメント
Walter Roberson
Walter Roberson 2018 年 6 月 20 日
"will the output video be as smooth as a live stream"
As we were discussing in https://www.mathworks.com/matlabcentral/answers/7202-processing-on-a-live-webcam-streaming-video#comment_579179, you are using the Automated Driving toolbox. You are limited by the functions in that toolbox that you call. This is probably not an issue of the webcam interface being slow: this is quite likely an issue that you are doing extensive computation with each frame.
No computer can respond instantly. If you want a frame to be ready to output within 1/30 of a second so that you can get 30 fps output, then you need to restrict yourself to computations that that computer can finish within 1/30 of a second. It does not matter whether the camera interface takes 30 microseconds per frame or 30 milliseconds per frame (33 1/3 fps) if the computation you are doing takes (say) 1/4 second. That is true whether that (say) 1/4 second per frame is because you are using slow hardware; or because you are trying to use more RAM than you have available and the program is swapping; or because you wrote inefficient code such as failing to pre-initialize arrays that you are storing into; or because you are just plain trying to compute things more complex than current computer speeds could reasonably get done in that length of time.
The Automated Driving Toolbox is a premium toolbox; very few of the regular volunteers here have access to even the documentation for it, so it is difficult for us to make suggestions (especially since you do not include any code.)

サインインしてコメントする。


Florian Morsch
Florian Morsch 2018 年 6 月 15 日
編集済み: Florian Morsch 2018 年 6 月 15 日
You way to do it would be:
1: Create a webcam object EDIT: or create a cam object
2: You can get screenshots/snapshots from the object
3: Create a videoplayer object
4: Now you run a while loop and take a snapshot, process it and give it to the videoPlayer as output, which can step through the frames he gets. The FPS is limited to your code, if you need 1 second to work with a frame then you will get 1 FPS, if your code is fast enough you might end up with 10-15 FPS or more.
Now its up to you how fast your code works to get a smoother "video". RealTime is mostly not possible since you need to do some operations on the frame which means you have processing time (except your code is really really good and you can manage to do the processing in like under 20ms, which would be 50 FPS).
  11 件のコメント
Florian Morsch
Florian Morsch 2018 年 6 月 21 日
Refering to your comment: You could store the frames and then analyse every frame, but that would be video processing, not real time processing, if you code is not fast enough for real time in the first place. That would be like taking a video, process every frame and then rewatch it. Sure, you would get no "lag" like in the stream processing, but its not real time anymore, its a video you watch.
Some things can help you to make the code faster (preallocating can reduce the processing time by a lot) see: https://de.mathworks.com/help/matlab/matlab_prog/preallocating-arrays.html

サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by