Info

此问题已关闭。 请重新打开它进行编辑或回答。

Program error!! Why??

1 次查看(过去 30 天)
Marqual Brown
Marqual Brown 2017-9-28
关闭: MATLAB Answer Bot 2021-8-20
//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

回答(2 个)

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

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by