Skip to content
Snippets Groups Projects
Commit e4ad5bfe authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Tweaks to reg parameters

parent 2c541e1e
No related branches found
No related tags found
No related merge requests found
Pipeline #11739 passed
......@@ -37,6 +37,7 @@ Correspondances::Correspondances(Correspondances *parent, Source *src)
static void averageDepth(vector<Mat> &in, Mat &out, float varThresh) {
const int rows = in[0].rows;
const int cols = in[0].cols;
float varThresh2 = varThresh*varThresh;
// todo: create new only if out is empty (or wrong shape/type)
out = Mat(rows, cols, CV_32FC1);
......@@ -62,16 +63,16 @@ static void averageDepth(vector<Mat> &in, Mat &out, float varThresh) {
for (int i_in = 0; i_in < in.size(); ++i_in) {
double d = in[i_in].at<float>(i);
if (d < 40.0) {
double delta = (d*1000.0 - sum*1000.0);
double delta = (d - sum);
var += delta*delta;
//LOG(INFO) << "VAR " << delta;
}
}
if (good_values > 1) var /= (double)(good_values-1);
else var = 0.0;
//LOG(INFO) << "VAR " << var;
if (var < varThresh) {
if (var < varThresh2) {
out.at<float>(i) = (float)sum;
} else {
out.at<float>(i) = 41.0f;
......@@ -119,13 +120,14 @@ bool Correspondances::capture(cv::Mat &rgb1, cv::Mat &rgb2) {
targ_->grab();
src_->getFrames(rgb1, d1);
targ_->getFrames(rgb2, d2);
buffer[0][i] = d1;
buffer[1][i] = d2;
d1.copyTo(buffer[0][i]);
d2.copyTo(buffer[1][i]);
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
averageDepth(buffer[0], d1, 0.00000005f);
averageDepth(buffer[1], d2, 0.00000005f);
averageDepth(buffer[0], d1, 0.01f);
averageDepth(buffer[1], d2, 0.01f);
Mat d1_v, d2_v;
d1.convertTo(d1_v, CV_8U, 255.0f / 10.0f);
d2.convertTo(d2_v, CV_8U, 255.0f / 10.0f);
......
......@@ -328,7 +328,7 @@ void ftl::registration::manual(ftl::Configurable *root) {
lastScore = 1000.0;
do {
Eigen::Matrix4d tr;
float s = current->findBestSubset(tr, (int)(current->screenPoints().size() * 0.4f), 100);
float s = current->findBestSubset(tr, 20, 100); // (int)(current->screenPoints().size() * 0.4f)
LOG(INFO) << "SCORE = " << s;
if (s < lastScore) {
lastScore = s;
......@@ -353,7 +353,7 @@ void ftl::registration::manual(ftl::Configurable *root) {
current->capture(f1,f2);
vector<tuple<int,int,int,int>> feat;
if (ftl::registration::featuresSIFT(f1, f2, feat, 2)) {
if (ftl::registration::featuresSIFT(f1, f2, feat, 10)) {
for (int j=0; j<feat.size(); j++) {
auto [sx,sy,tx,ty] = feat[j];
current->add(tx, ty, sx, sy);
......
......@@ -109,7 +109,7 @@ bool ftl::registration::featuresChess(cv::Mat &frame1, cv::Mat &frame2, std::vec
bool ftl::registration::featuresSIFT(cv::Mat &frame1, cv::Mat &frame2, std::vector<std::tuple<int,int,int,int>> &points, int K) {
int minHessian = 400;
Ptr<SIFT> detector = SIFT::create();
Ptr<SIFT> detector = SIFT::create(10000,3,0.04,10);
//detector->setHessianThreshold(minHessian);
vector<vector<KeyPoint>> keypoints;
......@@ -139,7 +139,7 @@ bool ftl::registration::featuresSIFT(cv::Mat &frame1, cv::Mat &frame2, std::vect
std::vector<std::vector< DMatch >> matches;
matcher.knnMatch( descriptors[0], descriptors[1], matches, K );
const float ratio_thresh = 0.7f;
const float ratio_thresh = 0.9f;
std::vector<DMatch> good_matches;
for (size_t i = 0; i < matches.size(); i++)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment