Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions src/mrcal_jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ constexpr std::string jni_make_method_sig(std::string_view retval,
return result;
}

/**
* Converts decimation levels to point weights using `weight=0.5^level`.
* Negative weights correspond to ignored points.
*
* @param observations Input as [x, y, level], output as [x, y, weight]
*/
static void levels_to_weights(std::span<mrcal_point3_t> observations) {
for (auto &o : observations) {
double &level = o.z;
if (level < 0) {
o.z = -1;
} else {
o.z = std::pow(0.5, level);
}
}
}

/**
* Finds a class and keeps it as a global reference.
*
Expand Down Expand Up @@ -206,15 +223,7 @@ Java_org_photonvision_mrcal_MrCalJNI_mrcal_1calibrate_1camera
total_frames_rt_toref.push_back(seed_pose);
}

// Convert detection level to weights
for (auto &o : observations) {
double &level = o.z;
if (level < 0) {
o.z = -1;
} else {
o.z = std::pow(0.5, level);
}
}
levels_to_weights(observations);

auto statsptr = mrcal_main(observations, total_frames_rt_toref, boardSize,
static_cast<double>(boardSpacing), imagerSize,
Expand Down Expand Up @@ -355,6 +364,8 @@ Java_org_photonvision_mrcal_MrCalJNI_compute_1uncertainty
cv::Size calobjectSize(boardWidth, boardHeight);
cv::Size sampleRes(sampleGridWidth, sampleGridHeight);

levels_to_weights(observations.asSpan<mrcal_point3_t>());

std::vector<mrcal_point3_t> result;
try {
result = compute_uncertainty(
Expand Down
Loading