mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
modified CvMat#snake_image to check sizes of alpha, beta, gamma when coeff_usage == CV_ARRAY
This commit is contained in:
parent
684692a80b
commit
2fb60d0380
2 changed files with 15 additions and 6 deletions
|
@ -4826,14 +4826,19 @@ rb_snake_image(int argc, VALUE *argv, VALUE self)
|
|||
IplImage stub;
|
||||
int i;
|
||||
if (coeff == CV_VALUE) {
|
||||
a = ALLOCA_N(float, 1);
|
||||
a[0] = (float)NUM2DBL(alpha);
|
||||
b = ALLOCA_N(float, 1);
|
||||
b[0] = (float)NUM2DBL(beta);
|
||||
c = ALLOCA_N(float, 1);
|
||||
c[0] = (float)NUM2DBL(gamma);
|
||||
float buff_a, buff_b, buff_c;
|
||||
buff_a = (float)NUM2DBL(alpha);
|
||||
buff_b = (float)NUM2DBL(beta);
|
||||
buff_c = (float)NUM2DBL(gamma);
|
||||
a = &buff_a;
|
||||
b = &buff_b;
|
||||
c = &buff_c;
|
||||
}
|
||||
else { // CV_ARRAY
|
||||
if ((RARRAY_LEN(alpha) != length) ||
|
||||
(RARRAY_LEN(beta) != length) ||
|
||||
(RARRAY_LEN(gamma) != length))
|
||||
rb_raise(rb_eArgError, "alpha, beta, gamma should be same size of points");
|
||||
a = ALLOCA_N(float, length);
|
||||
b = ALLOCA_N(float, length);
|
||||
c = ALLOCA_N(float, length);
|
||||
|
|
|
@ -1630,6 +1630,10 @@ class TestCvMat_imageprocessing < OpenCVTestCase
|
|||
assert_raise(TypeError) {
|
||||
mat.snake_image(points, alpha, arr_beta, gamma, size, term_criteria)
|
||||
}
|
||||
|
||||
assert_raise(ArgumentError) {
|
||||
mat.snake_image(points, arr_alpha[0 .. num_points / 2], arr_beta, arr_gamma, size, term_criteria)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue