<commit_before>/*
 * (C) 2008-2014 shimat
 * This code is licenced under the LGPL.
 */

#ifndef _CPP_FEATURES2D_H_
#define _CPP_FEATURES2D_H_

#include "include_opencv.h"

#pragma region FeatureDetector

CVAPI(void) features2d_FeatureDetector_detect1(cv::FeatureDetector *detector, cv::Mat *image, std::vector<cv::KeyPoint> *keypoints, cv::Mat *mask)
{
	detector->detect(*image, *keypoints, entity(mask));
}

CVAPI(void) features2d_FeatureDetector_detect2(cv::FeatureDetector *detector, cv::Mat **images, int imageLength, std::vector<std::vector<cv::KeyPoint> > *keypoints, cv::Mat **mask)
{
	std::vector<cv::Mat> imageVec(imageLength);
	std::vector<cv::Mat> maskVec;
	{
		for (int i = 0; i < imageLength; i++)
			imageVec.push_back(*images[i]);		
	}
	if (mask != NULL)
	{
		maskVec.reserve(imageLength);
		for (int i = 0; i < imageLength; i++)
			maskVec.push_back(*mask[i]);
	}

	detector->detect(imageVec, *keypoints, maskVec);
}

CVAPI(int) features2d_FeatureDetector_empty(cv::FeatureDetector *detector)
{
	return detector->empty();
}

CVAPI(cv::Ptr<cv::FeatureDetector>*) features2d_FeatureDetector_create(const char *detectorType)
{
	cv::Ptr<cv::FeatureDetector> ret = cv::FeatureDetector::create(detectorType);
	return new cv::Ptr<cv::FeatureDetector>(ret);
}

#pragma endregion

#pragma region Feature2D
CVAPI(void) features2d_Feature2D_compute(cv::Feature2D *obj,
	cv::Mat *image, std::vector<cv::KeyPoint> *keypoints, cv::Mat *descriptors)
{
	obj->compute(*image, *keypoints, *descriptors);
}

CVAPI(cv::Ptr<cv::Feature2D>*) features2d_Feature2D_create(const char *name)
{
	cv::Ptr<cv::Feature2D> ret = cv::Feature2D::create(name);
	return new cv::Ptr<cv::Feature2D>(ret);
}
#pragma endregion

#pragma region MSER
CVAPI(cv::MSER*) features2d_MSER_new(int delta, int min_area, int max_area,
          double max_variation, double min_diversity, int max_evolution, 
		  double area_threshold, double min_margin, int edge_blur_size )
{
	return new cv::MSER(delta, min_area, max_area);
}
CVAPI(void) features2d_MSER_delete(cv::MSER *obj)
{
	delete obj;
}
CVAPI(void) features2d_MSER_detect(cv::MSER *obj, cv::Mat *image, 
								   std::vector<std::vector<cv::Point> > **msers, cv::Mat *mask )
{
	*msers = new std::vector<std::vector<cv::Point> >;
	(*obj)(*image, **msers, entity(mask));
}
CVAPI(cv::AlgorithmInfo*) features2d_MSER_info(cv::MSER *obj)<commit_msg>Added BRISK<commit_after>/*
 * (C) 2008-2014 shimat
 * This code is licenced under the LGPL.
 */

#ifndef _CPP_FEATURES2D_H_
#define _CPP_FEATURES2D_H_

#include "include_opencv.h"

#pragma region FeatureDetector

CVAPI(void) features2d_FeatureDetector_detect1(cv::FeatureDetector *detector, cv::Mat *image, std::vector<cv::KeyPoint> *keypoints, cv::Mat *mask)
{
	detector->detect(*image, *keypoints, entity(mask));
}

CVAPI(void) features2d_FeatureDetector_detect2(cv::FeatureDetector *detector, cv::Mat **images, int imageLength, std::vector<std::vector<cv::KeyPoint> > *keypoints, cv::Mat **mask)
{
	std::vector<cv::Mat> imageVec(imageLength);
	std::vector<cv::Mat> maskVec;
	{
		for (int i = 0; i < imageLength; i++)
			imageVec.push_back(*images[i]);		
	}
	if (mask != NULL)
	{
		maskVec.reserve(imageLength);
		for (int i = 0; i < imageLength; i++)
			maskVec.push_back(*mask[i]);
	}

	detector->detect(imageVec, *keypoints, maskVec);
}

