필터 지우기
필터 지우기

how can i feed the pre-recorded video to the following code instead of live video(from webcam)/ or how can i save the live video in a 'disk'

조회 수: 1 (최근 30일)
Greeting to the community, I am using matlab for image processing. anybody knows that how can i feed a pre-recorded video to the following code instead of live video(from webcam)?
I need to input pre-recroded video, or using live video but save the video in a folder first (using 'disk' instaed of 'memory') before proceeding the next stage (image processing).
a part of the code:
% Select video format
hws = imaqhwinfo ;
hw = imaqhwinfo(hws.InstalledAdaptors{end},1) ;
VideoFormat = hw.SupportedFormats;
% Select video format
hws = imaqhwinfo ;
hw = imaqhwinfo(hws.InstalledAdaptors{end},1) ;
VideoFormat = hw.SupportedFormats;
set(handles.text_vf, 'String', ['Video Format : ', 'YUY2_640x480']);
% set videoinput object
video = videoinput('winvideo',1,'YUY2_640x480');
set(video,'FramesPerTrigger',10);
set(video,'ReturnedColorSpace','grayscale');
set(video,'LoggingMode','memory');
triggerconfig(video,'immediate');
set(video,'FramesAcquiredFcnCount', 3);
set(video,'FramesAcquiredFcn', {@FramesAcquiredFcn,hObject});
% Preview UPDATE
vidRes = get(video, 'VideoResolution');
vidWin = image(zeros(vidRes(2), vidRes(1)),'Parent',handles.Preview);
preview(video,vidWin);

답변 (1개)

Mohammad Sami
Mohammad Sami 2020년 9월 4일
You can use the VideoReader to read a video file.
v = VideoReader('xylophone.mp4');
while hasFrame(v)
frame = readFrame(v);
end
  댓글 수: 2
Koohyar
Koohyar 2020년 9월 4일
편집: Koohyar 2020년 9월 4일
Hi Mohammad, thanks for your suggestion. Unfortunetly it shows error! I imported the video from the Image Acquisition Tool, and saved in in the directory (.mp4), but it shows error when I call the video (based on your advice), as below:
Error using VideoReader/get
Property VideoResolution not found in class VideoReader, or is not present in all elements of the array of class VideoReader
Any advice you could give would be much appreciated!
thanks
Mohammad Sami
Mohammad Sami 2020년 9월 5일
Video reader class does any property video Resolution. If you want resolution you will have to get Height and width properties.
Documentation of video reader is available here
https://www.mathworks.com/help/matlab/ref/videoreader.html

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by