www.gusucode.com > visionhdl工具箱matlab源码程序 > visionhdl/visionhdl/+visionhdl/en/ROISelector.m
classdef ROISelector< matlab.System & matlab.system.mixin.Propagates & matlab.system.mixin.CustomIcon & matlab.system.mixin.Nondirect %ROISelector Selects a region of interest (ROI) from a stream % roi = visionhdl.ROISelector returns a System object, roi, that selects a % default region of the active frame from an input stream. % % roi = visionhdl.ROISelector('PropertyName',PropertyValue,...) returns an % HDL ROI Selector System object, roi, with each specified property set to % the specified value. % % Step method syntax: % % [pixel1,ctrl1] = step(roi,pixelIn,ctrlIn) returns the next pixel value, % pixel1, and control signals, ctrl1, resulting from masking the active % image frame into a single new region. Define the region by setting the % Regions property to a 1-by-4 vector, [hPos vPos hSize vSize]. % % [pixel1,ctrl1,...,pixelN,ctrlN] = step(roi,pixelIn,ctrlIn) returns the % next pixel values, pixel1,...,pixelN, and control signals, % ctrl1,...,ctrlN, of each stream resulting from masking the active image % frame into 1 to N new active regions, as directed by the Regions % property. Set the Regions property to a N-by-4 matrix of region % coordinates. % % [pixel1,ctrl1,...,pixelN,ctrlN] = step(roi,pixelIn,ctrlIn,region1,...,regionN) % returns the next pixel values of each stream, pixel1,...,pixelN, % resulting from masking the active image frame into 1 to N new regions, % as directed by the region1,...,regionN arguments. Each region input is a % 1-by-4 vector of region coordinates. Use this syntax when you set the % RegionsSource property to 'Input Port', and the NumberOfRegions property % to N. % % System objects may be called directly like a function instead of using % the step method. For example, y = step(obj, x) and y = obj(x) are % equivalent. % % ROISelector methods: % % step - See above description for use of this method % release - Allow property value and input characteristics changes % clone - Create ROISelector object with same property values % isLocked - Locked status (logical) % % ROISelector properties: % % RegionsSource: Property or Input Port % NumberOfRegions: Number of regions when using Input Port % Regions: Constant regions as [hPos vPos hSize vSize; hPos2 vPos2...] % % % EXAMPLE: % frm2pix = visionhdl.FrameToPixels(... % 'VideoFormat','custom',... % 'ActivePixelsPerLine',32,... % 'ActiveVideoLines',18,... % 'TotalPixelsPerLine',42,... % 'TotalVideoLines',28,... % 'StartingActiveLine',6,... % 'FrontPorch',5); % [actPixPerLine,actLine,numPixPerFrm] = getparamfromfrm2pix(frm2pix); % % pix2frm = visionhdl.PixelsToFrame(... % 'VideoFormat','custom',... % 'ActivePixelsPerLine',actPixPerLine,... % 'ActiveVideoLines',actLine); % % roi = visionhdl.ROISelector; % roi.RegionsSource = 'Property'; % % Specify a 15 across by 10 down region at pixel (7,5) % roi.Regions = [7 5 15 10]; % % frmFull = imread('rice.png'); % frmIn = frmFull(74:73+actLine,104:103+actPixPerLine); % imshow(frmIn); % % pixOutVec = zeros(numPixPerFrm*2,1,'uint8'); % ctrlOutVec = repmat(pixelcontrolstruct,numPixPerFrm*2,1); % % [pixInVec,ctrlInVec] = step(frm2pix,frmIn); % pixInVec = [pixInVec;pixInVec]; % ctrlInVec = [ctrlInVec;ctrlInVec]; % for p = 1:numPixPerFrm*2 % [pixOutVec(p),ctrlOutVec(p)] = step(roi,pixInVec(p),ctrlInVec(p)); % end % [frmOut,frmValid] = step(pix2frm,pixOutVec,ctrlOutVec); % % if frmValid % figure; % imshow(frmOut); % end % Copyright 2015-2016 The MathWorks, Inc. methods function out=ROISelector %ROISelector Selects a region of interest (ROI) from a stream % roi = visionhdl.ROISelector returns a System object, roi, that selects a % default region of the active frame from an input stream. % % roi = visionhdl.ROISelector('PropertyName',PropertyValue,...) returns an % HDL ROI Selector System object, roi, with each specified property set to % the specified value. % % Step method syntax: % % [pixel1,ctrl1] = step(roi,pixelIn,ctrlIn) returns the next pixel value, % pixel1, and control signals, ctrl1, resulting from masking the active % image frame into a single new region. Define the region by setting the % Regions property to a 1-by-4 vector, [hPos vPos hSize vSize]. % % [pixel1,ctrl1,...,pixelN,ctrlN] = step(roi,pixelIn,ctrlIn) returns the % next pixel values, pixel1,...,pixelN, and control signals, % ctrl1,...,ctrlN, of each stream resulting from masking the active image % frame into 1 to N new active regions, as directed by the Regions % property. Set the Regions property to a N-by-4 matrix of region % coordinates. % % [pixel1,ctrl1,...,pixelN,ctrlN] = step(roi,pixelIn,ctrlIn,region1,...,regionN) % returns the next pixel values of each stream, pixel1,...,pixelN, % resulting from masking the active image frame into 1 to N new regions, % as directed by the region1,...,regionN arguments. Each region input is a % 1-by-4 vector of region coordinates. Use this syntax when you set the % RegionsSource property to 'Input Port', and the NumberOfRegions property % to N. % % System objects may be called directly like a function instead of using % the step method. For example, y = step(obj, x) and y = obj(x) are % equivalent. % % ROISelector methods: % % step - See above description for use of this method % release - Allow property value and input characteristics changes % clone - Create ROISelector object with same property values % isLocked - Locked status (logical) % % ROISelector properties: % % RegionsSource: Property or Input Port % NumberOfRegions: Number of regions when using Input Port % Regions: Constant regions as [hPos vPos hSize vSize; hPos2 vPos2...] % % % EXAMPLE: % frm2pix = visionhdl.FrameToPixels(... % 'VideoFormat','custom',... % 'ActivePixelsPerLine',32,... % 'ActiveVideoLines',18,... % 'TotalPixelsPerLine',42,... % 'TotalVideoLines',28,... % 'StartingActiveLine',6,... % 'FrontPorch',5); % [actPixPerLine,actLine,numPixPerFrm] = getparamfromfrm2pix(frm2pix); % % pix2frm = visionhdl.PixelsToFrame(... % 'VideoFormat','custom',... % 'ActivePixelsPerLine',actPixPerLine,... % 'ActiveVideoLines',actLine); % % roi = visionhdl.ROISelector; % roi.RegionsSource = 'Property'; % % Specify a 15 across by 10 down region at pixel (7,5) % roi.Regions = [7 5 15 10]; % % frmFull = imread('rice.png'); % frmIn = frmFull(74:73+actLine,104:103+actPixPerLine); % imshow(frmIn); % % pixOutVec = zeros(numPixPerFrm*2,1,'uint8'); % ctrlOutVec = repmat(pixelcontrolstruct,numPixPerFrm*2,1); % % [pixInVec,ctrlInVec] = step(frm2pix,frmIn); % pixInVec = [pixInVec;pixInVec]; % ctrlInVec = [ctrlInVec;ctrlInVec]; % for p = 1:numPixPerFrm*2 % [pixOutVec(p),ctrlOutVec(p)] = step(roi,pixInVec(p),ctrlInVec(p)); % end % [frmOut,frmValid] = step(pix2frm,pixOutVec,ctrlOutVec); % % if frmValid % figure; % imshow(frmOut); % end end function getExecutionSemanticsImpl(in) %#ok<MANU> % works in both classic and synchronous subsystems end function getHeaderImpl(in) %#ok<MANU> %getHeaderImpl Return header for object display end function getIconImpl(in) %#ok<MANU> end function getInputNamesImpl(in) %#ok<MANU> end function getNumInputsImpl(in) %#ok<MANU> end function getNumOutputsImpl(in) %#ok<MANU> end function getOutputDataTypeImpl(in) %#ok<MANU> end function getOutputNamesImpl(in) %#ok<MANU> end function getOutputSizeImpl(in) %#ok<MANU> end function isInactivePropertyImpl(in) %#ok<MANU> end function isOutputComplexImpl(in) %#ok<MANU> end function isOutputFixedSizeImpl(in) %#ok<MANU> end function lineFrameFSM(in) %#ok<MANU> % Uses the input register in the object to % update InFrame and InLine end function loadObjectImpl(in) %#ok<MANU> end function outputImpl(in) %#ok<MANU> % Output First end function resetImpl(in) %#ok<MANU> end function saveObjectImpl(in) %#ok<MANU> % Save the public properties end function setROIOutputs(in) %#ok<MANU> end function setupImpl(in) %#ok<MANU> end function showSimulateUsingImpl(in) %#ok<MANU> end function updateImpl(in) %#ok<MANU> % Update from here end function updateRegionRegs(in) %#ok<MANU> end function validateInputsImpl(in) %#ok<MANU> end end methods (Abstract) end properties %NumberOfRegions Number of Regions % Indicate the number of regions of interest to be selected NumberOfRegions; %Regions Regions % The starting location and size of the regions as [left top Xsize Ysize]. % Active when RegionsSource is set to 'Property' Regions; %RegionsSource Regions source % Indicate how to specify the regions source parameters as one of [ 'Property' % | {'Input port'} ]. RegionsSource; end end