CVAPI(int) features2d_FeatureDetector_empty(cv::FeatureDetector *detector)
{
	return detector->empty();
}

CVAPI(cv::Ptr<cv::FeatureDetector>*) features2d_FeatureDetector_create(const char *detectorType)
{
	cv::Ptr<cv::FeatureDetector> ret = cv::FeatureDetector::create(detectorType);
	return new cv::Ptr<cv::FeatureDetector>(ret);
}

#pragma endregion

#pragma region Feature2D
CVAPI(void) features2d_Feature2D_compute(cv::Feature2D *obj,
	cv::Mat *image, std::vector<cv::KeyPoint> *keypoints, cv::Mat *descriptors)
{
	obj->compute(*image, *keypoints, *descriptors);
}

CVAPI(cv::Ptr<cv::Feature2D>*) features2d_Feature2D_create(const char *name)
{
	cv::Ptr<cv::Feature2D> ret = cv::Feature2D::create(name);
	return new cv::Ptr<cv::Feature2D>(ret);
}
#pragma endregion

#pragma region BRISK

CVAPI(cv::BRISK*) features2d_BRISK_new(int thresh, int octaves, float patternScale)
{
	return new cv::BRISK(thresh, octaves, patternScale);
}
CVAPI(void) features2d_BRISK_delete(cv::BRISK *obj)
{
	delete obj;
}

CVAPI(int) features2d_BRISK_descriptorSize(cv::BRISK *obj)
{
	return obj->descriptorSize();
}
CVAPI(int) features2d_BRISK_descriptorType(cv::BRISK *obj)
{
	return obj->descriptorType();
}

CVAPI(void) features2d_BRISK_run1(cv::BRISK *obj, cv::_InputArray *image, cv::_InputArray *mask, 
	std::vector<cv::KeyPoint> *keypoints)
{
	(*obj)(*image, entity(mask), *keypoints);
}

CVAPI(void) features2d_BRISK_run2(cv::BRISK *obj, cv::_InputArray *image, cv::_InputArray *mask, 
	std::vector<cv::KeyPoint> *keypoints, cv::_OutputArray *descriptors, int useProvidedKeypoints)
{
	(*obj)(*image, entity(mask), *keypoints, *descriptors, useProvidedKeypoints != 0);
}

CVAPI(cv::AlgorithmInfo*) features2d_BRISK_info(cv::BRISK *obj)
{
	return obj->info();
}

/*
	// custom setup
	CV_WRAP explicit BRISK(std::vector<float> &radiusList, std::vector<int> &numberList,
		float dMax = 5.85f, float dMin = 8.2f, std::vector<int> indexChange = std::vector<int>());

	// call this to generate the kernel:
	// circle of radius r (pixels), with n points;
	// short pairings with dMax, long pairings with dMin
	CV_WRAP void generateKernel(std::vector<float> &radiusList,
		std::vector<int> &numberList, float dMax = 5.85f, float dMin = 8.2f,
		std::vector<int> indexChange = std::vector<int>());
*/
#pragma endregion

#pragma region MSER
CVAPI(cv::MSER*) features2d_MSER_new(int delta, int minArea, int maxArea,
          double maxVariation, double minDiversity, int maxEvolution, 
		  double areaThreshold, double minMargin, int edgeBlurSize )
{
	return new cv::MSER(delta, minArea, maxArea, maxVariation, minDiversity, maxEvolution, 
		areaThreshold, minMargin, edgeBlurSize);
}
CVAPI(void) features2d_MSER_delete(cv::MSER *obj)
{
	delete obj;
}
CVAPI(void) features2d_MSER_detect(cv::MSER *obj, cv::Mat *image, 
								   std::vector<std::vector<cv::Point> > **msers, cv::Mat *mask )
{
	*msers = new std::vector<std::vector<cv::Point> >;
	(*obj)(*image, **msers, entity(mask));
}
CVAPI(cv::AlgorithmInfo*) features2d_MSER_info(cv::MSER *obj)
{'fraction_non_alphanumeric': 0.15907299385148982, 'fraction_numerical': 0.013242944978716696, 'mean_word_length': 7.071246819338422, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 56, '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': '346227', 'n_tokens_mistral': 2487, 'n_tokens_neox': 2392, 'n_words': 456}