Filter löschen
Filter löschen

custom preview function for video data

2 Ansichten (letzte 30 Tage)
GEO GEP
GEO GEP am 4 Jul. 2012
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 Kommentar
GEO GEP
GEO GEP am 4 Jul. 2012
surprisingly substituing 'UpdatePreviewWindowFcn' by 'FramesAcquiredFcn' solves the flickering problem, but introduces lag due to (constant) memory access (one frame per trigger)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by