Camera calibration structure used for camera calibration tasks. More...
#include <CameraCalibration.h>
Data Structures | |
struct | GradientDescentParameters |
Parameter struct for gradient descent. More... | |
struct | LabColor |
Structure to store Lab color values. More... | |
Public Member Functions | |
CameraCalibration (helios::Context *context) | |
std::vector< uint > | addCheckerboard (const helios::int2 &boardsidesize, const float &patchsize, const helios::vec3 ¢relocation, const helios::vec3 &rotationrad, bool firstblack=true) |
Add checker board geometry into context. | |
std::vector< uint > | addDefaultCheckerboard (const helios::vec3 ¢relocation, const helios::vec3 &rotationrad) |
Add default checker board geometry into context. | |
std::vector< uint > | addColorboard (const helios::vec3 ¢relocation, float patchsize, const helios::vec3 &rotationrad, const std::vector< std::vector< helios::RGBcolor > > &colorassignment={}, const std::vector< std::vector< std::string > > &spectrumassignment={}) |
Add color board geometry into context. | |
std::vector< uint > | addColorboard (const helios::vec3 ¢relocation, float patchsize, const helios::vec3 &rotationrad, const std::vector< std::vector< helios::RGBcolor > > &colorassignment, const std::vector< std::vector< std::string > > &spectrumassignment, const std::string &colorboard_type) |
Add color board geometry into context with colorboard type labeling. | |
std::vector< uint > | addDefaultColorboard (const helios::vec3 ¢relocation, float patchsize=0.5, const helios::vec3 &rotationrad=helios::make_vec3(0, 0, 0)) |
Add default color board (DGK-DKK) with spectral reflectivity values. | |
std::vector< uint > | addDGKColorboard (const helios::vec3 ¢relocation, float patchsize=0.5, const helios::vec3 &rotationrad=helios::make_vec3(0, 0, 0)) |
Add DGK-DKK calibration color board. | |
std::vector< uint > | addCalibriteColorboard (const helios::vec3 ¢relocation, float patchsize=0.5, const helios::vec3 &rotationrad=helios::make_vec3(0, 0, 0)) |
Add Calibrite ColorChecker Classic calibration color board. | |
std::vector< uint > | addSpyderCHECKRColorboard (const helios::vec3 ¢relocation, float patchsize=0.5, const helios::vec3 &rotationrad=helios::make_vec3(0, 0, 0)) |
Add Datacolor SpyderCHECKR 24 calibration color board. | |
std::vector< uint > | getColorBoardUUIDs () |
Retrieves a list of color board UUIDs. | |
bool | writeSpectralXMLfile (const std::string &filename, const std::string ¬e, const std::string &label, std::vector< helios::vec2 > *spectrum) |
Write XML file from spectral vectors containing both wavelengths and spectral values. | |
bool | loadXMLlabeldata (const std::string &filename, const std::string &labelname, std::vector< helios::vec2 > &spectraldata) |
Load XML file and save data in spectral vectors containing both wavelengths and spectral values. | |
float | GradientDescent (std::vector< std::vector< float > > *expandedcameraspectra, const std::vector< std::vector< float > > &expandedconstinput, const float &learningrate, const std::vector< std::vector< float > > &truevalues) |
Reduce calibration error based on gradient descent. | |
std::vector< float > | updateCameraResponseSpectra (const std::vector< std::string > &camerareponselabels, const std::string &cameralabel, const std::map< uint, std::vector< helios::vec2 > > &simulatedinputspectra, const std::vector< std::vector< float > > &truevalues) |
Update camera response spectra. | |
void | preprocessSpectra (const std::vector< std::string > &sourcelabels, const std::vector< std::string > &cameralabels, std::vector< std::string > &objectlabels, helios::vec2 &wavelengthrange, const std::string &targetlabel="") |
Preprocess all spectra for modelling. | |
void | distortImage (const std::string &cameralabel, const std::vector< std::string > &bandlabels, const helios::vec2 &focalxy, std::vector< double > &distCoeffs, helios::int2 cameraresolution) |
Get distorted image. | |
float | getCameraResponseScale (const std::string &cameralabel, const helios::int2 cameraresolution, const std::vector< std::string > &bandlabels, const std::vector< std::vector< float > > &truevalues) |
Get camera spectral response scale. | |
std::vector< uint > | readROMCCanopy () |
Read ROMC canopy file (Used for self test). | |
void | writeCalibratedCameraResponses (const std::vector< std::string > &camerareponselabels, const std::string &calibratemark, float scale) |
Write calibrated camera response spectra. | |
std::string | detectColorBoardType () const |
Detect which colorboard type is present in the scene. | |
std::vector< LabColor > | getReferenceLab_DGK () const |
Get reference Lab values for DGK colorboard (18 patches) | |
std::vector< LabColor > | getReferenceLab_Calibrite () const |
Get reference Lab values for Calibrite ColorChecker Classic (24 patches) | |
std::vector< LabColor > | getReferenceLab_SpyderCHECKR () const |
Get reference Lab values for Datacolor SpyderCHECKR 24 (24 patches) | |
LabColor | rgbToLab (const helios::vec3 &rgb) const |
Convert RGB color to Lab color space (RGB as vec3 [0,1]) | |
helios::vec3 | labToRgb (const LabColor &lab) const |
Convert Lab color to RGB color space (returns vec3 [0,1]) | |
double | deltaE76 (const LabColor &lab1, const LabColor &lab2) const |
Calculate Delta E 76 (CIE76) color difference between two Lab colors. | |
double | deltaE2000 (const LabColor &lab1, const LabColor &lab2) const |
Calculate Delta E 2000 color difference between two Lab colors (more perceptually accurate) | |
Data Fields | |
GradientDescentParameters | responseupdateparameters |
std::map< std::string, std::map< std::string, std::vector< helios::vec2 > > > | processedspectra |
Camera calibration structure used for camera calibration tasks.
Definition at line 21 of file CameraCalibration.h.
|
explicit |
Definition at line 20 of file CameraCalibration.cpp.
std::vector< uint > CameraCalibration::addCalibriteColorboard | ( | const helios::vec3 & | centrelocation, |
float | patchsize = 0.5 , |
||
const helios::vec3 & | rotationrad = helios::make_vec3(0, 0, 0) |
||
) |
Add Calibrite ColorChecker Classic calibration color board.
[in] | centrelocation | Location of the board (vec3 on coordinates x,y,z) |
[in] | patchsize | Size of each color patch in color board |
[in] | rotationrad | Radians of rotation (vec3 on coordinates x,y,z) |
Definition at line 219 of file CameraCalibration.cpp.
std::vector< uint > CameraCalibration::addCheckerboard | ( | const helios::int2 & | boardsidesize, |
const float & | patchsize, | ||
const helios::vec3 & | centrelocation, | ||
const helios::vec3 & | rotationrad, | ||
bool | firstblack = true |
||
) |
Add checker board geometry into context.
[in] | boardsidesize | size of check board |
[in] | patchsize | size of each square patch |
[in] | centrelocation | location of the board (vec3 on coordinates x,y,z) |
[in] | rotationrad | radians of rotation (vec3 on coordinates x,y,z) |
[in] | firstblack | initial the color of first square patch (black or white) |
Definition at line 23 of file CameraCalibration.cpp.
std::vector< uint > CameraCalibration::addColorboard | ( | const helios::vec3 & | centrelocation, |
float | patchsize, | ||
const helios::vec3 & | rotationrad, | ||
const std::vector< std::vector< helios::RGBcolor > > & | colorassignment, | ||
const std::vector< std::vector< std::string > > & | spectrumassignment, | ||
const std::string & | colorboard_type | ||
) |
Add color board geometry into context with colorboard type labeling.
[in] | centrelocation | location of the board center (vec3 on coordinates x,y,z) |
[in] | patchsize | size of each square color patch on the board |
[in] | rotationrad | rotation the board about x-, y-, and z-axes |
[in] | colorassignment | Color of each patch and size of color board. First index is the row and second index is the column. |
[in] | spectrumassignment | Label of global data corresponding to the reflectance spectrum of each color patch on the color board. First index is the row and second index is the column. |
[in] | colorboard_type | String identifier for the colorboard type (e.g., "DGK", "Calibrite", "SpyderCHECKR") |
Definition at line 140 of file CameraCalibration.cpp.
std::vector< uint > CameraCalibration::addColorboard | ( | const helios::vec3 & | centrelocation, |
float | patchsize, | ||
const helios::vec3 & | rotationrad, | ||
const std::vector< std::vector< helios::RGBcolor > > & | colorassignment = {} , |
||
const std::vector< std::vector< std::string > > & | spectrumassignment = {} |
||
) |
Add color board geometry into context.
[in] | centrelocation | location of the board center (vec3 on coordinates x,y,z) |
[in] | patchsize | size of each square color patch on the board |
[in] | rotationrad | rotation the board about x-, y-, and z-axes |
[in] | colorassignment | [OPTIONAL] Color of each patch and size of color board. First index is the row and second index is the column. |
[in] | spectrumassignment | [OPTIONAL] Label of global data corresponding to the reflectance spectrum of each color patch on the color board. First index is the row and second index is the column. |
Definition at line 81 of file CameraCalibration.cpp.
std::vector< uint > CameraCalibration::addDefaultCheckerboard | ( | const helios::vec3 & | centrelocation, |
const helios::vec3 & | rotationrad | ||
) |
Add default checker board geometry into context.
[in] | centrelocation | location of the board (vec3 on coordinates x,y,z) |
[in] | rotationrad | radians of rotation (vec3 on coordinates x,y,z) |
Definition at line 73 of file CameraCalibration.cpp.
std::vector< uint > CameraCalibration::addDefaultColorboard | ( | const helios::vec3 & | centrelocation, |
float | patchsize = 0.5 , |
||
const helios::vec3 & | rotationrad = helios::make_vec3(0, 0, 0) |
||
) |
Add default color board (DGK-DKK) with spectral reflectivity values.
[in] | centrelocation | Location of the board (vec3 on coordinates x,y,z) |
[in] | patchsize | Size of each color patch in color board |
[in] | rotationrad | Radians of rotation (vec3 on coordinates x,y,z) |
Definition at line 200 of file CameraCalibration.cpp.
std::vector< uint > CameraCalibration::addDGKColorboard | ( | const helios::vec3 & | centrelocation, |
float | patchsize = 0.5 , |
||
const helios::vec3 & | rotationrad = helios::make_vec3(0, 0, 0) |
||
) |
Add DGK-DKK calibration color board.
[in] | centrelocation | Location of the board (vec3 on coordinates x,y,z) |
[in] | patchsize | Size of each color patch in color board |
[in] | rotationrad | Radians of rotation (vec3 on coordinates x,y,z) |
Definition at line 205 of file CameraCalibration.cpp.
std::vector< uint > CameraCalibration::addSpyderCHECKRColorboard | ( | const helios::vec3 & | centrelocation, |
float | patchsize = 0.5 , |
||
const helios::vec3 & | rotationrad = helios::make_vec3(0, 0, 0) |
||
) |
Add Datacolor SpyderCHECKR 24 calibration color board.
[in] | centrelocation | Location of the board (vec3 on coordinates x,y,z) |
[in] | patchsize | Size of each color patch in color board |
[in] | rotationrad | Radians of rotation (vec3 on coordinates x,y,z) |
Definition at line 233 of file CameraCalibration.cpp.
Calculate Delta E 2000 color difference between two Lab colors (more perceptually accurate)
Definition at line 988 of file CameraCalibration.cpp.
Calculate Delta E 76 (CIE76) color difference between two Lab colors.
Definition at line 979 of file CameraCalibration.cpp.
std::string CameraCalibration::detectColorBoardType | ( | ) | const |
Detect which colorboard type is present in the scene.
Definition at line 832 of file CameraCalibration.cpp.
void CameraCalibration::distortImage | ( | const std::string & | cameralabel, |
const std::vector< std::string > & | bandlabels, | ||
const helios::vec2 & | focalxy, | ||
std::vector< double > & | distCoeffs, | ||
helios::int2 | cameraresolution | ||
) |
Get distorted image.
[in] | cameralabel | Label of camera. |
[in] | bandlabels | Label vector of bands. |
[in] | focalxy | Focal length xy of camera. |
[in] | distCoeffs | Distortion coefficients. |
[in] | cameraresolution | Resolution of camera. |
[in] | cameraresolution | Resolution of camera for distortion. |
Definition at line 455 of file CameraCalibration.cpp.
float CameraCalibration::getCameraResponseScale | ( | const std::string & | cameralabel, |
const helios::int2 | cameraresolution, | ||
const std::vector< std::string > & | bandlabels, | ||
const std::vector< std::vector< float > > & | truevalues | ||
) |
Get camera spectral response scale.
[in] | cameralabel | Label of camera. |
[in] | cameraresolution | Resolution of camera. |
[in] | bandlabels | Label vector of bands. |
[in] | truevalues | True color board values. |
Definition at line 670 of file CameraCalibration.cpp.
std::vector< uint > CameraCalibration::getColorBoardUUIDs | ( | ) |
Retrieves a list of color board UUIDs.
Definition at line 247 of file CameraCalibration.cpp.
std::vector< CameraCalibration::LabColor > CameraCalibration::getReferenceLab_Calibrite | ( | ) | const |
Get reference Lab values for Calibrite ColorChecker Classic (24 patches)
Definition at line 770 of file CameraCalibration.cpp.
std::vector< CameraCalibration::LabColor > CameraCalibration::getReferenceLab_DGK | ( | ) | const |
Get reference Lab values for DGK colorboard (18 patches)
Definition at line 744 of file CameraCalibration.cpp.
std::vector< CameraCalibration::LabColor > CameraCalibration::getReferenceLab_SpyderCHECKR | ( | ) | const |
Get reference Lab values for Datacolor SpyderCHECKR 24 (24 patches)
Definition at line 801 of file CameraCalibration.cpp.
float CameraCalibration::GradientDescent | ( | std::vector< std::vector< float > > * | expandedcameraspectra, |
const std::vector< std::vector< float > > & | expandedconstinput, | ||
const float & | learningrate, | ||
const std::vector< std::vector< float > > & | truevalues | ||
) |
Reduce calibration error based on gradient descent.
[in] | expandedcameraspectra | Expanded camera response spectra to be updated. |
[in] | expandedconstinput | Expanded input spectra. |
[in] | learningrate | Learning rate. |
[in] | truevalues | True color board values. |
Definition at line 299 of file CameraCalibration.cpp.
helios::vec3 CameraCalibration::labToRgb | ( | const LabColor & | lab | ) | const |
Convert Lab color to RGB color space (returns vec3 [0,1])
Definition at line 933 of file CameraCalibration.cpp.
bool CameraCalibration::loadXMLlabeldata | ( | const std::string & | filename, |
const std::string & | labelname, | ||
std::vector< helios::vec2 > & | spectraldata | ||
) |
Load XML file and save data in spectral vectors containing both wavelengths and spectral values.
[in] | filename | Name with path of XML file |
[in] | labelname | Label name of data |
[in] | spectraldata | An empty spectral vector to be filled |
Definition at line 285 of file CameraCalibration.cpp.
void CameraCalibration::preprocessSpectra | ( | const std::vector< std::string > & | sourcelabels, |
const std::vector< std::string > & | cameralabels, | ||
std::vector< std::string > & | objectlabels, | ||
helios::vec2 & | wavelengthrange, | ||
const std::string & | targetlabel = "" |
||
) |
Preprocess all spectra for modelling.
[in] | sourcelabels | Label vector of source spectra. |
[in] | cameralabels | Label vector of camera spectra. |
[in] | objectlabels | Label vector of object spectra. |
[in,out] | wavelengthrange | Min and max of wavelength boundary. |
[in] | targetlabel | Label of target spectrum used for interpolation. |
Definition at line 546 of file CameraCalibration.cpp.
std::vector< uint > CameraCalibration::readROMCCanopy | ( | ) |
Read ROMC canopy file (Used for self test).
Definition at line 709 of file CameraCalibration.cpp.
CameraCalibration::LabColor CameraCalibration::rgbToLab | ( | const helios::vec3 & | rgb | ) | const |
Convert RGB color to Lab color space (RGB as vec3 [0,1])
Definition at line 895 of file CameraCalibration.cpp.
std::vector< float > CameraCalibration::updateCameraResponseSpectra | ( | const std::vector< std::string > & | camerareponselabels, |
const std::string & | cameralabel, | ||
const std::map< uint, std::vector< helios::vec2 > > & | simulatedinputspectra, | ||
const std::vector< std::vector< float > > & | truevalues | ||
) |
Update camera response spectra.
[in] | camerareponselabels | Label vector of camera response spectra to be updated. |
[in] | cameralabel | Label of camera to be used for simulation. |
[in] | simulatedinputspectra | Input spectra. |
[in] | truevalues | True color board values. |
Definition at line 372 of file CameraCalibration.cpp.
void CameraCalibration::writeCalibratedCameraResponses | ( | const std::vector< std::string > & | camerareponselabels, |
const std::string & | calibratemark, | ||
float | scale | ||
) |
Write calibrated camera response spectra.
[in] | camerareponselabels | Label vector of original camera response spectra to be written. |
[in] | calibratemark | Calibration mark. |
[in] | scale | Manually adjustable Scaling factor for calibrated camera response spectra. |
Definition at line 441 of file CameraCalibration.cpp.
bool CameraCalibration::writeSpectralXMLfile | ( | const std::string & | filename, |
const std::string & | note, | ||
const std::string & | label, | ||
std::vector< helios::vec2 > * | spectrum | ||
) |
Write XML file from spectral vectors containing both wavelengths and spectral values.
[in] | filename | Name with path of XML file |
[in] | note | Note to write in XML file |
[in] | label | Label of spectral data to write in XML file |
[in] | spectrum | Pointer of spectrum to write in XML file |
Definition at line 251 of file CameraCalibration.cpp.
std::map<std::string, std::map<std::string, std::vector<helios::vec2> > > CameraCalibration::processedspectra |
Definition at line 195 of file CameraCalibration.h.
GradientDescentParameters CameraCalibration::responseupdateparameters |
Definition at line 163 of file CameraCalibration.h.