148 label(std::move(initlabel)), band_labels(band_label), position(initposition), lookat(initlookat), antialiasing_samples(initantialiasing_samples) {
149 for (
const auto &band: band_label) {
150 band_spectral_response[band] =
"uniform";
156 HFOV_degrees = camera_properties.
HFOV;
159 model = camera_properties.
model;
163 exposure = camera_properties.
exposure;
182 float lens_focal_length;
186 float FOV_aspect_ratio;
188 float sensor_width_mm;
192 std::string lens_make;
194 std::string lens_model;
196 std::string lens_specification;
198 std::string exposure;
202 std::string white_balance;
206 std::string camera_type;
208 uint antialiasing_samples;
210 std::vector<std::string> band_labels;
212 std::map<std::string, std::string> band_spectral_response;
214 std::map<std::string, std::vector<float>> pixel_data;
216 std::vector<uint> pixel_label_UUID;
217 std::vector<float> pixel_depth;
242 void whiteBalance(
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label,
float p = 5.0);
254 void whiteBalanceGrayEdge(
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label,
int derivative_order = 1,
float p = 5.0);
264 void whiteBalanceWhitePatch(
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label,
float percentile = 0.99f);
288 void reinhardToneMapping(
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label);
299 void applyGain(
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label,
float percentile = 0.95f);
307 void adjustSBC(
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label,
float saturation,
float brightness,
float contrast);
325 void gammaCompress(
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label);
334 void globalHistogramEqualization(
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label);
343 void autoExposure(
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label,
float gain_multiplier);
381 void adjustBrightnessContrast(
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label,
float brightness,
float contrast);
390 void adjustSaturation(
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label,
float saturation);
403 return (x <= 0.0031308f) ? 12.92f * x : 1.055f * std::pow(x, 1.0f / 2.4f) - 0.055f;
412 return (v <= 0.04045f) ? v / 12.92f : std::pow((v + 0.055f) / 1.055f, 2.4f);
423 static float luminance(
float red,
float green,
float blue)
noexcept {
424 return 0.2126f * red + 0.7152f * green + 0.0722f * blue;
651 static int selfTest(
int argc = 0,
char **argv =
nullptr);
748 void setDiffuseSpectrumIntegral(
const std::string &band_label,
float spectrum_integral,
float wavelength_min,
float wavelength_max);
762 void addRadiationBand(
const std::string &label,
float wavelength_min,
float wavelength_max);
769 void copyRadiationBand(
const std::string &old_label,
const std::string &new_label);
778 void copyRadiationBand(
const std::string &old_label,
const std::string &new_label,
float wavelength_min,
float wavelength_max);
902 void setSourceFlux(
const std::vector<uint> &source_ID,
const std::string &band_label,
float flux);
946 void setSourceSpectrum(
const std::vector<uint> &source_ID,
const std::vector<helios::vec2> &spectrum);
960 void setSourceSpectrum(
const std::vector<uint> &source_ID,
const std::string &spectrum_label);
995 float integrateSpectrum(
const std::vector<helios::vec2> &object_spectrum,
float wavelength_min,
float wavelength_max)
const;
1002 float integrateSpectrum(
const std::vector<helios::vec2> &object_spectrum)
const;
1012 float integrateSpectrum(
uint source_ID,
const std::vector<helios::vec2> &object_spectrum,
float wavelength_min,
float wavelength_max)
const;
1021 float integrateSpectrum(
uint source_ID,
const std::vector<helios::vec2> &object_spectrum,
const std::vector<helios::vec2> &camera_spectrum)
const;
1029 float integrateSpectrum(
const std::vector<helios::vec2> &object_spectrum,
const std::vector<helios::vec2> &camera_spectrum)
const;
1046 void scaleSpectrum(
const std::string &existing_global_data_label,
const std::string &new_global_data_label,
float scale_factor)
const;
1053 void scaleSpectrum(
const std::string &global_data_label,
float scale_factor)
const;
1062 void scaleSpectrumRandomly(
const std::string &existing_global_data_label,
const std::string &new_global_data_label,
float minimum_scale_factor,
float maximum_scale_factor)
const;
1071 void blendSpectra(
const std::string &new_spectrum_label,
const std::vector<std::string> &spectrum_labels,
const std::vector<float> &weights)
const;
1079 void blendSpectraRandomly(
const std::string &new_spectrum_label,
const std::vector<std::string> &spectrum_labels)
const;
1093 void interpolateSpectrumFromPrimitiveData(
const std::vector<uint> &primitive_UUIDs,
const std::vector<std::string> &spectra,
const std::vector<float> &values,
const std::string &primitive_data_query_label,
1094 const std::string &primitive_data_radprop_label);
1109 void interpolateSpectrumFromObjectData(
const std::vector<uint> &object_IDs,
const std::vector<std::string> &spectra,
const std::vector<float> &values,
const std::string &object_data_query_label,
const std::string &primitive_data_radprop_label);
1153 uint antialiasing_samples);
1163 void setCameraSpectralResponse(
const std::string &camera_label,
const std::string &band_label,
const std::string &global_data);
1394 void runBand(
const std::string &label);
1402 void runBand(
const std::vector<std::string> &labels);
1429 void updateCameraResponse(
const std::string &orginalcameralabel,
const std::vector<std::string> &sourcelabels_raw,
const std::vector<std::string> &cameraresponselabels,
helios::vec2 &wavelengthrange,
1430 const std::vector<std::vector<float>> &truevalues,
const std::string &calibratedmark);
1442 float getCameraResponseScale(
const std::string &orginalcameralabel,
const std::vector<std::string> &cameraresponselabels,
const std::vector<std::string> &bandlabels,
const std::vector<std::string> &sourcelabels,
helios::vec2 &wavelengthrange,
1443 const std::vector<std::vector<float>> &truevalues);
1456 void runRadiationImaging(
const std::string &cameralabel,
const std::vector<std::string> &sourcelabels,
const std::vector<std::string> &bandlabels,
const std::vector<std::string> &cameraresponselabels,
helios::vec2 wavelengthrange,
1457 float fluxscale = 1,
float diffusefactor = 0.0005,
uint scatteringdepth = 4);
1470 void runRadiationImaging(
const std::vector<std::string> &cameralabels,
const std::vector<std::string> &sourcelabels,
const std::vector<std::string> &bandlabels,
const std::vector<std::string> &cameraresponselabels,
helios::vec2 wavelengthrange,
1471 float fluxscale = 1,
float diffusefactor = 0.0005,
uint scatteringdepth = 4);
1487 void applyCameraImageCorrections(
const std::string &cameralabel,
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label,
float saturation_adjustment = 1.f,
float brightness_adjustment = 1.f,
1488 float contrast_adjustment = 1.f);
1491 [[deprecated(
"Use applyCameraImageCorrections() instead")]]
1492 void applyImageProcessingPipeline(
const std::string &cameralabel,
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label,
float saturation_adjustment = 1.f,
float brightness_adjustment = 1.f,
1493 float contrast_adjustment = 1.f,
float gain_adjustment = 1.f);
1503 void applyCameraColorCorrectionMatrix(
const std::string &camera_label,
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label,
const std::string &ccm_file_path);
1517 std::string
writeCameraImage(
const std::string &camera,
const std::vector<std::string> &bands,
const std::string &imagefile_base,
const std::string &image_path =
"./",
int frame = -1,
float flux_to_pixel_conversion = 1.f);
1528 std::string
writeNormCameraImage(
const std::string &camera,
const std::vector<std::string> &bands,
const std::string &imagefile_base,
const std::string &image_path =
"./",
int frame = -1);
1538 void writeCameraImageData(
const std::string &camera,
const std::string &band,
const std::string &imagefile_base,
const std::string &image_path =
"./",
int frame = -1);
1549 void writePrimitiveDataLabelMap(
const std::string &cameralabel,
const std::string &primitive_data_label,
const std::string &imagefile_base,
const std::string &image_path =
"./",
int frame = -1,
float padvalue = NAN);
1560 void writeObjectDataLabelMap(
const std::string &cameralabel,
const std::string &object_data_label,
const std::string &imagefile_base,
const std::string &image_path =
"./",
int frame = -1,
float padvalue = NAN);
1569 void writeDepthImageData(
const std::string &cameralabel,
const std::string &imagefile_base,
const std::string &image_path =
"./",
int frame = -1);
1579 void writeNormDepthImage(
const std::string &cameralabel,
const std::string &imagefile_base,
float max_depth,
const std::string &image_path =
"./",
int frame = -1);
1592 void writeImageBoundingBoxes(
const std::string &cameralabel,
const std::string &primitive_data_label,
uint object_class_ID,
const std::string &imagefile_base,
const std::string &image_path =
"./",
bool append_label_file =
false,
int frame = -1);
1605 void writeImageBoundingBoxes_ObjectData(
const std::string &cameralabel,
const std::string &object_data_label,
uint object_class_ID,
const std::string &imagefile_base,
const std::string &image_path =
"./",
bool append_label_file =
false,
1618 void writeImageBoundingBoxes(
const std::string &cameralabel,
const std::string &primitive_data_label,
const uint &object_class_ID,
const std::string &image_file,
const std::string &classes_txt_file =
"classes.txt",
1619 const std::string &image_path =
"./");
1631 void writeImageBoundingBoxes(
const std::string &cameralabel,
const std::vector<std::string> &primitive_data_label,
const std::vector<uint> &object_class_ID,
const std::string &image_file,
const std::string &classes_txt_file =
"classes.txt",
1632 const std::string &image_path =
"./");
1644 void writeImageBoundingBoxes_ObjectData(
const std::string &cameralabel,
const std::string &object_data_label,
const uint &object_class_ID,
const std::string &image_file,
const std::string &classes_txt_file =
"classes.txt",
1645 const std::string &image_path =
"./");
1657 void writeImageBoundingBoxes_ObjectData(
const std::string &cameralabel,
const std::vector<std::string> &object_data_label,
const std::vector<uint> &object_class_ID,
const std::string &image_file,
1658 const std::string &classes_txt_file =
"classes.txt",
const std::string &image_path =
"./");
1672 void writeImageSegmentationMasks(
const std::string &cameralabel,
const std::string &primitive_data_label,
const uint &object_class_ID,
const std::string &json_filename,
const std::string &image_file,
1673 const std::vector<std::string> &data_attribute_labels = {},
bool append_file =
false);
1687 void writeImageSegmentationMasks(
const std::string &cameralabel,
const std::vector<std::string> &primitive_data_label,
const std::vector<uint> &object_class_ID,
const std::string &json_filename,
const std::string &image_file,
1688 const std::vector<std::string> &data_attribute_labels = {},
bool append_file =
false);
1702 void writeImageSegmentationMasks_ObjectData(
const std::string &cameralabel,
const std::string &object_data_label,
const uint &object_class_ID,
const std::string &json_filename,
const std::string &image_file,
1703 const std::vector<std::string> &data_attribute_labels = {},
bool append_file =
false);
1717 void writeImageSegmentationMasks_ObjectData(
const std::string &cameralabel,
const std::vector<std::string> &object_data_label,
const std::vector<uint> &object_class_ID,
const std::string &json_filename,
const std::string &image_file,
1718 const std::vector<std::string> &data_attribute_labels = {},
bool append_file =
false);
1722 std::pair<nlohmann::json, int> initializeCOCOJsonWithImageId(
const std::string &filename,
bool append_file,
const std::string &cameralabel,
const helios::int2 &camera_resolution,
const std::string &image_file);
1723 nlohmann::json initializeCOCOJson(
const std::string &filename,
bool append_file,
const std::string &cameralabel,
const helios::int2 &camera_resolution,
const std::string &image_file);
1724 void addCategoryToCOCO(nlohmann::json &coco_json,
const std::vector<uint> &object_class_ID,
const std::vector<std::string> &category_name);
1725 void writeCOCOJson(
const nlohmann::json &coco_json,
const std::string &filename);
1728 std::map<int, std::vector<std::vector<bool>>> generateLabelMasks(
const std::string &cameralabel,
const std::string &data_label,
bool use_object_data);
1729 std::pair<int, int> findStartingBoundaryPixel(
const std::vector<std::vector<bool>> &mask,
const helios::int2 &camera_resolution);
1730 std::vector<std::pair<int, int>> traceBoundaryMoore(
const std::vector<std::vector<bool>> &mask,
int start_x,
int start_y,
const helios::int2 &camera_resolution);
1731 std::vector<std::pair<int, int>> traceBoundarySimple(
const std::vector<std::vector<bool>> &mask,
int start_x,
int start_y,
const helios::int2 &camera_resolution);
1732 std::vector<std::map<std::string, std::vector<float>>> generateAnnotationsFromMasks(
const std::map<
int, std::vector<std::vector<bool>>> &label_masks,
uint object_class_ID,
const helios::int2 &camera_resolution,
int image_id);
1735 std::string detectLightingType()
const;
1738 void populateCameraMetadata(
const std::string &camera_label,
CameraMetadata &metadata)
const;
1739 std::string writeCameraMetadataFile(
const std::string &camera_label,
const std::string &output_path =
"./")
const;
1748 void setPadValue(
const std::string &cameralabel,
const std::vector<std::string> &bandlabels,
const std::vector<float> &padvalues);
1760 void calibrateCamera(
const std::string &orginalcameralabel,
const std::vector<std::string> &sourcelabels,
const std::vector<std::string> &cameraresponselabels,
const std::vector<std::string> &bandlabels,
const float scalefactor,
1761 const std::vector<std::vector<float>> &truevalues,
const std::string &calibratedmark);
1770 void calibrateCamera(
const std::string &originalcameralabel,
const float scalefactor,
const std::vector<std::vector<float>> &truevalues,
const std::string &calibratedmark);
1791 std::string
autoCalibrateCameraImage(
const std::string &camera_label,
const std::string &red_band_label,
const std::string &green_band_label,
const std::string &blue_band_label,
const std::string &output_file_path,
1795 void exportColorCorrectionMatrixXML(
const std::string &file_path,
const std::string &camera_label,
const std::vector<std::vector<float>> &matrix,
const std::string &source_image_path,
const std::string &colorboard_type,
float average_delta_e);
1801 std::vector<float>
getCameraPixelData(
const std::string &camera_label,
const std::string &band_label);
1804 void setCameraPixelData(
const std::string &camera_label,
const std::string &band_label,
const std::vector<float> &pixel_data);
1840 uint specular_reflection_mode = 0;
1846 bool calibration_flag =
false;
1849 std::string getCurrentDateTime();
1852 std::vector<uint> primitiveID;
1855 std::vector<uint> context_UUIDs;
1859 std::unordered_map<uint, size_t> uuid_to_position;
1863 std::vector<uint> position_to_uuid;
1867 std::map<std::string, RadiationBand> radiation_bands;
1870 std::vector<helios::vec2> global_diffuse_spectrum;
1873 std::string global_diffuse_spectrum_label =
"none";
1876 uint64_t global_diffuse_spectrum_version = 0;
1878 std::map<std::string, bool> scattering_iterations_needed;
1882 std::vector<RadiationSource> radiation_sources;
1887 std::map<std::string, RadiationCamera> cameras;
1890 std::map<std::string, CameraMetadata> camera_metadata;
1893 std::set<std::string> metadata_enabled_cameras;
1896 std::map<std::string, std::vector<uint>> spectral_reflectivity_data;
1899 std::map<std::string, std::vector<uint>> spectral_transmissivity_data;
1902 struct SpectrumInterpolationConfig {
1903 std::unordered_set<uint> primitive_UUIDs;
1904 std::unordered_set<uint> object_IDs;
1905 std::vector<std::string> spectra_labels;
1906 std::vector<float> mapping_values;
1907 std::string query_data_label;
1908 std::string target_data_label;
1911 std::vector<SpectrumInterpolationConfig> spectrum_interpolation_configs;
1913 std::vector<helios::vec2> generateGaussianCameraResponse(
float FWHM,
float mu,
float centrawavelength,
const helios::int2 &wavebandrange);
1918 float sigma = 5.6703744E-8;
1930 float kappa_default;
1933 float sigmas_default;
1936 float temperature_default;
1939 size_t directRayCount_default;
1942 size_t diffuseRayCount_default;
1945 float diffuseFlux_default;
1948 float minScatterEnergy_default;
1951 uint scatteringDepth_default;
1956 void initializeOptiX();
1964 void updateRadiativeProperties();
1983 std::vector<float> updateAtmosphericSkyModel(
const std::vector<std::string> &band_labels,
const RadiationCamera &camera);
1992 void updatePragueParametersForGeneralDiffuse(
const std::vector<std::string> &band_labels);
1999 std::vector<helios::vec2> loadSpectralData(
const std::string &global_data_label)
const;
2004 void buildLightModelGeometry(
uint sourceID);
2006 void buildCameraModelGeometry(
const std::string &cameralabel);
2008 void updateLightModelPosition(
uint sourceID,
const helios::vec3 &delta_position);
2010 void updateCameraModelPosition(
const std::string &cameralabel);
2031 std::vector<CameraTile> computeCameraTiles(
const RadiationCamera &camera,
size_t maxRays);
2038 void buildGeometryData();
2046 void buildTextureData();
2050 void buildUUIDMapping();
2053 void buildMaterialData();
2056 void buildSourceData();
2059 std::map<uint, std::vector<uint>> source_model_UUIDs;
2061 std::map<std::string, std::vector<uint>> camera_model_UUIDs;
2066 std::unique_ptr<helios::RayTracingBackend> backend;
2075 std::vector<helios::RayTracingSource> source_data;
2079 bool isgeometryinitialized;
2084 bool radiativepropertiesneedupdate =
true;
2086 std::vector<bool> isbandpropertyinitialized;
2088 bool islightvisualizationenabled =
false;
2089 bool iscameravisualizationenabled =
false;
2092 std::vector<std::string> output_prim_data;
2094 std::vector<std::string> spectral_library_files;
2097 float integrateOverResponse(
const std::vector<float> &wavelengths,
const std::vector<float> &values,
const std::vector<helios::vec2> &camera_response)
const;
2099 float weightedAverageOverResponse(
const std::vector<float> &wavelengths,
const std::vector<float> ¶m_values,
const std::vector<float> &weight_values,
const std::vector<helios::vec2> &camera_response)
const;
2101 float computeAngularNormalization(
float circ_str,
float circ_width,
float horiz_bright)
const;