Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Program error!! Why??

1 Ansicht (letzte 30 Tage)
Marqual Brown
Marqual Brown am 28 Sep. 2017
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
//Code below
obj = VideoReader('C:\Users\Robotics\Pictures\Saved Pictures\Lightfile\Prelight.MOV');
frameidx = 0;
groupidx = 0;
frames_per_group = 5;
frame_history = [];
frameidx_history = [];
groupidx_history = [];
while hasFrame(obj)
frameidx = frameidx + 1;
groupidx = groupidx + 1;
b = readFrame(obj);
frame_history = cat(4, frame_history, b);
frameidx_history(end+1) = frameidx;
if size(frame_history, 4) == frames_per_group
maxbrightness = -inf;
maxbrightnessidx = -inf;
for K = 1 : frames_per_group;
grayframe = rgb2gray(frame_history(:,:,:,K));
thisbrightness = sum(grayframe(:));
if thisbrightness > maxbrightness
maxbrightness = thisbrightness;
maxbrightnessidx = K;
end
end
bestframe = frame_history(:,:,:,maxbri ghtnessidx);
bestframeidx = frameidx_history(maxbrigthnessidx);
filename = sprintf('frame%04d.jpg', bestframeidx);
imwrite(bestframe, filename);
frame_history = [];
frameidx_history = [];
end
end
when I run it, it says that its a problem with the maxbrightnessidx. Can someone help? Please

Antworten (2)

Rik
Rik am 2 Nov. 2017
Without the file, the only thing I see, is that you have an extra space in your line:
bestframe = frame_history(:,:,:,maxbri ghtnessidx);

Roger Stafford
Roger Stafford am 2 Nov. 2017
In
bestframeidx = frameidx_history(maxbrigthnessidx);
you misspell 'maxbrigthnessidx'. The 't' and 'h' are interchanged.

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by