Class: OpenCV::Algorithm

Inherits:
Object
  • Object
show all
Defined in:
ext/opencv/lbph.cpp,
ext/opencv/algorithm.cpp,
ext/opencv/eigenfaces.cpp,
ext/opencv/fisherfaces.cpp,
ext/opencv/facerecognizer.cpp

Direct Known Subclasses

FaceRecognizer

Instance Method Summary collapse

Instance Method Details

#get_bool(parameter) ⇒ Object



169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'ext/opencv/algorithm.cpp', line 169

VALUE
rb_get_bool(VALUE self, VALUE parameter)
{
  Check_Type(parameter, T_STRING);
  bool value = false;
  try {
    value = ALGORITHM(self)->getBool(StringValueCStr(parameter));
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }

  return value ? Qtrue : Qfalse;
}

#get_double(parameter) ⇒ Object



154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'ext/opencv/algorithm.cpp', line 154

VALUE
rb_get_double(VALUE self, VALUE parameter)
{
  Check_Type(parameter, T_STRING);
  double value = 0.0;
  try {
    value = ALGORITHM(self)->getDouble(StringValueCStr(parameter));
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }

  return DBL2NUM(value);
}

#get_int(parameter) ⇒ Object



139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'ext/opencv/algorithm.cpp', line 139

VALUE
rb_get_int(VALUE self, VALUE parameter)
{
  Check_Type(parameter, T_STRING);
  int value = 0;
  try {
    value = ALGORITHM(self)->getInt(StringValueCStr(parameter));
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }

  return INT2NUM(value);
}

#get_mat(parameter) ⇒ Object



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'ext/opencv/algorithm.cpp', line 199

VALUE
rb_get_mat(VALUE self, VALUE parameter)
{
  Check_Type(parameter, T_STRING);
  VALUE mat = Qnil;
  try {
    cv::Mat value = ALGORITHM(self)->getMat(StringValueCStr(parameter));
    cv::Size size = value.size();
    mat = cCvMat::new_object(size.height, size.width, value.type());
    cv::Mat dst(CVMAT(mat));
    value.copyTo(dst);
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }
  return mat;
}

#get_matvector(parameter) ⇒ Object



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'ext/opencv/algorithm.cpp', line 217

VALUE
rb_get_matvector(VALUE self, VALUE parameter)
{
  Check_Type(parameter, T_STRING);
  VALUE array = Qnil;
  try {
    std::vector<cv::Mat> value = ALGORITHM(self)->getMatVector(StringValueCStr(parameter));
    int len = value.size();
    array = rb_ary_new2(len);
    for (int i = 0; i < len; i++) {
      cv::Mat m = value[i];
      cv::Size size = m.size();
      VALUE mat = cCvMat::new_object(size.height, size.width, m.type());
      cv::Mat dst(CVMAT(mat));
      m.copyTo(dst);
      rb_ary_store(array, i, mat);
    }
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }
  return array;
}

#get_string(parameter) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'ext/opencv/algorithm.cpp', line 184

VALUE
rb_get_string(VALUE self, VALUE parameter)
{
  Check_Type(parameter, T_STRING);
  std::string value = "";
  try {
    value = ALGORITHM(self)->getString(StringValueCStr(parameter));
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }

  return rb_str_new_cstr(value.c_str());
}

#nameObject



241
242
243
244
245
246
247
248
249
250
251
252
# File 'ext/opencv/algorithm.cpp', line 241

VALUE
rb_name(VALUE self)
{
  VALUE name = Qnil;
  try {
    name = rb_str_new_cstr(ALGORITHM(self)->name().c_str());
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }
  return name;
}

#set_algorithm(parameter, value) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'ext/opencv/algorithm.cpp', line 124

VALUE
rb_set_algorithm(VALUE self, VALUE parameter, VALUE value)
{
  Check_Type(parameter, T_STRING);
  try {
    ALGORITHM(self)->setAlgorithm(StringValueCStr(parameter), ALGORITHM(value));
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }

  return Qnil;
}

#set_bool(parameter, value) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'ext/opencv/algorithm.cpp', line 55

VALUE
rb_set_bool(VALUE self, VALUE parameter, VALUE value)
{
  Check_Type(parameter, T_STRING);
  try {
    bool val = TRUE_OR_FALSE(value) ? true : false;
    ALGORITHM(self)->setBool(StringValueCStr(parameter), val);
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }

  return Qnil;
}

#set_double(parameter, value) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'ext/opencv/algorithm.cpp', line 41

VALUE
rb_set_double(VALUE self, VALUE parameter, VALUE value)
{
  Check_Type(parameter, T_STRING);
  try {
    ALGORITHM(self)->setDouble(StringValueCStr(parameter), NUM2DBL(value));
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }

  return Qnil;
}

#set_int(parameter, value) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'ext/opencv/algorithm.cpp', line 27

VALUE
rb_set_int(VALUE self, VALUE parameter, VALUE value)
{
  Check_Type(parameter, T_STRING);
  try {
    ALGORITHM(self)->setInt(StringValueCStr(parameter), NUM2INT(value));
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }

  return Qnil;
}

#set_mat(parameter, value) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'ext/opencv/algorithm.cpp', line 85

VALUE
rb_set_mat(VALUE self, VALUE parameter, VALUE value)
{
  Check_Type(parameter, T_STRING);
  try {
    CvMat* val = CVMAT_WITH_CHECK(value);
    cv::Mat mat(val);
    ALGORITHM(self)->setMat(StringValueCStr(parameter), mat);
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }

  return Qnil;
}

#set_matvector(parameter, value) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'ext/opencv/algorithm.cpp', line 101

VALUE
rb_set_matvector(VALUE self, VALUE parameter, VALUE value)
{
  Check_Type(parameter, T_STRING);
  Check_Type(value, T_ARRAY);
  try {
    long len = RARRAY_LEN(value);
    VALUE* value_ptr = RARRAY_PTR(value);
    std::vector<cv::Mat> mat_vector;
    for (int i = 0; i < len; i++) {
      CvMat* val = CVMAT_WITH_CHECK(value_ptr[i]);
      cv::Mat mat(val);
      mat_vector.push_back(mat);
    }
    ALGORITHM(self)->setMatVector(StringValueCStr(parameter), mat_vector);
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }

  return Qnil;
}

#set_string(parameter, value) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'ext/opencv/algorithm.cpp', line 70

VALUE
rb_set_string(VALUE self, VALUE parameter, VALUE value)
{
  Check_Type(parameter, T_STRING);
  Check_Type(value, T_STRING);
  try {
    ALGORITHM(self)->setString(StringValueCStr(parameter), StringValueCStr(value));
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }

  return Qnil;
}