isValidLabel
와 updateLikelihoods
메서드 가 중요computeLabel
함수computeLabel
함수에서 처리됩니다.bool ProjectiveIntegrator::computeLabel(const InputData& data,
const float truncation_distance,
VoxelMeasurement& measurement) const {
const bool is_surface = measurement.sdf < truncation_distance;
if (data.label_image.empty() || !semantic_integrator_ || !is_surface) {
return true;
}
measurement.label =
interpolator_->interpolateID(data.label_image, measurement.interpolation_weights);
return semantic_integrator_->canIntegrate(measurement.label);
}
is_surface
: 현재 볼셀이 표면 근처에 있는지 확인하는 조건입니다. 표면 근처에 있지 않은 경우 세멘틱 정보를 통합하지 않습니다.
data.label_image
: RGB 이미지에 대한 세멘틱 분할 결과가 label_image
로 주어집니다. 이 이미지에서 픽셀별로 레이블이 할당됩니다 (예: 건물, 나무, 사람 등).
interpolator_->interpolateID
:
semantic_integrator_->canIntegrate(measurement.label)
: updateVoxel
함수updateVoxel
함수에 있습니다. void ProjectiveIntegrator::updateVoxel(const InputData& data,
const VoxelMeasurement& measurement,
const float truncation_distance,
VoxelTuple& voxels) const {
// ...
// Only merge other quantities near the surface
if (measurement.sdf >= truncation_distance) {
return;
}
// 세멘틱 정보 통합
if (!semantic_integrator_ || !voxels.semantic) {
return;
}
if (semantic_integrator_->isValidLabel(measurement.label)) {
semantic_integrator_->updateLikelihoods(measurement.label, *voxels.semantic);
}
}
semantic_integrator_->updateLikelihoods
: isValidLabel()
함수는 레이블이 유효한지 확인하고, canIntegrate()
함수는 해당 레이블이 동적(dynamic) 레이블이나 무효한(invalid) 레이블인지 여부를 확인합니다.MLESemanticIntegrator
클래스에서 이루어집니다. 특히, updateLikelihoods
함수가 세멘틱 통합의 핵심입니다.void MLESemanticIntegrator::updateLikelihoods(uint32_t label,
SemanticVoxel& voxel) const {
if (voxel.empty) {
voxel.empty = false;
voxel.semantic_likelihoods.setConstant(total_labels_, init_likelihood_);
}
voxel.semantic_likelihoods += observation_likelihoods_.col(label);
voxel.semantic_likelihoods.maxCoeff(&voxel.semantic_label);
}
observation_likelihoods_
)의 값을 더해줍니다. observation_likelihoods_
은 각 레이블에 대한 일치 확률과 불일치 확률을 포함하고 있으며, voxel.semantic_likelihoods
벡터에 추가적인 정보를 계속해서 더하는 방식voxel.semantic_likelihoods.maxCoeff(&voxel.semantic_label)
는 가장 큰 우도 값을 갖는 레이블을 찾아 voxel.semantic_label
에 저장voxel.semantic_likelihoods
초기화: setConstant
함수를 통해 모든 라벨의 초기 확률을 균일하게 설정init_likelihood_ = log(1 / total_labels_)
semantic_likelihoods
에 해당 레이블의 우도를 더해줍니다. observation_likelihoods_
행렬의 해당 라벨에 해당하는 값을 더해주는 방식으로 업데이트됩니다.maxCoeff
함수를 사용하여 가장 높은 우도를 가진 라벨을 해당 볼셀의 최종 세멘틱 라벨로 결정합니다.