mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
remove some unsupported codes
This commit is contained in:
parent
4b671d74ca
commit
3a08bc621e
19 changed files with 5 additions and 668 deletions
13
Manifest.txt
13
Manifest.txt
|
@ -34,12 +34,6 @@ examples/images/tiffany.jpg
|
|||
examples/inpaint.rb
|
||||
examples/match_kdtree.rb
|
||||
examples/match_template.rb
|
||||
examples/matching_to_many_images/matching_to_many_images.rb
|
||||
examples/matching_to_many_images/query.png
|
||||
examples/matching_to_many_images/train/1.png
|
||||
examples/matching_to_many_images/train/2.png
|
||||
examples/matching_to_many_images/train/3.png
|
||||
examples/matching_to_many_images/train/trainImages.txt
|
||||
examples/paint.rb
|
||||
examples/snake.rb
|
||||
ext/opencv/algorithm.cpp
|
||||
|
@ -56,8 +50,6 @@ ext/opencv/cvchain.cpp
|
|||
ext/opencv/cvchain.h
|
||||
ext/opencv/cvcircle32f.cpp
|
||||
ext/opencv/cvcircle32f.h
|
||||
ext/opencv/cvcondensation.cpp
|
||||
ext/opencv/cvcondensation.h
|
||||
ext/opencv/cvconnectedcomp.cpp
|
||||
ext/opencv/cvconnectedcomp.h
|
||||
ext/opencv/cvcontour.cpp
|
||||
|
@ -82,8 +74,6 @@ ext/opencv/cvline.cpp
|
|||
ext/opencv/cvline.h
|
||||
ext/opencv/cvmat.cpp
|
||||
ext/opencv/cvmat.h
|
||||
ext/opencv/cvmatnd.cpp
|
||||
ext/opencv/cvmatnd.h
|
||||
ext/opencv/cvmemstorage.cpp
|
||||
ext/opencv/cvmemstorage.h
|
||||
ext/opencv/cvmoments.cpp
|
||||
|
@ -106,8 +96,6 @@ ext/opencv/cvsize2d32f.cpp
|
|||
ext/opencv/cvsize2d32f.h
|
||||
ext/opencv/cvslice.cpp
|
||||
ext/opencv/cvslice.h
|
||||
ext/opencv/cvsparsemat.cpp
|
||||
ext/opencv/cvsparsemat.h
|
||||
ext/opencv/cvsurfparams.cpp
|
||||
ext/opencv/cvsurfparams.h
|
||||
ext/opencv/cvsurfpoint.cpp
|
||||
|
@ -221,7 +209,6 @@ test/test_cvmat.rb
|
|||
test/test_cvmat_drawing.rb
|
||||
test/test_cvmat_dxt.rb
|
||||
test/test_cvmat_imageprocessing.rb
|
||||
test/test_cvmat_matching.rb
|
||||
test/test_cvmoments.rb
|
||||
test/test_cvpoint.rb
|
||||
test/test_cvpoint2d32f.rb
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
require 'opencv'
|
||||
require 'benchmark'
|
||||
include OpenCV
|
||||
|
||||
data = File.dirname(__FILE__)
|
||||
|
||||
query = CvMat.load File.join(data, 'query.png'), CV_LOAD_IMAGE_GRAYSCALE
|
||||
image_files = ['1.png', '2.png', '3.png'].map{|f| File.join(data, 'train', f)}
|
||||
images = image_files.map{|f| CvMat.load f, CV_LOAD_IMAGE_GRAYSCALE}
|
||||
|
||||
|
||||
matchs = query.match_descriptors(images)
|
||||
|
||||
match_index, count = matchs.max_by {|image_index, count| count}
|
||||
|
||||
puts "max match: #{image_files[match_index]}"
|
Binary file not shown.
Before Width: | Height: | Size: 119 KiB |
Binary file not shown.
Before Width: | Height: | Size: 116 KiB |
Binary file not shown.
Before Width: | Height: | Size: 112 KiB |
Binary file not shown.
Before Width: | Height: | Size: 118 KiB |
|
@ -1,3 +0,0 @@
|
|||
1.png
|
||||
2.png
|
||||
3.png
|
|
@ -1,282 +0,0 @@
|
|||
/************************************************************
|
||||
|
||||
cvcondensation.cpp -
|
||||
|
||||
$Author: lsxi $
|
||||
|
||||
Copyright (C) 2005-2006 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#include "cvcondensation.h"
|
||||
/*
|
||||
* Document-class: OpenCV::CvConDensation
|
||||
*
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVCONDENSATION
|
||||
|
||||
VALUE rb_klass;
|
||||
|
||||
VALUE
|
||||
rb_class()
|
||||
{
|
||||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv();
|
||||
rb_klass = rb_define_class_under(opencv, "CvConDensation", rb_cObject);
|
||||
rb_define_method(rb_klass, "dp", RUBY_METHOD_FUNC(rb_dp), 0);
|
||||
rb_define_method(rb_klass, "mp", RUBY_METHOD_FUNC(rb_mp), 0);
|
||||
rb_define_method(rb_klass, "dynamic_matrix", RUBY_METHOD_FUNC(rb_dynamic_matrix), 0);
|
||||
rb_define_method(rb_klass, "confidence", RUBY_METHOD_FUNC(rb_confidence), 0);
|
||||
rb_define_method(rb_klass, "cumulative", RUBY_METHOD_FUNC(rb_cumulative), 0);
|
||||
rb_define_method(rb_klass, "state", RUBY_METHOD_FUNC(rb_state), 0);
|
||||
rb_define_method(rb_klass, "samples_num", RUBY_METHOD_FUNC(rb_samples_num), 0);
|
||||
rb_define_method(rb_klass, "init_sample_set", RUBY_METHOD_FUNC(rb_init_sample_set), 2);
|
||||
rb_define_method(rb_klass, "update_by_time", RUBY_METHOD_FUNC(rb_update_by_time), 0);
|
||||
rb_define_alias(rb_klass, "update", "update_by_time");
|
||||
rb_define_method(rb_klass, "each_sample", RUBY_METHOD_FUNC(rb_each_sample), 0);
|
||||
rb_define_method(rb_klass, "calculate_confidence", RUBY_METHOD_FUNC(rb_calculate_confidence), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* dp -> int
|
||||
*
|
||||
* Return dimension of state vector
|
||||
*/
|
||||
VALUE
|
||||
rb_dp(VALUE self)
|
||||
{
|
||||
return INT2NUM(CVCONDENSATION(self)->DP);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* mp -> int
|
||||
*
|
||||
* Return demension of measurement vector.
|
||||
*/
|
||||
VALUE
|
||||
rb_mp(VALUE self)
|
||||
{
|
||||
return INT2NUM(CVCONDENSATION(self)->MP);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* dynamic_matrix -> mat
|
||||
*
|
||||
* Return matrix of the linear Dynamics system.
|
||||
*/
|
||||
VALUE
|
||||
rb_dynamic_matrix(VALUE self)
|
||||
{
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
CvMat* mat = NULL;
|
||||
try {
|
||||
mat = cvInitMatHeader(ALLOC(CvMat), cd->DP, cd->DP, CV_MAKETYPE(CV_32F, 1), cd->DynamMatr);
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
return DEPEND_OBJECT(cCvMat::rb_class(), mat, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* confidence -> mat
|
||||
*
|
||||
* Return confidence for each sample.
|
||||
*/
|
||||
VALUE
|
||||
rb_confidence(VALUE self)
|
||||
{
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
CvMat* mat = NULL;
|
||||
try {
|
||||
mat = cvInitMatHeader(ALLOC(CvMat), cd->SamplesNum, 1, CV_MAKETYPE(CV_32F, 1), cd->flConfidence);
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
return DEPEND_OBJECT(cCvMat::rb_class(), mat, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* cumulative -> mat
|
||||
*
|
||||
* Return cumulative confidence.
|
||||
*/
|
||||
VALUE
|
||||
rb_cumulative(VALUE self)
|
||||
{
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
CvMat* mat = NULL;
|
||||
try {
|
||||
mat = cvInitMatHeader(ALLOC(CvMat), cd->SamplesNum, 1, CV_MAKETYPE(CV_32F, 1), cd->flCumulative);
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
return DEPEND_OBJECT(cCvMat::rb_class(), mat, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* state -> mat
|
||||
*
|
||||
* Return vector of state
|
||||
*/
|
||||
VALUE
|
||||
rb_state(VALUE self)
|
||||
{
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
CvMat* mat = NULL;
|
||||
try {
|
||||
mat = cvInitMatHeader(ALLOC(CvMat), cd->DP, 1, CV_MAKETYPE(CV_32F, 1), cd->State);
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
return DEPEND_OBJECT(cCvMat::rb_class(), mat, self);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* samples_num -> int
|
||||
*
|
||||
* Return number of the samples
|
||||
*/
|
||||
VALUE
|
||||
rb_samples_num(VALUE self)
|
||||
{
|
||||
return INT2NUM(CVCONDENSATION(self)->SamplesNum);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* init_sample_set(upper, lower)
|
||||
*
|
||||
* Initializes sample set for ConDensation algorithm.
|
||||
* Fills the samples with values within specified(lower to upper) ranges.
|
||||
*/
|
||||
VALUE
|
||||
rb_init_sample_set(VALUE self, VALUE lower, VALUE upper)
|
||||
{
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
CvMat *lower_bound = CVMAT_WITH_CHECK(lower), *upper_bound = CVMAT_WITH_CHECK(upper), lb_stub, ub_stub;
|
||||
int lower_type = lower_bound->type, upper_type = lower_bound->type;
|
||||
try {
|
||||
if (lower_type != CV_32FC1 || lower_bound->cols != 1) {
|
||||
if (CV_MAT_DEPTH(lower_type) == CV_32F) {
|
||||
lower_bound = cvReshape(lower_bound, &lb_stub, 1, lower_bound->rows * lower_bound->cols);
|
||||
}
|
||||
else {
|
||||
lower = cCvMat::new_object(cvSize(lower_bound->rows * lower_bound->cols, 1), CV_MAKETYPE(CV_32S, 1));
|
||||
cvConvertScale(lower_bound, CVARR(lower));
|
||||
lower_bound = CVMAT(lower);
|
||||
}
|
||||
}
|
||||
if (upper_type != CV_32FC1 || upper_bound->cols != 1) {
|
||||
if (CV_MAT_DEPTH(upper_type) == CV_32F) {
|
||||
upper_bound = cvReshape(upper_bound, &ub_stub, 1, upper_bound->rows * upper_bound->cols);
|
||||
}
|
||||
else {
|
||||
upper = cCvMat::new_object(cvSize(upper_bound->rows * upper_bound->cols, 1), CV_MAKETYPE(CV_32F, 1));
|
||||
cvConvertScale(upper_bound, CVARR(upper));
|
||||
upper_bound = CVMAT(upper);
|
||||
}
|
||||
}
|
||||
if (lower_bound->rows != cd->DP || upper_bound->rows != cd->DP) {
|
||||
rb_raise(rb_eTypeError, "sample matrix step unmatch.");
|
||||
}
|
||||
cvConDensInitSampleSet(cd, lower_bound, upper_bound);
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* update_by_time
|
||||
*
|
||||
* Estimates subsequent model state.
|
||||
*/
|
||||
VALUE
|
||||
rb_update_by_time(VALUE self)
|
||||
{
|
||||
try {
|
||||
cvConDensUpdateByTime(CVCONDENSATION(self));
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* each_sample {|mat| ... }
|
||||
*
|
||||
* Evaluate each sample by given block.
|
||||
*/
|
||||
VALUE
|
||||
rb_each_sample(VALUE self)
|
||||
{
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
if (rb_block_given_p()) {
|
||||
try {
|
||||
for (int i = 0; i < cd->SamplesNum; ++i) {
|
||||
CvMat* mat = cvInitMatHeader(ALLOC(CvMat), cd->DP, 1, CV_MAKETYPE(CV_32F, 1), cd->flSamples[i]);
|
||||
rb_yield(DEPEND_OBJECT(cCvMat::rb_class(), mat, self));
|
||||
}
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* calculate_confidence {|value| ... }
|
||||
*
|
||||
* Evalute each sample by given block, then return value set to confidence.
|
||||
*/
|
||||
VALUE
|
||||
rb_calculate_confidence(VALUE self)
|
||||
{
|
||||
VALUE value;
|
||||
CvConDensation *cd = CVCONDENSATION(self);
|
||||
if (rb_block_given_p()) {
|
||||
try {
|
||||
for (int i = 0; i < cd->SamplesNum; ++i) {
|
||||
CvMat* mat = cvInitMatHeader(ALLOC(CvMat), cd->DP, 1, CV_MAKETYPE(CV_32F, 1), cd->flSamples[i]);
|
||||
value = rb_yield(DEPEND_OBJECT(cCvMat::rb_class(), mat, self));
|
||||
cd->flConfidence[i] = NUM2DBL(value);
|
||||
}
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVCONDENSATION
|
||||
__NAMESPACE_END_OPENCV
|
|
@ -1,49 +0,0 @@
|
|||
/************************************************************
|
||||
|
||||
cvcondensation.h -
|
||||
|
||||
$Author: lsxi $
|
||||
|
||||
Copyright (C) 2005-2006 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#ifndef RUBY_OPENCV_CVCONDENSATION_H
|
||||
#define RUBY_OPENCV_CVCONDENSATION_H
|
||||
|
||||
#include "opencv.h"
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVCONDENSATION namespace cCvConDensation {
|
||||
#define __NAMESPACE_END_CVCONDENSATION }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVCONDENSATION
|
||||
|
||||
VALUE rb_class();
|
||||
void init_ruby_class();
|
||||
|
||||
VALUE rb_dp(VALUE self);
|
||||
VALUE rb_mp(VALUE self);
|
||||
VALUE rb_dynamic_matrix(VALUE self);
|
||||
VALUE rb_state(VALUE self);
|
||||
VALUE rb_confidence(VALUE self);
|
||||
VALUE rb_cumulative(VALUE self);
|
||||
VALUE rb_samples_num(VALUE self);
|
||||
|
||||
VALUE rb_init_sample_set(VALUE self, VALUE lower, VALUE upper);
|
||||
VALUE rb_update_by_time(VALUE self);
|
||||
VALUE rb_each_sample(VALUE self);
|
||||
VALUE rb_calculate_confidence(VALUE self);
|
||||
|
||||
__NAMESPACE_END_CVCONDENSATION
|
||||
|
||||
inline CvConDensation*
|
||||
CVCONDENSATION(VALUE object)
|
||||
{
|
||||
CvConDensation *ptr;
|
||||
Data_Get_Struct(object, CvConDensation, ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
#endif // RUBY_OPENCV_CVCONDENSATION_H
|
|
@ -5224,96 +5224,6 @@ rb_match_shapes(int argc, VALUE *argv, VALUE self)
|
|||
return rb_float_new(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Port from OpenCV sample: matching_to_many_images.cpp
|
||||
* call-seq:
|
||||
* match_descriptors(images[, detector_type="SURF"][, descriptor_type="SURF"][, matcher_type="FlannBased"]) -> Hash
|
||||
*
|
||||
* Matching descriptors detected on one image to descriptors detected in image array.
|
||||
* Returns a Hash contains match count of each image index.
|
||||
* For example, a Hash {0 => 5, 2 => 10} means the images[0] has 5 key points matched, images[2] has 10 key points matched,
|
||||
* and all of other images in the images array have no key point matched.
|
||||
* Hence images[2] is the best match in general.
|
||||
*
|
||||
* <i>images</i> is an array of CvMat objects.
|
||||
* <i>detector_type</i> is a string, default is "SURF", options: "SURF", "FAST", "SIFT", "STAR"
|
||||
* <i>descriptor_type</i> is a string, default is "SURF", options: "SURF", "SIFT", "BRIEF"
|
||||
* <i>matcher_type</i> is a string, default is "FlannBased", options: "FlannBased", "BruteForce"
|
||||
*/
|
||||
VALUE
|
||||
rb_match_descriptors(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE images, detector_type, descriptor_type, matcher_type;
|
||||
rb_scan_args(argc, argv, "13", &images, &detector_type, &descriptor_type, &matcher_type);
|
||||
if (RARRAY_LEN(images) == 0) {
|
||||
return rb_hash_new();
|
||||
}
|
||||
if (NIL_P(detector_type)) {
|
||||
detector_type = rb_str_new2("SURF");
|
||||
}
|
||||
if (NIL_P(descriptor_type)) {
|
||||
descriptor_type = rb_str_new2("SURF");
|
||||
}
|
||||
if (NIL_P(matcher_type)) {
|
||||
matcher_type = rb_str_new2("FlannBased");
|
||||
}
|
||||
|
||||
VALUE _matches = rb_hash_new();
|
||||
try {
|
||||
cv::Mat queryImage(CVMAT(self));
|
||||
std::vector<cv::Mat> trainImages;
|
||||
for(int i = 0, n = RARRAY_LEN(images); i < n; i++) {
|
||||
trainImages.push_back(CVMAT_WITH_CHECK(RARRAY_PTR(images)[i]));
|
||||
}
|
||||
|
||||
cv::Ptr<cv::FeatureDetector> featureDetector = cv::FeatureDetector::create(StringValueCStr(detector_type));
|
||||
if (featureDetector.empty()) {
|
||||
rb_raise(rb_eArgError, "Could not create feature detector by given detector type: %s", StringValueCStr(detector_type));
|
||||
}
|
||||
cv::Ptr<cv::DescriptorExtractor> descriptorExtractor = cv::DescriptorExtractor::create(StringValueCStr(descriptor_type));
|
||||
if (descriptorExtractor.empty()) {
|
||||
rb_raise(rb_eArgError, "Could not create descriptor extractor by given descriptor type: %s", StringValueCStr(descriptor_type));
|
||||
}
|
||||
cv::Ptr<cv::DescriptorMatcher> descriptorMatcher;
|
||||
try {
|
||||
descriptorMatcher = cv::DescriptorMatcher::create(StringValueCStr(matcher_type));
|
||||
}
|
||||
catch(cv::Exception& e) {
|
||||
rb_raise(rb_eArgError, "Could not create descriptor matcher by given matcher type: %s", StringValueCStr(matcher_type));
|
||||
}
|
||||
|
||||
std::vector<cv::KeyPoint> queryKeypoints;
|
||||
std::vector<std::vector<cv::KeyPoint> > trainKeypoints;
|
||||
featureDetector->detect(queryImage, queryKeypoints);
|
||||
featureDetector->detect(trainImages, trainKeypoints);
|
||||
cv::Mat queryDescriptors;
|
||||
std::vector<cv::Mat> trainDescriptors;
|
||||
descriptorExtractor->compute(queryImage, queryKeypoints, queryDescriptors);
|
||||
descriptorExtractor->compute(trainImages, trainKeypoints, trainDescriptors);
|
||||
std::vector<cv::DMatch> matches;
|
||||
descriptorMatcher->add(trainDescriptors);
|
||||
descriptorMatcher->train();
|
||||
descriptorMatcher->match(queryDescriptors, matches);
|
||||
|
||||
for (size_t i = 0, n = matches.size(); i < n; i++) {
|
||||
VALUE match = INT2FIX(matches[i].imgIdx);
|
||||
VALUE count = rb_hash_lookup(_matches, match);
|
||||
if (NIL_P(count)) {
|
||||
count = INT2FIX(1);
|
||||
} else {
|
||||
count = INT2FIX(FIX2INT(count) + 1);
|
||||
}
|
||||
rb_hash_aset(_matches, match, count);
|
||||
}
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
}
|
||||
|
||||
return _matches;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* mean_shift(window, criteria) -> comp
|
||||
|
@ -6099,7 +6009,6 @@ init_ruby_class()
|
|||
rb_define_method(rb_klass, "apply_color_map", RUBY_METHOD_FUNC(rb_apply_color_map), 1);
|
||||
rb_define_method(rb_klass, "match_template", RUBY_METHOD_FUNC(rb_match_template), -1);
|
||||
rb_define_method(rb_klass, "match_shapes", RUBY_METHOD_FUNC(rb_match_shapes), -1);
|
||||
rb_define_method(rb_klass, "match_descriptors", RUBY_METHOD_FUNC(rb_match_descriptors), -1);
|
||||
|
||||
rb_define_method(rb_klass, "mean_shift", RUBY_METHOD_FUNC(rb_mean_shift), 2);
|
||||
rb_define_method(rb_klass, "cam_shift", RUBY_METHOD_FUNC(rb_cam_shift), 2);
|
||||
|
|
|
@ -221,7 +221,6 @@ VALUE rb_apply_color_map(VALUE self, VALUE colormap);
|
|||
/* Matching*/
|
||||
VALUE rb_match_template(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_match_shapes(int argc, VALUE *argv, VALUE self);
|
||||
VALUE rb_match_descriptors(int argc, VALUE *argv, VALUE self);
|
||||
|
||||
/* Object Tracking */
|
||||
VALUE rb_mean_shift(VALUE self, VALUE window, VALUE criteria);
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/***********************************************************
|
||||
|
||||
cvmatnd.cpp -
|
||||
|
||||
$Author: lsxi $
|
||||
|
||||
Copyright (C) 2007 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#include "cvmatnd.h"
|
||||
/*
|
||||
* Document-class: OpenCV::CvMatND
|
||||
*
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVMATND
|
||||
|
||||
VALUE rb_klass;
|
||||
|
||||
VALUE
|
||||
rb_class()
|
||||
{
|
||||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
* cvmat = rb_define_class_under(opencv, "CvMat", rb_cObject);
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv(), cvmat = cCvMat::rb_class();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvMatND", cvmat);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVMATND
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/************************************************************
|
||||
|
||||
cvmatnd.h -
|
||||
|
||||
$Author: lsxi $
|
||||
|
||||
Copyright (C) 2007 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#ifndef RUBY_OPENCV_CVMATND_H
|
||||
#define RUBY_OPENCV_CVMATND_H
|
||||
|
||||
#include "opencv.h"
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVMATND namespace cCvMatND {
|
||||
#define __NAMESPACE_END_CVMATND }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVMATND
|
||||
|
||||
VALUE rb_class();
|
||||
|
||||
void init_ruby_class();
|
||||
|
||||
__NAMESPACE_END_CVMATND
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
#endif // RUBY_OPENCV_CVMATND_H
|
|
@ -1,44 +0,0 @@
|
|||
/***********************************************************
|
||||
|
||||
cvsparse.cpp -
|
||||
|
||||
$Author: lsxi $
|
||||
|
||||
Copyright (C) 2007 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#include "cvsparsemat.h"
|
||||
/*
|
||||
* Document-class: OpenCV::CvSparseMat
|
||||
*
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVSPARSEMAT
|
||||
|
||||
VALUE rb_klass;
|
||||
|
||||
VALUE
|
||||
rb_class()
|
||||
{
|
||||
return rb_klass;
|
||||
}
|
||||
|
||||
void
|
||||
init_ruby_class()
|
||||
{
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
* cvmat = rb_define_class_under(opencv, "CvMat", rb_cObject);
|
||||
*
|
||||
* note: this comment is used by rdoc.
|
||||
*/
|
||||
VALUE opencv = rb_module_opencv(), cvmat = cCvMat::rb_class();
|
||||
|
||||
rb_klass = rb_define_class_under(opencv, "CvSparseMat", cvmat);
|
||||
}
|
||||
|
||||
__NAMESPACE_END_CVSPARSEMAT
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/************************************************************
|
||||
|
||||
cvsparsemat.h -
|
||||
|
||||
$Author: lsxi $
|
||||
|
||||
Copyright (C) 2005-2006 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#ifndef RUBY_OPENCV_CVSPARSEMAT_H
|
||||
#define RUBY_OPENCV_CVSPARSEMAT_H
|
||||
|
||||
#include "opencv.h"
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVSPARSEMAT namespace cCvSparseMat {
|
||||
#define __NAMESPACE_END_CVSPARSEMAT }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVSPARSEMAT
|
||||
|
||||
VALUE rb_class();
|
||||
|
||||
void init_ruby_class();
|
||||
|
||||
__NAMESPACE_END_CVSPARSEMAT
|
||||
__NAMESPACE_END_OPENCV
|
||||
|
||||
#endif // RUBY_OPENCV_CVSPARSEMAT_H
|
|
@ -738,8 +738,6 @@ extern "C" {
|
|||
|
||||
mOpenCV::cCvMat::init_ruby_class();
|
||||
mOpenCV::cIplImage::init_ruby_class();
|
||||
mOpenCV::cCvMatND::init_ruby_class();
|
||||
mOpenCV::cCvSparseMat::init_ruby_class();
|
||||
mOpenCV::cCvHistogram::init_ruby_class();
|
||||
mOpenCV::cCvCapture::init_ruby_class();
|
||||
mOpenCV::cCvVideoWriter::init_ruby_class();
|
||||
|
@ -748,7 +746,6 @@ extern "C" {
|
|||
mOpenCV::cCvTwoPoints::init_ruby_class();
|
||||
mOpenCV::cCvCircle32f::init_ruby_class();
|
||||
|
||||
mOpenCV::cCvConDensation::init_ruby_class();
|
||||
mOpenCV::cCvFeatureTree::init_ruby_class();
|
||||
|
||||
mOpenCV::cCvConnectedComp::init_ruby_class();
|
||||
|
|
|
@ -109,8 +109,6 @@ extern "C" {
|
|||
|
||||
#include "cvmat.h"
|
||||
#include "iplimage.h"
|
||||
#include "cvmatnd.h"
|
||||
#include "cvsparsemat.h"
|
||||
#include "cvhistogram.h"
|
||||
#include "cvcapture.h"
|
||||
#include "cvvideowriter.h"
|
||||
|
@ -119,8 +117,6 @@ extern "C" {
|
|||
#include "cvtwopoints.h"
|
||||
#include "cvcircle32f.h"
|
||||
|
||||
#include "cvcondensation.h"
|
||||
|
||||
#include "cvconnectedcomp.h"
|
||||
#include "cvavgcomp.h"
|
||||
#include "cvhaarclassifiercascade.h"
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,57 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
# -*- mode: ruby; coding: utf-8 -*-
|
||||
require 'test/unit'
|
||||
require 'opencv'
|
||||
require File.expand_path(File.dirname(__FILE__)) + '/helper'
|
||||
|
||||
include OpenCV
|
||||
|
||||
# Tests for matching functions of OpenCV::CvMat
|
||||
class TestCvMat_matching < OpenCVTestCase
|
||||
def setup
|
||||
@query = read_test_image('query.png')
|
||||
@images = ['1.png', '2.png', '3.png'].map{|f| read_test_image('train', f)}
|
||||
end
|
||||
|
||||
def data_dir
|
||||
File.join(File.dirname(__FILE__), '..', 'examples', 'matching_to_many_images')
|
||||
end
|
||||
|
||||
def read_test_image(*path)
|
||||
CvMat.load File.join(data_dir, *path), CV_LOAD_IMAGE_GRAYSCALE
|
||||
end
|
||||
|
||||
def test_match_descriptors
|
||||
matchs = @query.match_descriptors(@images)
|
||||
match_index, count = matchs.max_by {|image_index, count| count}
|
||||
assert_equal 2, match_index
|
||||
end
|
||||
|
||||
def test_match_descriptors_with_empty_image_array
|
||||
assert_equal({}, @query.match_descriptors([]))
|
||||
end
|
||||
|
||||
def test_match_descriptors_with_wrong_detector_type_argument
|
||||
assert_raise ArgumentError do
|
||||
@query.match_descriptors(@images, "Wrong")
|
||||
end
|
||||
end
|
||||
|
||||
def test_match_descriptors_with_wrong_descriptor_type_argument
|
||||
assert_raise ArgumentError do
|
||||
@query.match_descriptors(@images, "SURF", "wrong")
|
||||
end
|
||||
end
|
||||
|
||||
def test_match_descriptors_with_wrong_matcher_type_argument
|
||||
assert_raise ArgumentError do
|
||||
@query.match_descriptors(@images, "SURF", "SURF", "wrong")
|
||||
end
|
||||
end
|
||||
|
||||
def test_match_descriptors_with_invalid_image_array
|
||||
assert_raise TypeError do
|
||||
@query.match_descriptors([DUMMY_OBJ, DUMMY_OBJ])
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue