surprisingly substituing 'UpdatePreviewWindowFcn' by 'FramesAcquiredFcn' solves the flickering problem, but introduces lag due to (constant) memory access (one frame per trigger)
custom preview function for video data
4 views (last 30 days)
Show older comments
Hello, i m trying to write a custom preview function for processing video data. Due to camera constraints i can only use one resolution.. However video data within preview function can be processed at lower resolutions.
The problem is a strange axe flicker when subsampling/viewing the original video data for processing.. I was able to reproduce it by using a web camera and a simple script:
function test002
close all;clear all;
vid = videoinput('winvideo');
hFig = figure;
subsample=2;
vidRes = get(vid, 'VideoResolution');
imWidth = vidRes(1)/subsample;
imHeight = vidRes(2)/subsample;
nBands = get(vid, 'NumberOfBands');
hImage = image( zeros(imHeight, imWidth, nBands) );
setappdata(hImage,'UpdatePreviewWindowFcn',@mypreview_fcn);
preview(vid, hImage);
end
function mypreview_fcn(obj,event,himage)
data=event.Data;
subsample=2;
data_sub=data(1:subsample:end,1:subsample:end,:);
set(himage,'CData',data_sub);
end
Any ideas?? (tried doubleBuffering, and resizing figure)
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!