<commit_before>#include "opencv2/opencv.hpp"
#include "opencv2/features2d.hpp"
using namespace cv;

#include "Pipeline.hpp"
#include "util.hpp"

Logger _log("Step 2 (match)");

void Pipeline::find_matching_pairs(
	const Images&         images,
	const CamFrames&      camframes,
	const DescriptorsVec& descriptors_vec,
	      ImagePairs&     pairs
)
{
	const int N = descriptors_vec.size();

	// Initialise descriptors matcher
	FlannBasedMatcher flann;

	// Get matches
	std::vector<DMatch> matches;
	Descriptors descriptors_i;
	Descriptors descriptors_j;

	// Match between all image pairs possible
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			// Get descriptors from image i and image j
			descriptors_i = descriptors_vec[i];
			descriptors_j = descriptors_vec[j];

			// Must convert types to pass on to FLANN matcher
			descriptors_i.convertTo(descriptors_i, CV_32F);
			descriptors_j.convertTo(descriptors_j, CV_32F);

			// Match descriptors
			// Output is distance between descriptors
			flann.match(descriptors_i, descriptors_j, matches);
			//_log("Input: (%d: %d rows, %d: %d rows)\t Output: %d rows",
			//	i, descriptors_i.rows,
			//	j, descriptors_j.rows,
			//	matches.size());

			// Our parameters
			float max_dist    = 400;
			int   min_matches = 5;

			// Only pick good matches
			std::vector<DMatch> good_matches;
			for (int m = 0; m < matches.size(); m++)
				if (matches[m].distance <= max_dist)
					good_matches.push_back(matches[m]);

			if (good_matches.size() < min_matches) continue;

			// Add to pairs structure
			pairs.push_back((ImagePair) {
				KeyPointsPair(
					camframes[i].key_points,
					camframes[j].key_points
				)
			});

			// Draw matches
			// NOTE: remove continue; to see images
			//continue;
			Mat out;
			drawMatches(images[i].gray, camframes[i].key_points,
			            images[j].gray, camframes[j].key_points,
				    good_matches, out);
			char title[64];
			sprintf(title, "Match %d-%d", i, j);
			showImage(title, out);

		}
	}


	waitKey(0);
}
<commit_msg>Show RGB images for matches<commit_after>#include "opencv2/opencv.hpp"
#include "opencv2/features2d.hpp"
using namespace cv;

#include "Pipeline.hpp"
#include "util.hpp"

Logger _log("Step 2 (match)");

void Pipeline::find_matching_pairs(
	const Images&         images,
	const CamFrames&      camframes,
	const DescriptorsVec& descriptors_vec,
	      ImagePairs&     pairs
)
{
	const int N = descriptors_vec.size();

	// Initialise descriptors matcher
	FlannBasedMatcher flann;

	// Get matches
	std::vector<DMatch> matches;
	Descriptors descriptors_i;
	Descriptors descriptors_j;

	// Match between all image pairs possible
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			// Get descriptors from image i and image j
			descriptors_i = descriptors_vec[i];
			descriptors_j = descriptors_vec[j];

			// Must convert types to pass on to FLANN matcher
			descriptors_i.convertTo(descriptors_i, CV_32F);
			descriptors_j.convertTo(descriptors_j, CV_32F);

			// Match descriptors
			// Output is distance between descriptors
			flann.match(descriptors_i, descriptors_j, matches);
			//_log("Input: (%d: %d rows, %d: %d rows)\t Output: %d rows",
			//	i, descriptors_i.rows,
			//	j, descriptors_j.rows,
			//	matches.size());

			// Our parameters
			float max_dist    = 400;
			int   min_matches = 5;

			// Only pick good matches
			std::vector<DMatch> good_matches;
			for (int m = 0; m < matches.size(); m++)
				if (matches[m].distance <= max_dist)
					good_matches.push_back(matches[m]);

			if (good_matches.size() < min_matches) continue;

			// Add to pairs structure
			pairs.push_back((ImagePair) {
				KeyPointsPair(
					camframes[i].key_points,
					camframes[j].key_points
				)
			});

			// Draw matches
			// NOTE: remove continue; to see images
			//continue;
			Mat out;
			drawMatches(images[i].rgb, camframes[i].key_points,
			            images[j].rgb, camframes[j].key_points,
				    good_matches, out);
			char title[64];
			sprintf(title, "Match %d-%d", i, j);
			showImageAndWait("Match results", out);

		}
	}

}

{'fraction_non_alphanumeric': 0.12813031850230974, 'fraction_numerical': 0.008509603695599319, 'mean_word_length': 3.202247191011236, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4125904', 'n_tokens_mistral': 1661, 'n_tokens_neox': 1419, 'n_words': 364}