Cortex  10.0.0-a4
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
IECore::LensModel Class Referenceabstract

#include <LensModel.h>

+ Inheritance diagram for IECore::LensModel:

Classes

struct  LensModelRegistration
 

Public Types

enum  { Distort = 0, Undistort = 1 }
 
typedef LensModelPtr(* CreatorFn) (ConstCompoundObjectPtr data)
 
- Public Types inherited from IECore::RunTimeTyped
typedef RefCounted BaseClass
 A typedef for the class this class derives from. All RunTimeTyped classes define this typedef.
 
- Public Types inherited from IECore::RefCounted
typedef size_t RefCount
 

Public Member Functions

 IE_CORE_DECLARERUNTIMETYPED (LensModel, Parameterised)
 
Imath::Box2i bounds (int mode, const Imath::Box2i &input, int width, int height)
 
Distort/Undistort Methods

A set of methods to distort or undistort points and bounding boxes.

virtual void validate ()=0
 
virtual Imath::V2d distort (Imath::V2d p)=0
 
virtual Imath::V2d undistort (Imath::V2d p)=0
 
- Public Member Functions inherited from IECore::Parameterised
 IE_CORE_DECLARERUNTIMETYPED (Parameterised, RunTimeTyped)
 
 Parameterised (const std::string &description)
 
 Parameterised (const std::string &description, CompoundParameterPtr compoundParameter)
 Another constructor added later on that gives defines the CompoundParameter object to be hold in this Parameterised instance.
 
const std::string & description () const
 Returns a description for this parameterised object.
 
CompoundParameterparameters () override
 
const CompoundParameterparameters () const override
 Returns the parameters for query.
 
CompoundObjectuserData ()
 Returns an object that anyone can use for storing anything.
 
const CompoundObjectuserData () const
 Read only version of the above.
 
- Public Member Functions inherited from IECore::RunTimeTyped
 IE_CORE_DECLAREMEMBERPTR (RunTimeTyped)
 
virtual TypeId typeId () const
 
virtual const char * typeName () const
 
virtual bool isInstanceOf (TypeId typeId) const
 
virtual bool isInstanceOf (const char *typeName) const
 
- Public Member Functions inherited from IECore::RefCounted
 IE_CORE_DECLAREMEMBERPTR (RefCounted)
 
void addRef () const
 Add a reference to the current object.
 
void removeRef () const
 Remove a reference from the current object.
 
RefCount refCount () const
 Returns the current reference count.
 

Public Attributes

enum IECore::LensModel:: { ... }  DistortionMode
 

Lens Model Registry

A set of methods to query the available lens models and create them.

static LensModelPtr create (ConstCompoundObjectPtr lensParams)
 
static LensModelPtr create (const std::string &name)
 
static LensModelPtr create (TypeId id)
 
static std::vector< std::string > lensModels ()
 Returns a vector of available lens models.
 
 LensModel ()
 
 ~LensModel () override
 

Additional Inherited Members

- Static Public Member Functions inherited from IECore::RunTimeTyped
static TypeId staticTypeId ()
 Returns the TypeId for this class, without needing an instance.
 
static const char * staticTypeName ()
 Returns the type name for this class, without needing an instance.
 
static TypeId baseTypeId ()
 
static const char * baseTypeName ()
 
static bool inheritsFrom (TypeId typeId)
 Returns true if this class inherits from the specified type.
 
static bool inheritsFrom (const char *typeName)
 Returns true if this class inherits from the specified type.
 
static bool inheritsFrom (TypeId type, TypeId baseType)
 Returns true if type inherits from baseType.
 
static bool inheritsFrom (const char *typeName, const char *baseTypeName)
 Returns true if typeName inherits from baseTypeName.
 
static TypeId baseTypeId (TypeId typeId)
 Returns the base type of the given type, or InvalidTypeId if no such base exists.
 
static const std::vector< TypeId > & baseTypeIds (TypeId typeId)
 
static const std::set< TypeId > & derivedTypeIds (TypeId typeId)
 
static TypeId typeIdFromTypeName (const char *typeName)
 
static const char * typeNameFromTypeId (TypeId typeId)
 
static void registerType (TypeId derivedTypeId, const char *derivedTypeName, TypeId baseTypeId)
 Allows external modules to register their own type ids.
 
- Protected Types inherited from IECore::RunTimeTyped
typedef std::map< TypeId, TypeIdBaseTypeRegistryMap
 
typedef std::map< TypeId, std::vector< TypeId > > BaseTypesRegistryMap
 
typedef std::map< TypeId, std::set< TypeId > > DerivedTypesRegistryMap
 
typedef tbb::spin_rw_mutex Mutex
 
typedef std::map< TypeId, std::string > TypeIdsToTypeNamesMap
 
typedef std::map< std::string, TypeIdTypeNamesToTypeIdsMap
 
- Static Protected Member Functions inherited from IECore::RunTimeTyped
static BaseTypeRegistryMap & baseTypeRegistry ()
 
static DerivedTypesRegistryMap & derivedTypesRegistry ()
 
static BaseTypesRegistryMap & completeBaseTypesRegistry ()
 
static DerivedTypesRegistryMap & completeDerivedTypesRegistry ()
 
static void derivedTypeIdsWalk (TypeId typeId, std::set< TypeId > &)
 
static TypeIdsToTypeNamesMap & typeIdsToTypeNames ()
 
static TypeNamesToTypeIdsMap & typeNamesToTypeIds ()
 
- Static Protected Attributes inherited from IECore::RunTimeTyped
static Mutex g_baseTypeIdsMutex
 
static Mutex g_derivedTypeIdsMutex
 

Detailed Description

LensModel:

The LensModel class is the base for all IECore lens models which implements a simple framework for writing arbitrary lens distortion models. A simple interface is exposed in the form of the validate(), distort(), undistort() methods which should be reimplemented by any subclass to evaluate the parameters and perform the distortion of a point in UV space.

The static LensModel::create() methods are implemented as factory functions for creating LensModels. Derived classes should define a static instance of the LensModel::LensModelRegistration<> which will register it will the factory functions. A vector of all registered lens models can be returned by calling LensModel::lensModels(). As the factory functions were implemented to ensure correct initialization of the lens models, all derived classes should make their default constructor protected and add LensModel as a friend class.

LensModels can be serialized by just writing out the CompoundObject that contains it's parameters. LensModels can be easily loaded by just passing the same compound object containing it's parameter's values into LensModel::create().

To use an object derived from LensModel:

Constructor & Destructor Documentation

IECore::LensModel::LensModel ( )
protected

The Default Constructor is protected as the LensModel::create() method should be used to instantiate a new LensModel instead. This is the only way that we can ensure that the LensModel is initialized correctly.

Member Function Documentation

Imath::Box2i IECore::LensModel::bounds ( int  mode,
const Imath::Box2i &  input,
int  width,
int  height 
)

Calculates the distorted/undistorted data window of an image. The distorted bounding box is calculated by finding the smallest box that contains a set of distort points which were taken from the border of the undistorted bounding box.

Parameters
modeDistort/Undistort
inputThe data window of the input
widthThe width in pixels of the display window (also known as the format) of the input.
heightThe height in pixels of the display window (also known as the format) of the input.
static LensModelPtr IECore::LensModel::create ( ConstCompoundObjectPtr  lensParams)
static

Instantiates a new LensModel object and initialises it with the parameters held within lensParams.

Parameters
lensParamsMust contain a string object called "lensModel" that contains the name of the registered lens model to instantiate.
static LensModelPtr IECore::LensModel::create ( const std::string &  name)
static

Instantiates a new LensModel object from just the lens model's typeName.

Parameters
nameThe typeName() of the registered lens model.
static LensModelPtr IECore::LensModel::create ( TypeId  id)
static

Instantiates a new LensModel object from it's typeId.

Parameters
nameThe typeId() of the registered lens model.
virtual Imath::V2d IECore::LensModel::distort ( Imath::V2d  p)
pure virtual

Distorts a point in UV space of the range (0-1) where the lower left corner is 0,0. Should be implemented by derived classes to return the distorted UV coordinate.

Parameters
uvThe undistorted point that will be distorted. Should be a 2D vector in pixel space.

Implemented in IECore::StandardRadialLensModel.

virtual Imath::V2d IECore::LensModel::undistort ( Imath::V2d  p)
pure virtual

Undistorts a point in UV space of the range (0-1) where the lower left corner is 0,0. Should be implemented by derived classes to return the undistorted UV coordinate.

Parameters
uvThe distorted point that will be undistorted. Should be a 2D vector in pixel space.

Implemented in IECore::StandardRadialLensModel.

virtual void IECore::LensModel::validate ( )
pure virtual

Compute should be called to set up the internal values. This method must be called before subsequent calls to distort(), undistort() and bounds() or their results are undefined.

Implemented in IECore::StandardRadialLensModel.


The documentation for this class was generated from the following file: