-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
784 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ namespace depth_to_rgb_calibration { | |
double step_size = 0; | ||
}; | ||
|
||
|
||
struct params | ||
{ | ||
params(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# License: Apache 2.0. See LICENSE file in root directory. | ||
# Copyright(c) 2020 Intel Corporation. All Rights Reserved. | ||
target_sources(${LRS_TARGET} | ||
PRIVATE | ||
"${CMAKE_CURRENT_LIST_DIR}/l500-thermal-loop.h" | ||
"${CMAKE_CURRENT_LIST_DIR}/l500-thermal-loop.cpp" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2020 Intel Corporation. All Rights Reserved. | ||
|
||
#include "l500-thermal-loop.h" | ||
#include "../../l500/l500-private.h" | ||
|
||
namespace librealsense { | ||
namespace algo { | ||
namespace thermal_loop { | ||
namespace l500 { | ||
|
||
|
||
const int thermal_calibration_table::id = 0x317; | ||
|
||
|
||
thermal_calibration_table::thermal_calibration_table( const std::vector< byte > & data, | ||
int resolution ) | ||
: _resolution( resolution ) | ||
{ | ||
float const * header_ptr = (float *)( data.data() + sizeof( ivcam2::table_header ) ); | ||
|
||
auto expected_size = sizeof( ivcam2::table_header ) + sizeof( thermal_table_header ) | ||
+ sizeof( thermal_bin ) * resolution; | ||
|
||
if( data.size() != expected_size ) | ||
throw std::runtime_error( librealsense::to_string() | ||
<< "data size (" << data.size() | ||
<< ") does not meet expected size " << expected_size ); | ||
|
||
_header = *(thermal_table_header *)( header_ptr ); | ||
|
||
auto data_ptr = (thermal_bin *)( data.data() + sizeof( ivcam2::table_header ) | ||
+ sizeof( thermal_table_header ) ); | ||
bins.assign( data_ptr, data_ptr + resolution ); | ||
} | ||
|
||
|
||
bool operator==( const thermal_calibration_table & lhs, const thermal_calibration_table & rhs ) | ||
{ | ||
if( lhs.bins.size() != rhs.bins.size() ) | ||
return false; | ||
|
||
if( lhs._header.max_temp != rhs._header.max_temp || lhs._header.min_temp != rhs._header.min_temp | ||
|| lhs._header.reference_temp != rhs._header.reference_temp | ||
|| lhs._header.valid != rhs._header.valid ) | ||
return false; | ||
|
||
for( auto i = 0; i < rhs.bins.size(); i++ ) | ||
{ | ||
if( lhs.bins[i].scale != rhs.bins[i].scale || lhs.bins[i].sheer != rhs.bins[i].sheer | ||
|| lhs.bins[i].tx != rhs.bins[i].tx || lhs.bins[i].ty != rhs.bins[i].ty ) | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
|
||
double thermal_calibration_table::get_thermal_scale( double hum_temp ) const | ||
{ | ||
auto scale = bins[_resolution - 1].scale; | ||
|
||
auto temp_range = _header.max_temp - _header.min_temp; | ||
// there are 29 bins between min and max temps so 30 equal intervals | ||
auto const interval = temp_range / ( _resolution + 1 ); | ||
// T: |---|---|---| ... |---| | ||
// min 0 1 2 ... 28 max | ||
size_t index = 0; | ||
for( double temp = _header.min_temp; index < _resolution; | ||
++index, temp += interval ) | ||
{ | ||
auto interval_max = temp + interval; | ||
if( hum_temp <= interval_max ) | ||
{ | ||
scale = bins[index].scale; | ||
break; | ||
} | ||
} | ||
|
||
// The "scale" is meant to be divided by, but we want something to multiply with! | ||
if( scale == 0 ) | ||
throw std::runtime_error( "invalid 0 scale in thermal table" ); | ||
return 1. / scale; | ||
} | ||
|
||
|
||
std::vector< byte > thermal_calibration_table::build_raw_data() const | ||
{ | ||
std::vector< float > data; | ||
data.resize( sizeof( ivcam2::table_header ) / sizeof( float ), 0 ); | ||
data.push_back( _header.min_temp ); | ||
data.push_back( _header.max_temp ); | ||
data.push_back( _header.reference_temp ); | ||
data.push_back( _header.valid ); | ||
|
||
for( auto i = 0; i < bins.size(); i++ ) | ||
{ | ||
data.push_back( bins[i].scale ); | ||
data.push_back( bins[i].sheer ); | ||
data.push_back( bins[i].tx ); | ||
data.push_back( bins[i].ty ); | ||
} | ||
|
||
std::vector< byte > res; | ||
res.assign( (byte *)( data.data() ), (byte *)( data.data() + data.size() ) ); | ||
return res; | ||
} | ||
|
||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2020 Intel Corporation. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
#include "../../types.h" | ||
#include "thermal-calibration-table-interface.h" | ||
|
||
namespace librealsense { | ||
namespace algo { | ||
namespace thermal_loop { | ||
namespace l500 { | ||
|
||
|
||
// RGB_Thermal_Info_CalibInfo table | ||
// ----------------------------------- | ||
// | ||
// The table contains equally spaced bins between min & max temperature. | ||
// | ||
// Each bin has a set of 4 transformation parameters. The transformation maps a point in the RGB | ||
// image in a given temperature to its expected location in the temperature in which the RGB module | ||
// was calibrated. | ||
// | ||
// Reference at: | ||
// https://rsconf.intel.com/display/L500/0x317+RGB+Thermal+Table | ||
// | ||
#pragma pack( push, 1 ) | ||
class thermal_calibration_table : public thermal_calibration_table_interface | ||
{ | ||
public: | ||
static const int id; | ||
|
||
// The header as it's written raw | ||
struct thermal_table_header | ||
{ | ||
float min_temp; | ||
float max_temp; | ||
float reference_temp; // not used | ||
float valid; // not used | ||
}; | ||
|
||
// Each bin data, as it's written in the actual raw table | ||
struct thermal_bin | ||
{ | ||
float scale; | ||
float sheer; // parameters which affect offset that are not in use | ||
float tx; | ||
float ty; | ||
}; | ||
|
||
// Number of bins *between* min and max: | ||
// bin - size = ( max - min ) / ( resolution + 1 ) | ||
// In the raw calibration table, 29 is implicitly used. | ||
size_t _resolution; | ||
|
||
thermal_table_header _header; | ||
std::vector< thermal_bin > bins; | ||
|
||
thermal_calibration_table() = default; | ||
thermal_calibration_table( const std::vector< byte > & data, int resolution = 29 ); | ||
|
||
double get_thermal_scale( double hum_temp ) const override; | ||
|
||
std::vector< byte > build_raw_data() const override; | ||
}; | ||
#pragma pack( pop ) | ||
|
||
bool operator==( const thermal_calibration_table & lhs, const thermal_calibration_table & rhs ); | ||
|
||
} // namespace l500 | ||
} // namespace thermal_loop | ||
} // namespace algo | ||
} // namespace librealsense |
25 changes: 25 additions & 0 deletions
25
src/algo/thermal-loop/thermal-calibration-table-interface.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2020 Intel Corporation. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
|
||
namespace librealsense { | ||
namespace algo { | ||
namespace thermal_loop { | ||
|
||
|
||
struct thermal_calibration_table_interface | ||
{ | ||
virtual ~thermal_calibration_table_interface() {} | ||
|
||
virtual double get_thermal_scale( double hum_temp ) const = 0; | ||
|
||
virtual std::vector< byte > build_raw_data() const = 0; | ||
}; | ||
|
||
|
||
} // namespace thermal_loop | ||
} // namespace algo | ||
} // namespace librealsense |
Oops, something went wrong.