Undefined function 'preview' for input arguments of type 'struct'.

2 次查看(过去 30 天)
Hai I am using Back round subtraction method on frame.Now I want to see the preview of these frames.But Error is occured " Undefined function 'preview' for input arguments of type 'struct'. This is code:
if true
for i = 2:numFrames
%fr = vid(i).cdata;
% read in frame
fr= read(vid, i);
fr_bw = rgb2gray(fr); % convert frame to grayscale
fr_diff = abs(double(fr_bw) - double(bg_bw)); % cast operands as double to avoid negative overflow
threshHold=mean(fr_diff);%Experimetn
for j=1:width % if fr_diff > thresh pixel in foreground
for k=1:height
if ((fr_diff(k,j) > threshHold))
fg(k,j) = fr_bw(k,j);
else
fg(k,j) = 0;
end
end
end
bg_bw = fr_bw; %store old frame to bg_bw variable
imshow(fr_bw);
figure(1),subplot(3,1,1),imshow(fr)
subplot(3,1,2),imshow(fr_bw)
subplot(3,1,3),imshow(uint8(fg)) ;
z=i-1;
q(z) = im2frame(uint8(fg),gray(256)); % put frames into movie
preview((q(z)));
end end

回答(2 个)

Guillaume
Guillaume 2016-5-4
preview does not appear to be a function of base matlab nor any of its toolboxes, so it must be a function that you've written yourself. Make sure that it is visible to matlab by adding its folder to matlab's path.

Steven Lord
Steven Lord 2016-5-4
There are a couple of objects in MATLAB that have preview methods. For instance, video input objects in Image Acquisition Toolbox have a preview method as do DatabaseDatastore objects in Database Toolbox and general datastore objects in MATLAB.
But there's no preview function or method for struct arrays.

Community Treasure Hunt

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

Start Hunting!

Translated by