Custom processing within a video preview window
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I'm trying to perform custom processing on a video preview. However, I'm having trouble utilizing the FramesAcquiredFcn. Although I don't get any errors, the video preview is always the same, unprocessed video preview.
vid = videoinput('pointgrey',1,'Mono8_640x480');
vidRes = get(vid, 'VideoResolution');
imWidth = vidRes(1);
imHeight = vidRes(2);
nBands = get(vid, 'NumberOfBands');
himage = image( zeros(imHeight, imWidth, nBands) );
setappdata(himage,'FramesAcquiredFcn',@mypreview_fcn);
%If I change the name of my processing function (from @mypreview_fcn to anything else, eg @mypreview), I still get no errors, and the same video. Therefore, I tried dropping the handle, @, and just put the name of my function, but this yields an error of "Error using mypreview_fcn Too many output arguments." If I place an output argument into mypreview_fcn, then I get an error that the variable "event" is undefined when I thought it is supposed to be an argument supplied by the preview function.
preview(vid,himage);
my preview function is shown below:
function mypreview_fcn(obj, event, himage)
data = event.Data;
w_s = 5;
SC = stdfilt(data(:,:,1),ones(w_s))./imfilter(double(data(:,:,1)),fspecial('average',w_s),'symmetric');
set(himage,'CData',SC);
end
Please let me know if you have any thoughts, it would be greatly appreciated. Thank you!
0 commentaires
Réponses (2)
Petter Hagqvist
le 6 Fév 2019
Very late answer, but I encountered this myself and also found the solution. It might help someone looking for the answer in the future.
You need to add:
start(vid);
Only calling preview() doesn't seem to be enough.
0 commentaires
Voir également
Catégories
En savoir plus sur Image Preview and Device Configuration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!