mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
changed arguments of CvMat#extract_surf
This commit is contained in:
parent
43c67a60cc
commit
79b8f28964
2 changed files with 8 additions and 20 deletions
|
@ -5387,36 +5387,34 @@ rb_compute_correspond_epilines(VALUE klass, VALUE points, VALUE which_image, VAL
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* extract_surf(params[,mask,keypoints]) -> [cvseq(cvsurfpoint), array(float)]
|
* extract_surf(params[,mask]) -> [cvseq(cvsurfpoint), array(float)]
|
||||||
* Extracts Speeded Up Robust Features from an image
|
* Extracts Speeded Up Robust Features from an image
|
||||||
*
|
*
|
||||||
* <i>params</i> (CvSURFParams) - Various algorithm parameters put to the structure CvSURFParams.
|
* <i>params</i> (CvSURFParams) - Various algorithm parameters put to the structure CvSURFParams.
|
||||||
* <i>mask</i> (CvMat) - The optional input 8-bit mask. The features are only found in the areas that contain more than 50% of non-zero mask pixels.
|
* <i>mask</i> (CvMat) - The optional input 8-bit mask. The features are only found in the areas that contain more than 50% of non-zero mask pixels.
|
||||||
* <i>keypoints</i> (CvSeq which includes CvSURFPoint) - Provided keypoints
|
|
||||||
*/
|
*/
|
||||||
VALUE
|
VALUE
|
||||||
rb_extract_surf(int argc, VALUE *argv, VALUE self)
|
rb_extract_surf(int argc, VALUE *argv, VALUE self)
|
||||||
{
|
{
|
||||||
VALUE _params, _mask, _keypoints;
|
VALUE _params, _mask;
|
||||||
rb_scan_args(argc, argv, "12", &_params, &_mask, &_keypoints);
|
rb_scan_args(argc, argv, "11", &_params, &_mask);
|
||||||
|
|
||||||
// Prepare arguments
|
// Prepare arguments
|
||||||
CvSURFParams params = *CVSURFPARAMS_WITH_CHECK(_params);
|
CvSURFParams params = *CVSURFPARAMS_WITH_CHECK(_params);
|
||||||
CvMat* mask = MASK(_mask);
|
CvMat* mask = MASK(_mask);
|
||||||
CvSeq* keypoints = NIL_P(_keypoints) ? NULL : CVSEQ_WITH_CHECK(_keypoints);
|
|
||||||
int use_provided = (keypoints == NULL) ? 0 : 1;
|
|
||||||
VALUE storage = cCvMemStorage::new_object();
|
VALUE storage = cCvMemStorage::new_object();
|
||||||
|
CvSeq* keypoints = NULL;
|
||||||
CvSeq* descriptors = NULL;
|
CvSeq* descriptors = NULL;
|
||||||
|
|
||||||
// Compute SURF keypoints and descriptors
|
// Compute SURF keypoints and descriptors
|
||||||
try {
|
try {
|
||||||
cvExtractSURF(CVARR(self), mask, &keypoints, &descriptors, CVMEMSTORAGE(storage),
|
cvExtractSURF(CVARR(self), mask, &keypoints, &descriptors, CVMEMSTORAGE(storage),
|
||||||
params, use_provided);
|
params, 0);
|
||||||
}
|
}
|
||||||
catch (cv::Exception& e) {
|
catch (cv::Exception& e) {
|
||||||
raise_cverror(e);
|
raise_cverror(e);
|
||||||
}
|
}
|
||||||
_keypoints = cCvSeq::new_sequence(cCvSeq::rb_class(), keypoints, cCvSURFPoint::rb_class(), storage);
|
VALUE _keypoints = cCvSeq::new_sequence(cCvSeq::rb_class(), keypoints, cCvSURFPoint::rb_class(), storage);
|
||||||
|
|
||||||
// Create descriptor array
|
// Create descriptor array
|
||||||
const int DIM_SIZE = (params.extended) ? 128 : 64;
|
const int DIM_SIZE = (params.extended) ? 128 : 64;
|
||||||
|
|
|
@ -1843,13 +1843,6 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
assert_equal(Array, descriptors2[0].class)
|
assert_equal(Array, descriptors2[0].class)
|
||||||
assert_equal(64, descriptors2[0].size)
|
assert_equal(64, descriptors2[0].size)
|
||||||
|
|
||||||
# use provided keypoints
|
|
||||||
keypoints3, descriptors3 = mat0.extract_surf(CvSURFParams.new(500, true), mask, keypoints1)
|
|
||||||
assert_equal(CvSeq, keypoints3.class)
|
|
||||||
assert_equal(254, keypoints3.size)
|
|
||||||
assert_equal(Array, descriptors3.class)
|
|
||||||
assert_equal(254, descriptors3.size)
|
|
||||||
|
|
||||||
# raise exceptions because of invalid arguments
|
# raise exceptions because of invalid arguments
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
mat0.extract_surf(DUMMY_OBJ)
|
mat0.extract_surf(DUMMY_OBJ)
|
||||||
|
@ -1857,13 +1850,10 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
||||||
assert_raise(TypeError) {
|
assert_raise(TypeError) {
|
||||||
mat0.extract_surf(CvSURFParams.new(500), DUMMY_OBJ)
|
mat0.extract_surf(CvSURFParams.new(500), DUMMY_OBJ)
|
||||||
}
|
}
|
||||||
assert_raise(TypeError) {
|
|
||||||
mat0.extract_surf(CvSURFParams.new(500), mask, DUMMY_OBJ)
|
|
||||||
}
|
|
||||||
|
|
||||||
## Uncomment the following lines to show the result
|
# Uncomment the following lines to show the result
|
||||||
# results = []
|
# results = []
|
||||||
# [keypoints1, keypoints2, keypoints3].each { |kpts|
|
# [keypoints1, keypoints2].each { |kpts|
|
||||||
# tmp = mat0.GRAY2BGR
|
# tmp = mat0.GRAY2BGR
|
||||||
# kpts.each { |kp|
|
# kpts.each { |kp|
|
||||||
# tmp.circle!(kp.pt, 3, :color => CvColor::Red, :thickness => 1, :line_type => :aa)
|
# tmp.circle!(kp.pt, 3, :color => CvColor::Red, :thickness => 1, :line_type => :aa)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue