Cortex
10.0.0-a4
|
#include <LensModel.h>
Classes | |
struct | LensModelRegistration |
Public Types | |
enum | { Distort = 0, Undistort = 1 } |
typedef LensModelPtr(* | CreatorFn) (ConstCompoundObjectPtr data) |
![]() | |
typedef RefCounted | BaseClass |
A typedef for the class this class derives from. All RunTimeTyped classes define this typedef. | |
![]() | |
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 |
![]() | |
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. | |
CompoundParameter * | parameters () override |
const CompoundParameter * | parameters () const override |
Returns the parameters for query. | |
CompoundObject * | userData () |
Returns an object that anyone can use for storing anything. | |
const CompoundObject * | userData () const |
Read only version of the above. | |
![]() | |
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 |
![]() | |
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 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. | |
![]() | |
typedef std::map< TypeId, TypeId > | BaseTypeRegistryMap |
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, TypeId > | TypeNamesToTypeIdsMap |
![]() | |
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 Mutex | g_baseTypeIdsMutex |
static Mutex | g_derivedTypeIdsMutex |
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:
|
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.
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.
mode | Distort/Undistort |
input | The data window of the input |
width | The width in pixels of the display window (also known as the format) of the input. |
height | The height in pixels of the display window (also known as the format) of the input. |
|
static |
Instantiates a new LensModel object and initialises it with the parameters held within lensParams.
lensParams | Must contain a string object called "lensModel" that contains the name of the registered lens model to instantiate. |
|
static |
Instantiates a new LensModel object from just the lens model's typeName.
name | The typeName() of the registered lens model. |
|
static |
|
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.
uv | The undistorted point that will be distorted. Should be a 2D vector in pixel space. |
Implemented in IECore::StandardRadialLensModel.
|
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.
uv | The distorted point that will be undistorted. Should be a 2D vector in pixel space. |
Implemented in IECore::StandardRadialLensModel.
|
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.