gusucode.com > target工具箱matlab源码程序 > target/extensions/operatingsystem/linux/blks/masks/v4l2_video_capture_callback.m
function varargout = v4l2_video_capture_callback(varargin) %V4L2_VIDEO_CAPTURE_CALLBACK Mask Helper Function for Video Capture block. % % Copyright 2010-2011 The MathWorks, Inc. blk = gcbh; % Check on input "action" action = varargin{1}; switch action case 'pixelFormat' maskVisibilities = get_param(blk, 'MaskVisibilities'); pixelFormat = get_param(blk, 'pixelFormat'); if (strcmp(pixelFormat, 'YUYV') || ... strcmp(pixelFormat, 'RGB24')) maskVisibilities{5} = 'on'; else maskVisibilities{5} = 'off'; end set_param(blk, 'MaskVisibilities', maskVisibilities); case 'MaskInitialization' updatePortLabels(blk); otherwise error(message('TARGETFOUNDATION:utils:BlockBuilder_UnknownCallback', action)); end %-------------------------------------------------------------------------- function updatePortLabels(blk) eol = char(10); maskDisplayStr = ''; maskDisplayStr = [maskDisplayStr, 'color(''blue'');', eol, ... 'text(0.95, 0.90, ''LINUX'', ''horizontalAlignment'', ''right'');', eol ... 'color(''black'');', eol, ... 'text(0.5, 0.12, ''Video Capture'', ''horizontalAlignment'', ''center'');', eol]; pixelOrder = get_param(blk, 'pixelOrder'); pixelFormat = get_param(blk, 'pixelFormat'); if strcmp(pixelOrder, 'Interleaved') portLabels = ['port_label(''output'', 1, ''I'');', eol]; else if strcmp(pixelFormat, 'YUYV') portLabels = ['port_label(''output'', 1, ''Y'');', eol ... 'port_label(''output'', 2, ''Cb'');', eol ... 'port_label(''output'', 3, ''Cr'');']; else portLabels = ['port_label(''output'', 1, ''R'');', eol ... 'port_label(''output'', 2, ''G'');', eol ... 'port_label(''output'', 3, ''B'');']; end end maskDisplayStr = [maskDisplayStr, portLabels]; set_param(blk, 'MaskDisplay', maskDisplayStr); %[EOF] V4L2_VIDEO_CAPTURE_CALLBACK.M