custom preview function for video data

4 次查看(过去 30 天)
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)
  1 个评论
GEO GEP
GEO GEP 2012-7-4
surprisingly substituing 'UpdatePreviewWindowFcn' by 'FramesAcquiredFcn' solves the flickering problem, but introduces lag due to (constant) memory access (one frame per trigger)

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by