snapshot problem in video processing

i have a problem with snapshot in my codes.i can;t take a frame for remove noise.the program have error
Undefined function 'snapshot' for input arguments of type 'matlab.graphics.primitive.Image'.
Error in Untitled4 (line 10)
img= snapshot(c);
clear
clc
vid= VideoReader('viptraffic.avi'); %reading video file by VideoReader function
for i=1:vid.NumberofFrames %its a loop for noise removing and showing video online
img=read(vid,i); %reading video frame
c=imshow(img)
img= snapshot(c);
end

댓글 수: 5

Turlough Hughes
Turlough Hughes 2020년 7월 1일
Inputs for snapshot are can be either (i) a cameraboard object, or (ii) a webcam object, wherehas you are inputting an Image object. See this part of the documentation. Aside from that your frame, for a given iteration of the loop, will be stored in img.
Turlough Hughes
Turlough Hughes 2020년 7월 1일
Why are you using the snapshot function in the first place, are you trying to read data from a camera connected to your computer, or is the goal here to simply modify footage from viptraffic.avi?
mehrdad jafari
mehrdad jafari 2020년 7월 1일
tnx for your reply,
i want to take a image,when video is playing and then work on noise and show it again.
Walter Roberson
Walter Roberson 2020년 7월 1일
What is it you want to take an image of? A camera connected to the computer? Or a frame from the video that is playing?
mehrdad jafari
mehrdad jafari 2020년 7월 1일
video playing

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

답변 (1개)

Turlough Hughes
Turlough Hughes 2020년 7월 1일

0 개 추천

snapshot() is intended for use with a cameraboard object or webcam object and you are attempting you input an image object.
You want to take a image,when video is playing and then work on noise and show it again
To modify the frames and then view the results/create a new video of the modified frames you can do so as follows:
clear
clc
vid= VideoReader('viptraffic.avi'); %reading video file by VideoReader function
player = vision.VideoPlayer; % launch videoplayer
v = VideoWriter('newfile.avi'); % make object for saving modified video
open(v)
for i=1:vid.NumFrames
frame=read(vid,i); % get video frame
modifiedframe = frame; % make a copy
% Perform steps to modify each frame here:
modifiedframe(:,:,[2 3]) = 0; % for example show red stream only
% show results in video player
step(player,[frame modifiedframe]) % alternatively: step(player,modifiedframe)
writeVideo(v,modifiedframe); % write modified frame to your new video file.
pause(0.05)
end
close(v)
I opted to show before and after side by side in the videoplayer.
As for noise removal, there a numerous ways to do so.
some considerations:

댓글 수: 3

i used noise removal by above code, but i want to take a image when video is playing and then do noise removal with bellow or your code.
K = wiener2(J,[5 5]);
mehrdad jafari
mehrdad jafari 2020년 7월 1일
편집: mehrdad jafari 2020년 7월 1일
all the code i saw, didn't give me any clicking on video for choose a frame
Walter Roberson
Walter Roberson 2020년 7월 1일
I recommend starting with the File Exchange contribution videofig https://www.mathworks.com/matlabcentral/fileexchange/29544-figure-to-play-and-analyze-videos-with-custom-plots-on-top which already has callbacks programmed in to it, making it easier to adapt for your purposes.

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

제품

질문:

2020년 7월 1일

댓글:

2020년 7월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by