gusucode.com > vision工具箱matlab源码程序 > vision/+vision/+internal/+buildable/opticalFlowHSBuildable.m

    classdef opticalFlowHSBuildable < coder.ExternalDependency %#codegen
    % opticalFlowHSBuildable - encapsulate opticalFlowHS implementation library
    
    % Copyright 2012 The MathWorks, Inc.
    
    
    methods (Static)
        
        function name = getDescriptiveName(~)
            name = 'opticalFlowHSBuildable';
        end
        
        function b = isSupportedContext(context)
            b = context.isMatlabHostTarget();
        end
        
        function updateBuildInfo(buildInfo, ~)
            buildInfo.addIncludePaths({fullfile(matlabroot,'toolbox', ...
                'vision','builtins','src','vision','include')} );
            buildInfo.addSourcePaths({fullfile(matlabroot,'toolbox', ...
                'vision','builtins','src','vision')});
            buildInfo.addSourceFiles({'opticalFlowHSCore.cpp'});
            buildInfo.addIncludeFiles({'vision_defines.h', ...
                                       'opticalFlowHSCore_api.hpp', ...
                                       'opticalFlowHS.hpp', ...
                                       'opticalFlowHS_Sobel.hpp'});
        end

        %------------------------------------------------------------------
        % write all supported data-type specific function calls      
        function [outVelReal, outVelImag] = ...
                 opticalFlowHS_compute( ...
         			tmpImageA, ImageB, ...
					pBuffCprev, pBuffCnext, pBuffRprev, pBuffRnext, ...
					pGradCC, pGradRC, pGradRR, pGradCT, pGradRT, ...
					pAlpha, ...
					pVelBufCcurr, pVelBufCprev, pVelBufRcurr, pVelBufRprev, ...
					Smoothness, ... % Smoothness is Lambda
					useMaxIter, useMaxAllowableAbsDiffVel, ... 
					MaxIter, MaxAllowableAbsDiffVel ...
                  )    
            
            % add '#include "opticalFlowHSCore_api.hpp"' in <myfcn>.c
            coder.cinclude('opticalFlowHSCore_api.hpp');
            
            coder.inline('always');
    
            % call function
            outVelReal = zeros(size(tmpImageA), 'like', pBuffCprev);
            outVelImag = zeros(size(tmpImageA), 'like', pBuffCprev);
            
            pInRows = int32(size(tmpImageA,1));
            pInCols = int32(size(tmpImageA,2));
            fcnName = ['MWCV_OpticalFlow_HS_' class(tmpImageA)];
            coder.ceval(fcnName,...
              coder.ref(tmpImageA), ...
              coder.ref(ImageB), ...
              coder.ref(outVelReal), ...
              coder.ref(outVelImag), ...
              coder.ref(pBuffCprev), coder.ref(pBuffCnext), coder.ref(pBuffRprev), coder.ref(pBuffRnext), ...
			  coder.ref(pGradCC), coder.ref(pGradRC), coder.ref(pGradRR), coder.ref(pGradCT), coder.ref(pGradRT), ...
			  coder.ref(pAlpha), ...
					coder.ref(pVelBufCcurr), coder.ref(pVelBufCprev), coder.ref(pVelBufRcurr), coder.ref(pVelBufRprev), ...
					coder.ref(Smoothness), ... % Smoothness is Lambda
					useMaxIter, useMaxAllowableAbsDiffVel, ...
					coder.ref(MaxIter), coder.ref(MaxAllowableAbsDiffVel), ...
                    pInRows, pInCols ...
                  );

        end       
    end   
end