function [isIn,epipole] = isEpipoleInImage(f,imageSize)
% isEpipoleInImage Determine whether the epipole is inside the image.
%   This function supports code generation.

% Copyright 2010 The MathWorks, Inc.
% $Revision: 1.1.6.3 $  $Date: 2011/02/21 07:18:29 $
%#codegen

coder.extrinsic('cvstGetCoordsChoice');
isXY = eml_const(cvstGetCoordsChoice('fcnIsEpipoleInImage'));

if eml_ambiguous_types
  isIn = false;
  if isXY
    epipole = [0, 0];
  else
    epipole = [0; 0];
  end
  return;
end

eml_prefer_const(f, imageSize);
checkInputs(f, imageSize);
[isIn,epipole] = cvalgIsEpipoleInImage(f, imageSize, isXY);

%==========================================================================
function checkInputs(f, imageSize)
%--------------------------------------------------------------------------
% Check F
%--------------------------------------------------------------------------
eml_lib_assert(isfloat(f) && isreal(f) && ~issparse(f), ...
  'vision:isEpipoleInImage:invalidFType', ...
  'Expected F to be floating point, real, and nonsparse.');

eml_lib_assert(ndims(f) == 2 && size(f, 1) == 3 && size(f, 2) == 3, ...
  'vision:isEpipoleInImage:invalidFSize', ...
  'Expected F to be a 3-by-3 matrix.');

%--------------------------------------------------------------------------
% Check IMAGESIZE
%--------------------------------------------------------------------------
eml_lib_assert(isinteger(imageSize) || isfloat(imageSize), ...
  'vision:isEpipoleInImage:invalidImageSizeClass', ...
  'Expected IMAGESIZE to be double, single, or integer.');

eml_lib_assert(isreal(imageSize) && ~issparse(imageSize), ...
  'vision:isEpipoleInImage:invalidImageSizeType', ...
  'Expected IMAGESIZE to be real and nonsparse.');

eml_lib_assert(isvector(imageSize) && numel(imageSize) >= 2, ...
  'vision:isEpipoleInImage:invalidImageSizeSize', ...
  'Expected IMAGESIZE to be a vector of two or more elements.');

eml_lib_assert(all(all(imageSize == floor(imageSize))) ...
  && all(all(imageSize > 0)), ...
  'vision:isEpipoleInImage:invalidImageSizeValue', ...
  'Expected IMAGESIZE to have positive integer values.');
