bonanza-ruby-opencv 0.0.13.20160621111908 → 0.0.13.20200923185241
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/ext/opencv/cvchain.cpp +4 -0
- data/ext/opencv/cvhistogram.cpp +43 -11
- data/ext/opencv/cvmat.cpp +74 -24
- data/ext/opencv/cvseq.cpp +24 -0
- data/ext/opencv/iplconvkernel.cpp +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b1e5119a7a5d2271845769949eddcaccd0a519c3afd373f967b4b7c6a19880a6
|
4
|
+
data.tar.gz: 05c6480bfdc0f25d07fdc6e4e1d79ee6be8a1ddf94f2d9aabcc7654bd3f6598e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 645336822d5bed3ce63d416646bfa96fe040d4f868af99546e0247abdbc1103be5fac7009340a759271bb2c2be16a7ec4d5e74328e50a9f7fe055c641906da6d
|
7
|
+
data.tar.gz: 9ecc114298d4f79d2d57f30bb8630125c089104d9a7aee0c14dd3b95826f6cc19c590e64b5eae380a56397e7143f81749c7e0227e4a9f2ffd92d4a5180e4d25d
|
data/ext/opencv/cvchain.cpp
CHANGED
@@ -62,7 +62,11 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|
62
62
|
raise_cverror(e);
|
63
63
|
}
|
64
64
|
CvSeq* self_ptr = CVSEQ(self);
|
65
|
+
#ifdef RUBY_INTEGER_UNIFICATION
|
66
|
+
cCvSeq::register_elem_class(self, rb_cInteger);
|
67
|
+
#else
|
65
68
|
cCvSeq::register_elem_class(self, rb_cFixnum);
|
69
|
+
#endif
|
66
70
|
register_root_object(self_ptr, storage_value);
|
67
71
|
|
68
72
|
return self;
|
data/ext/opencv/cvhistogram.cpp
CHANGED
@@ -95,19 +95,19 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|
95
95
|
|
96
96
|
rb_scan_args(argc, argv, "32", &_dims, &_sizes, &_type, &_ranges, &_uniform);
|
97
97
|
int sizes_len = RARRAY_LEN(_sizes);
|
98
|
-
sizes =
|
98
|
+
sizes = RB_ALLOC_N(int, sizes_len);
|
99
99
|
|
100
100
|
if (NIL_P(_ranges)) {
|
101
101
|
sizes = ary2intptr(_sizes, sizes);
|
102
102
|
ranges = NULL;
|
103
103
|
}
|
104
104
|
else {
|
105
|
-
ranges =
|
105
|
+
ranges = RB_ALLOC_N(float*, sizes_len);
|
106
106
|
VALUE* range_ptr = RARRAY_PTR(_ranges);
|
107
107
|
int i;
|
108
108
|
for (i = 0; i < sizes_len; i++) {
|
109
109
|
sizes[i] = NUM2INT(RARRAY_PTR(_sizes)[i]);
|
110
|
-
ranges[i] = ary2fltptr(range_ptr[i],
|
110
|
+
ranges[i] = ary2fltptr(range_ptr[i], RB_ALLOC_N(float, 2));
|
111
111
|
}
|
112
112
|
}
|
113
113
|
uniform = TRUE_OR_FALSE(_uniform, 1);
|
@@ -193,7 +193,7 @@ rb_calc_hist_bang(int argc, VALUE* argv, VALUE self)
|
|
193
193
|
rb_scan_args(argc, argv, "12", &images, &accumulate, &mask);
|
194
194
|
Check_Type(images, T_ARRAY);
|
195
195
|
int num_images = RARRAY_LEN(images);
|
196
|
-
IplImage** img =
|
196
|
+
IplImage** img = RB_ALLOC_N(IplImage*, num_images);
|
197
197
|
VALUE* images_ptr = RARRAY_PTR(images);
|
198
198
|
for (int i = 0; i < num_images; i++) {
|
199
199
|
img[i] = IPLIMAGE_WITH_CHECK(images_ptr[i]);
|
@@ -226,7 +226,7 @@ VALUE
|
|
226
226
|
rb_aref(VALUE self, VALUE args)
|
227
227
|
{
|
228
228
|
int num_idx = RARRAY_LEN(args);
|
229
|
-
int* idx =
|
229
|
+
int* idx = RB_ALLOC_N(int, num_idx);
|
230
230
|
VALUE* args_ptr = RARRAY_PTR(args);
|
231
231
|
for (int i = 0; i < num_idx; i++) {
|
232
232
|
idx[i] = NUM2INT(args_ptr[i]);
|
@@ -257,6 +257,36 @@ rb_aref(VALUE self, VALUE args)
|
|
257
257
|
return rb_float_new((double)value);
|
258
258
|
}
|
259
259
|
|
260
|
+
VALUE
|
261
|
+
rb_at(VALUE self, VALUE x)
|
262
|
+
{
|
263
|
+
float value = 0.0;
|
264
|
+
CvHistogram* self_ptr = CVHISTOGRAM(self);
|
265
|
+
try {
|
266
|
+
value = cvQueryHistValue_1D(self_ptr, NUM2INT(x));
|
267
|
+
}
|
268
|
+
catch (cv::Exception& e) {
|
269
|
+
raise_cverror(e);
|
270
|
+
}
|
271
|
+
|
272
|
+
return rb_float_new((double)value);
|
273
|
+
}
|
274
|
+
|
275
|
+
VALUE
|
276
|
+
rb_at_3d(VALUE self, VALUE x, VALUE y, VALUE z)
|
277
|
+
{
|
278
|
+
float value = 0.0;
|
279
|
+
CvHistogram* self_ptr = CVHISTOGRAM(self);
|
280
|
+
try {
|
281
|
+
value = cvQueryHistValue_3D(self_ptr, NUM2INT(x), NUM2INT(y), NUM2INT(z));
|
282
|
+
}
|
283
|
+
catch (cv::Exception& e) {
|
284
|
+
raise_cverror(e);
|
285
|
+
}
|
286
|
+
|
287
|
+
return rb_float_new((double)value);
|
288
|
+
}
|
289
|
+
|
260
290
|
/*
|
261
291
|
* Finds the minimum and maximum histogram bins.
|
262
292
|
* @overload min_max_value
|
@@ -279,8 +309,8 @@ rb_min_max_value(VALUE self)
|
|
279
309
|
int *max_idx = NULL;
|
280
310
|
try {
|
281
311
|
dims = cvGetDims(self_ptr->bins, NULL);
|
282
|
-
min_idx =
|
283
|
-
max_idx =
|
312
|
+
min_idx = RB_ALLOC_N(int, dims);
|
313
|
+
max_idx = RB_ALLOC_N(int, dims);
|
284
314
|
cvGetMinMaxHistValue(CVHISTOGRAM(self), &min_value, &max_value, min_idx, max_idx);
|
285
315
|
}
|
286
316
|
catch (cv::Exception& e) {
|
@@ -493,10 +523,10 @@ rb_set_hist_bin_ranges_bang(int argc, VALUE* argv, VALUE self)
|
|
493
523
|
Check_Type(_ranges, T_ARRAY);
|
494
524
|
|
495
525
|
int ranges_size = RARRAY_LEN(_ranges);
|
496
|
-
float** ranges =
|
526
|
+
float** ranges = RB_ALLOC_N(float*, ranges_size);
|
497
527
|
VALUE* range_ptr = RARRAY_PTR(_ranges);
|
498
528
|
for (int i = 0; i < ranges_size; ++i) {
|
499
|
-
ranges[i] = ary2fltptr(range_ptr[i],
|
529
|
+
ranges[i] = ary2fltptr(range_ptr[i], RB_ALLOC_N(float, 2));
|
500
530
|
}
|
501
531
|
int uniform = TRUE_OR_FALSE(_uniform, 1);
|
502
532
|
|
@@ -530,7 +560,7 @@ rb_calc_back_project(VALUE self, VALUE image)
|
|
530
560
|
return Qnil;
|
531
561
|
}
|
532
562
|
|
533
|
-
IplImage** img =
|
563
|
+
IplImage** img = RB_ALLOC_N(IplImage*, num_images);
|
534
564
|
VALUE* image_ptr = RARRAY_PTR(image);
|
535
565
|
for (int i = 0; i < num_images; ++i) {
|
536
566
|
img[i] = IPLIMAGE_WITH_CHECK(image_ptr[i]);
|
@@ -577,7 +607,7 @@ rb_calc_back_project_patch(VALUE self, VALUE image, VALUE patch_size, VALUE meth
|
|
577
607
|
return Qnil;
|
578
608
|
}
|
579
609
|
|
580
|
-
IplImage** img =
|
610
|
+
IplImage** img = RB_ALLOC_N(IplImage*, num_images);
|
581
611
|
VALUE* image_ptr = RARRAY_PTR(image);
|
582
612
|
for (int i = 0; i < num_images; ++i) {
|
583
613
|
img[i] = IPLIMAGE_WITH_CHECK(image_ptr[i]);
|
@@ -682,6 +712,8 @@ init_ruby_class()
|
|
682
712
|
rb_define_method(rb_klass, "calc_hist", RUBY_METHOD_FUNC(rb_calc_hist), -1);
|
683
713
|
rb_define_method(rb_klass, "calc_hist!", RUBY_METHOD_FUNC(rb_calc_hist_bang), -1);
|
684
714
|
rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), -2);
|
715
|
+
rb_define_method(rb_klass, "at", RUBY_METHOD_FUNC(rb_at), 1);
|
716
|
+
rb_define_method(rb_klass, "at_3d", RUBY_METHOD_FUNC(rb_at_3d), 3);
|
685
717
|
rb_define_alias(rb_klass, "query_hist_value", "[]");
|
686
718
|
rb_define_method(rb_klass, "min_max_value", RUBY_METHOD_FUNC(rb_min_max_value), 0);
|
687
719
|
rb_define_method(rb_klass, "copy_hist", RUBY_METHOD_FUNC(rb_copy_hist), 0);
|
data/ext/opencv/cvmat.cpp
CHANGED
@@ -1137,14 +1137,11 @@ rb_set_data(VALUE self, VALUE data)
|
|
1137
1137
|
int depth = CV_MAT_DEPTH(self_ptr->type);
|
1138
1138
|
|
1139
1139
|
if (TYPE(data) == T_STRING) {
|
1140
|
-
if (depth != CV_8U)
|
1141
|
-
rb_raise(rb_eArgError, "Invalid CvMat depth");
|
1142
|
-
|
1143
1140
|
if (!CV_IS_MAT_CONT(self_ptr->type))
|
1144
1141
|
rb_raise(rb_eArgError, "CvMat must be continuous");
|
1145
1142
|
|
1146
1143
|
const int dataLength = RSTRING_LEN(data);
|
1147
|
-
if (dataLength != self_ptr->width * self_ptr->height *
|
1144
|
+
if (dataLength != self_ptr->width * self_ptr->height * CV_ELEM_SIZE(self_ptr->type))
|
1148
1145
|
rb_raise(rb_eArgError, "Invalid data string length");
|
1149
1146
|
|
1150
1147
|
memcpy(self_ptr->data.ptr, RSTRING_PTR(data), dataLength);
|
@@ -2101,12 +2098,21 @@ VALUE
|
|
2101
2098
|
rb_cmp_internal(VALUE self, VALUE val, VALUE dest, int operand)
|
2102
2099
|
{
|
2103
2100
|
CvArr* self_ptr = CVARR(self);
|
2101
|
+
|
2102
|
+
if (CV_MAT_CN(cvGetElemType(self_ptr)) != 1) {
|
2103
|
+
rb_raise(rb_eArgError, "self should be a single-channel CvMat.");
|
2104
|
+
}
|
2105
|
+
|
2104
2106
|
try {
|
2105
|
-
if (rb_obj_is_kind_of(val, rb_klass))
|
2106
|
-
|
2107
|
-
|
2107
|
+
if (rb_obj_is_kind_of(val, rb_klass)) {
|
2108
|
+
CvArr* val_ptr = CVARR(val);
|
2109
|
+
if (CV_MAT_CN(cvGetElemType(val_ptr)) != 1) {
|
2110
|
+
rb_raise(rb_eArgError, "val should be a single-channel CvMat.");
|
2111
|
+
}
|
2112
|
+
cvCmp(self_ptr, val_ptr, CVARR(dest), operand);
|
2113
|
+
} else if (rb_obj_is_kind_of(val, rb_cNumeric)) {
|
2108
2114
|
cvCmpS(self_ptr, NUM2DBL(val), CVARR(dest), operand);
|
2109
|
-
else {
|
2115
|
+
} else {
|
2110
2116
|
VALUE mat = new_mat_kind_object(cvGetSize(CVARR(self)), self);
|
2111
2117
|
cvSet(CVARR(mat), VALUE_TO_CVSCALAR(val));
|
2112
2118
|
cvCmp(self_ptr, CVARR(mat), CVARR(dest), operand);
|
@@ -3415,14 +3421,14 @@ rb_fill_poly_bang(int argc, VALUE *argv, VALUE self)
|
|
3415
3421
|
Check_Type(polygons, T_ARRAY);
|
3416
3422
|
drawing_option = DRAWING_OPTION(drawing_option);
|
3417
3423
|
num_polygons = RARRAY_LEN(polygons);
|
3418
|
-
num_points =
|
3424
|
+
num_points = RB_ALLOC_N(int, num_polygons);
|
3419
3425
|
|
3420
|
-
p =
|
3426
|
+
p = RB_ALLOC_N(CvPoint*, num_polygons);
|
3421
3427
|
for (j = 0; j < num_polygons; ++j) {
|
3422
3428
|
points = rb_ary_entry(polygons, j);
|
3423
3429
|
Check_Type(points, T_ARRAY);
|
3424
3430
|
num_points[j] = RARRAY_LEN(points);
|
3425
|
-
p[j] =
|
3431
|
+
p[j] = RB_ALLOC_N(CvPoint, num_points[j]);
|
3426
3432
|
for (i = 0; i < num_points[j]; ++i) {
|
3427
3433
|
p[j][i] = VALUE_TO_CVPOINT(rb_ary_entry(points, i));
|
3428
3434
|
}
|
@@ -3488,7 +3494,7 @@ rb_fill_convex_poly_bang(int argc, VALUE *argv, VALUE self)
|
|
3488
3494
|
Check_Type(points, T_ARRAY);
|
3489
3495
|
drawing_option = DRAWING_OPTION(drawing_option);
|
3490
3496
|
num_points = RARRAY_LEN(points);
|
3491
|
-
p =
|
3497
|
+
p = RB_ALLOC_N(CvPoint, num_points);
|
3492
3498
|
for (i = 0; i < num_points; ++i)
|
3493
3499
|
p[i] = VALUE_TO_CVPOINT(rb_ary_entry(points, i));
|
3494
3500
|
|
@@ -3564,14 +3570,14 @@ rb_poly_line_bang(int argc, VALUE *argv, VALUE self)
|
|
3564
3570
|
Check_Type(polygons, T_ARRAY);
|
3565
3571
|
drawing_option = DRAWING_OPTION(drawing_option);
|
3566
3572
|
num_polygons = RARRAY_LEN(polygons);
|
3567
|
-
num_points =
|
3568
|
-
p =
|
3573
|
+
num_points = RB_ALLOC_N(int, num_polygons);
|
3574
|
+
p = RB_ALLOC_N(CvPoint*, num_polygons);
|
3569
3575
|
|
3570
3576
|
for (j = 0; j < num_polygons; ++j) {
|
3571
3577
|
points = rb_ary_entry(polygons, j);
|
3572
3578
|
Check_Type(points, T_ARRAY);
|
3573
3579
|
num_points[j] = RARRAY_LEN(points);
|
3574
|
-
p[j] =
|
3580
|
+
p[j] = RB_ALLOC_N(CvPoint, num_points[j]);
|
3575
3581
|
for (i = 0; i < num_points[j]; ++i) {
|
3576
3582
|
p[j][i] = VALUE_TO_CVPOINT(rb_ary_entry(points, i));
|
3577
3583
|
}
|
@@ -3980,7 +3986,7 @@ rb_find_chessboard_corners(int argc, VALUE *argv, VALUE self)
|
|
3980
3986
|
|
3981
3987
|
int flag = NIL_P(flag_val) ? CV_CALIB_CB_ADAPTIVE_THRESH : NUM2INT(flag_val);
|
3982
3988
|
CvSize pattern_size = VALUE_TO_CVSIZE(pattern_size_val);
|
3983
|
-
CvPoint2D32f* corners =
|
3989
|
+
CvPoint2D32f* corners = RB_ALLOC_N(CvPoint2D32f, pattern_size.width * pattern_size.height);
|
3984
3990
|
int num_found_corners = 0;
|
3985
3991
|
int pattern_was_found = 0;
|
3986
3992
|
try {
|
@@ -4016,7 +4022,7 @@ rb_find_corner_sub_pix(VALUE self, VALUE corners, VALUE win_size, VALUE zero_zon
|
|
4016
4022
|
{
|
4017
4023
|
Check_Type(corners, T_ARRAY);
|
4018
4024
|
int count = RARRAY_LEN(corners);
|
4019
|
-
CvPoint2D32f* corners_buff =
|
4025
|
+
CvPoint2D32f* corners_buff = RB_ALLOC_N(CvPoint2D32f, count);
|
4020
4026
|
VALUE* corners_ptr = RARRAY_PTR(corners);
|
4021
4027
|
|
4022
4028
|
for (int i = 0; i < count; i++) {
|
@@ -4325,8 +4331,8 @@ rb_get_perspective_transform(VALUE self, VALUE source, VALUE dest)
|
|
4325
4331
|
|
4326
4332
|
int count = RARRAY_LEN(source);
|
4327
4333
|
|
4328
|
-
CvPoint2D32f* source_buff =
|
4329
|
-
CvPoint2D32f* dest_buff =
|
4334
|
+
CvPoint2D32f* source_buff = RB_ALLOC_N(CvPoint2D32f, count);
|
4335
|
+
CvPoint2D32f* dest_buff = RB_ALLOC_N(CvPoint2D32f, count);
|
4330
4336
|
|
4331
4337
|
for (int i = 0; i < count; i++) {
|
4332
4338
|
source_buff[i] = *(CVPOINT2D32F(RARRAY_PTR(source)[i]));
|
@@ -5192,6 +5198,35 @@ rb_flood_fill_bang(int argc, VALUE *argv, VALUE self)
|
|
5192
5198
|
return rb_ary_new3(3, self, cCvRect::new_object(cvRect(rect.x, rect.y, rect.width, rect.height)), mask);
|
5193
5199
|
}
|
5194
5200
|
|
5201
|
+
VALUE
|
5202
|
+
rb_flood_fill_mask(VALUE self, VALUE seed_point, VALUE mask, VALUE lo_diff, VALUE up_diff, VALUE connectivity, VALUE fixed_range)
|
5203
|
+
{
|
5204
|
+
int flags = NUM2INT(connectivity);
|
5205
|
+
if (RTEST(fixed_range)) {
|
5206
|
+
flags |= CV_FLOODFILL_FIXED_RANGE;
|
5207
|
+
}
|
5208
|
+
flags |= CV_FLOODFILL_MASK_ONLY;
|
5209
|
+
cv::Rect rect;
|
5210
|
+
try {
|
5211
|
+
cv::Mat selfMat(CVMAT(self));
|
5212
|
+
cv::Mat maskMat(CVMAT(mask));
|
5213
|
+
|
5214
|
+
cv::floodFill(
|
5215
|
+
selfMat,
|
5216
|
+
maskMat,
|
5217
|
+
cv::Point(VALUE_TO_CVPOINT(seed_point)),
|
5218
|
+
cv::Scalar(cvScalar(0)),
|
5219
|
+
&rect,
|
5220
|
+
cv::Scalar(NIL_P(lo_diff) ? cvScalar(0) : VALUE_TO_CVSCALAR(lo_diff)),
|
5221
|
+
cv::Scalar(NIL_P(up_diff) ? cvScalar(0) : VALUE_TO_CVSCALAR(up_diff)),
|
5222
|
+
flags);
|
5223
|
+
}
|
5224
|
+
catch (cv::Exception& e) {
|
5225
|
+
raise_cverror(e);
|
5226
|
+
}
|
5227
|
+
return cCvRect::new_object(cvRect(rect.x, rect.y, rect.width, rect.height));
|
5228
|
+
}
|
5229
|
+
|
5195
5230
|
/*
|
5196
5231
|
* Finds contours in binary image.
|
5197
5232
|
*
|
@@ -5340,7 +5375,7 @@ rb_draw_chessboard_corners_bang(VALUE self, VALUE pattern_size, VALUE corners, V
|
|
5340
5375
|
{
|
5341
5376
|
Check_Type(corners, T_ARRAY);
|
5342
5377
|
int count = RARRAY_LEN(corners);
|
5343
|
-
CvPoint2D32f* corners_buff =
|
5378
|
+
CvPoint2D32f* corners_buff = RB_ALLOC_N(CvPoint2D32f, count);
|
5344
5379
|
VALUE* corners_ptr = RARRAY_PTR(corners);
|
5345
5380
|
for (int i = 0; i < count; i++) {
|
5346
5381
|
corners_buff[i] = *(CVPOINT2D32F(corners_ptr[i]));
|
@@ -5432,6 +5467,19 @@ rb_watershed(VALUE self, VALUE markers)
|
|
5432
5467
|
return markers;
|
5433
5468
|
}
|
5434
5469
|
|
5470
|
+
VALUE
|
5471
|
+
rb_kmeans(VALUE self, VALUE k, VALUE termcrit)
|
5472
|
+
{
|
5473
|
+
VALUE labels = new_object(CVMAT(self)->height, 1, CV_32SC1);
|
5474
|
+
try {
|
5475
|
+
cvKMeans2(CVARR(self), NUM2INT(k), CVARR(labels), *CVTERMCRITERIA(termcrit));
|
5476
|
+
}
|
5477
|
+
catch (cv::Exception& e) {
|
5478
|
+
raise_cverror(e);
|
5479
|
+
}
|
5480
|
+
return labels;
|
5481
|
+
}
|
5482
|
+
|
5435
5483
|
/*
|
5436
5484
|
* call-seq:
|
5437
5485
|
* grab_cut -> cvmat(mask:cv8uc1)
|
@@ -6018,9 +6066,9 @@ rb_snake_image(int argc, VALUE *argv, VALUE self)
|
|
6018
6066
|
(RARRAY_LEN(beta) != length) ||
|
6019
6067
|
(RARRAY_LEN(gamma) != length))
|
6020
6068
|
rb_raise(rb_eArgError, "alpha, beta, gamma should be same size of points");
|
6021
|
-
a =
|
6022
|
-
b =
|
6023
|
-
c =
|
6069
|
+
a = RB_ALLOC_N(float, length);
|
6070
|
+
b = RB_ALLOC_N(float, length);
|
6071
|
+
c = RB_ALLOC_N(float, length);
|
6024
6072
|
for (i = 0; i < length; ++i) {
|
6025
6073
|
a[i] = (float)NUM2DBL(RARRAY_PTR(alpha)[i]);
|
6026
6074
|
b[i] = (float)NUM2DBL(RARRAY_PTR(beta)[i]);
|
@@ -6696,7 +6744,7 @@ init_ruby_class()
|
|
6696
6744
|
rb_define_method(rb_klass, "range", RUBY_METHOD_FUNC(rb_range), 2);
|
6697
6745
|
rb_define_method(rb_klass, "range!", RUBY_METHOD_FUNC(rb_range_bang), 2);
|
6698
6746
|
|
6699
|
-
rb_define_method(rb_klass, "reshape", RUBY_METHOD_FUNC(rb_reshape),
|
6747
|
+
rb_define_method(rb_klass, "reshape", RUBY_METHOD_FUNC(rb_reshape), 1);
|
6700
6748
|
rb_define_method(rb_klass, "repeat", RUBY_METHOD_FUNC(rb_repeat), 1);
|
6701
6749
|
rb_define_method(rb_klass, "flip", RUBY_METHOD_FUNC(rb_flip), -1);
|
6702
6750
|
rb_define_method(rb_klass, "flip!", RUBY_METHOD_FUNC(rb_flip_bang), -1);
|
@@ -6832,6 +6880,7 @@ init_ruby_class()
|
|
6832
6880
|
|
6833
6881
|
rb_define_method(rb_klass, "flood_fill", RUBY_METHOD_FUNC(rb_flood_fill), -1);
|
6834
6882
|
rb_define_method(rb_klass, "flood_fill!", RUBY_METHOD_FUNC(rb_flood_fill_bang), -1);
|
6883
|
+
rb_define_method(rb_klass, "flood_fill_mask", RUBY_METHOD_FUNC(rb_flood_fill_mask), 6);
|
6835
6884
|
rb_define_method(rb_klass, "find_contours", RUBY_METHOD_FUNC(rb_find_contours), -1);
|
6836
6885
|
rb_define_method(rb_klass, "find_contours!", RUBY_METHOD_FUNC(rb_find_contours_bang), -1);
|
6837
6886
|
rb_define_method(rb_klass, "draw_contours", RUBY_METHOD_FUNC(rb_draw_contours), -1);
|
@@ -6840,6 +6889,7 @@ init_ruby_class()
|
|
6840
6889
|
rb_define_method(rb_klass, "draw_chessboard_corners!", RUBY_METHOD_FUNC(rb_draw_chessboard_corners_bang), 3);
|
6841
6890
|
rb_define_method(rb_klass, "pyr_mean_shift_filtering", RUBY_METHOD_FUNC(rb_pyr_mean_shift_filtering), -1);
|
6842
6891
|
rb_define_method(rb_klass, "watershed", RUBY_METHOD_FUNC(rb_watershed), 1);
|
6892
|
+
rb_define_method(rb_klass, "kmeans", RUBY_METHOD_FUNC(rb_kmeans), 2);
|
6843
6893
|
rb_define_method(rb_klass, "grab_cut", RUBY_METHOD_FUNC(rb_grab_cut), 6);
|
6844
6894
|
rb_define_method(rb_klass, "grab_cut2", RUBY_METHOD_FUNC(rb_grab_cut2), 10);
|
6845
6895
|
|
data/ext/opencv/cvseq.cpp
CHANGED
@@ -88,7 +88,11 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|
88
88
|
raise_typeerror(klass, rb_cClass);
|
89
89
|
|
90
90
|
int type = 0, size = 0;
|
91
|
+
#ifdef RUBY_INTEGER_UNIFICATION
|
92
|
+
if (klass == rb_cInteger) {
|
93
|
+
#else
|
91
94
|
if (klass == rb_cFixnum) {
|
95
|
+
#endif
|
92
96
|
type = CV_SEQ_ELTYPE_INDEX;
|
93
97
|
size = sizeof(int);
|
94
98
|
}
|
@@ -170,7 +174,11 @@ rb_aref(VALUE self, VALUE index)
|
|
170
174
|
|
171
175
|
VALUE result = Qnil;
|
172
176
|
try {
|
177
|
+
#ifdef RUBY_INTEGER_UNIFICATION
|
178
|
+
if (seqblock_class(self) == rb_cInteger)
|
179
|
+
#else
|
173
180
|
if (seqblock_class(self) == rb_cFixnum)
|
181
|
+
#endif
|
174
182
|
result = INT2NUM(*CV_GET_SEQ_ELEM(int, seq, idx));
|
175
183
|
else
|
176
184
|
result = REFER_OBJECT(seqblock_class(self), cvGetSeqElem(seq, idx), self);
|
@@ -352,7 +360,11 @@ rb_pop(VALUE self)
|
|
352
360
|
VALUE object = Qnil;
|
353
361
|
VALUE klass = seqblock_class(self);
|
354
362
|
try {
|
363
|
+
#ifdef RUBY_INTEGER_UNIFICATION
|
364
|
+
if (klass == rb_cInteger) {
|
365
|
+
#else
|
355
366
|
if (klass == rb_cFixnum) {
|
367
|
+
#endif
|
356
368
|
int n = 0;
|
357
369
|
cvSeqPop(seq, &n);
|
358
370
|
object = INT2FIX(n);
|
@@ -420,7 +432,11 @@ rb_shift(VALUE self)
|
|
420
432
|
|
421
433
|
VALUE object = Qnil;
|
422
434
|
try {
|
435
|
+
#ifdef RUBY_INTEGER_UNIFICATION
|
436
|
+
if (seqblock_class(self) == rb_cInteger) {
|
437
|
+
#else
|
423
438
|
if (seqblock_class(self) == rb_cFixnum) {
|
439
|
+
#endif
|
424
440
|
int n = 0;
|
425
441
|
cvSeqPopFront(seq, &n);
|
426
442
|
object = INT2NUM(n);
|
@@ -456,7 +472,11 @@ rb_each(VALUE self)
|
|
456
472
|
if (seq->total > 0) {
|
457
473
|
VALUE klass = seqblock_class(self);
|
458
474
|
try {
|
475
|
+
#ifdef RUBY_INTEGER_UNIFICATION
|
476
|
+
if (klass == rb_cInteger)
|
477
|
+
#else
|
459
478
|
if (klass == rb_cFixnum)
|
479
|
+
#endif
|
460
480
|
for (int i = 0; i < seq->total; ++i)
|
461
481
|
rb_yield(INT2NUM(*CV_GET_SEQ_ELEM(int, seq, i)));
|
462
482
|
else
|
@@ -501,7 +521,11 @@ rb_insert(VALUE self, VALUE index, VALUE object)
|
|
501
521
|
if (CLASS_OF(object) != klass)
|
502
522
|
rb_raise(rb_eTypeError, "arguments should be %s.", rb_class2name(klass));
|
503
523
|
try {
|
524
|
+
#ifdef RUBY_INTEGER_UNIFICATION
|
525
|
+
if (klass == rb_cInteger) {
|
526
|
+
#else
|
504
527
|
if (klass == rb_cFixnum) {
|
528
|
+
#endif
|
505
529
|
int n = NUM2INT(object);
|
506
530
|
cvSeqInsert(seq, NUM2INT(index), &n);
|
507
531
|
}
|
@@ -75,7 +75,7 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|
75
75
|
if (NIL_P(values))
|
76
76
|
rb_raise(rb_eArgError, "argument 6 (values) should not be nil when the shape is :custom.");
|
77
77
|
num_values = RARRAY_LEN(values);
|
78
|
-
_values =
|
78
|
+
_values = RB_ALLOC_N(int, num_values);
|
79
79
|
VALUE *values_ptr = RARRAY_PTR(values);
|
80
80
|
for (int i = 0; i < num_values; ++i)
|
81
81
|
_values[i] = NUM2INT(values_ptr[i]);
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bonanza-ruby-opencv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.13.
|
4
|
+
version: 0.0.13.20200923185241
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lsxi
|
8
8
|
- ser1zw
|
9
9
|
- pcting
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-09-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rdoc
|
@@ -328,7 +328,7 @@ homepage: https://github.com/ruby-opencv/ruby-opencv/
|
|
328
328
|
licenses:
|
329
329
|
- The BSD License
|
330
330
|
metadata: {}
|
331
|
-
post_install_message:
|
331
|
+
post_install_message:
|
332
332
|
rdoc_options:
|
333
333
|
- "--main"
|
334
334
|
- README.md
|
@@ -345,9 +345,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
345
345
|
- !ruby/object:Gem::Version
|
346
346
|
version: '0'
|
347
347
|
requirements: []
|
348
|
-
|
349
|
-
|
350
|
-
signing_key:
|
348
|
+
rubygems_version: 3.0.8
|
349
|
+
signing_key:
|
351
350
|
specification_version: 4
|
352
351
|
summary: OpenCV wrapper for Ruby
|
353
352
|
test_files:
|