www.gusucode.com > visionhdl工具箱matlab源码程序 > visionhdl/visionhdlutilities/@visionhdlsupport/@Bayer/cgireml/dataWrite.m
function [SELR,SELG,SELB] = dataWrite(hStart, hEnd, vStart, vEnd) %#codegen persistent bayerState; stype = numerictype(0,3,0); S0 = fi(0,'numerictype',stype); S1 = fi(1,'numerictype',stype); S2 = fi(2,'numerictype',stype); S3 = fi(3,'numerictype',stype); S4 = fi(4,'numerictype',stype); S5 = fi(5,'numerictype',stype); S6 = fi(6,'numerictype',stype); SELR= fi(0,0,2,0); SELG= fi(0,0,2,0); SELB= fi(0,0,2,0); if isempty(bayerState) bayerState = fi(0,'numerictype',stype); end switch bayerState case S0 %% RESET State SELR(:) = 0; SELG(:) = 0; SELB(:) = 0; if vStart || hStart bayerState(:) = 1; else bayerState(:) = 0; end case S1 %% Line 1 , Pixel 1 SELR(:) = RL1P1; SELG(:) = GL1P1; SELB(:) = BL1P1; if vEnd bayerState(:) = 0; elseif hEnd bayerState(:) = 5; else bayerState(:) = 2; end case S2 %% Line 1 , Pixel 2 SELR(:) = RL1P2; SELG(:) = GL1P2; SELB(:) = BL1P2; if vEnd bayerState(:) = 0; elseif hEnd bayerState(:) = 5; else bayerState(:) = 1; end case S3 %% Line 2 Pixel 1 SELR(:) = RL2P1; SELG(:) = GL2P1; SELB(:) = BL2P1; if vEnd bayerState(:) = 0; elseif hEnd bayerState(:) = 6; else bayerState(:) = 4; end case S4 %% Line 2 Pixel 2 SELR(:) = RL2P2; SELG(:) = GL2P2; SELB(:) = BL2P2; if vEnd bayerState(:) = 0; elseif hEnd bayerState(:) = 6; else bayerState(:) = 3; end case S5 %% IDLE after RG SELR(:) = 0; SELG(:) = 0; SELB(:) = 0; if vEnd bayerState(:) = 0; elseif hStart bayerState(:) = 3; else bayerState(:) = 5; end case S6 %% IDLE after GB SELR(:) = 0; SELG(:) = 0; SELB(:) = 0; if vEnd bayerState(:) = 0; elseif hStart bayerState(:) = 1; else bayerState(:) = 6; end otherwise bayerState(:) = 0; SELR(:) = 0; SELG(:) = 0; SELB(:) = 0; end