Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Program error!! Why??

1 vue (au cours des 30 derniers jours)
Marqual Brown
Marqual Brown le 28 Sep 2017
Clôturé : MATLAB Answer Bot le 20 Août 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

Réponses (2)

Rik
Rik le 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 le 2 Nov 2017
In
bestframeidx = frameidx_history(maxbrigthnessidx);
you misspell 'maxbrigthnessidx'. The 't' and 'h' are interchanged.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by