mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
replace rb_hash_aref to rb_hash_lookup (or LOOKUP_HASH)
This commit is contained in:
parent
79f0bef6b3
commit
6331e8dc53
4 changed files with 13 additions and 13 deletions
|
@ -132,7 +132,7 @@ rb_open(int argc, VALUE *argv, VALUE self)
|
|||
capture = cvCaptureFromCAM(FIX2INT(device));
|
||||
break;
|
||||
case T_SYMBOL: {
|
||||
VALUE cap_index = rb_hash_aref(rb_const_get(rb_class(), rb_intern("INTERFACE")), device);
|
||||
VALUE cap_index = rb_hash_lookup(rb_const_get(rb_class(), rb_intern("INTERFACE")), device);
|
||||
if (NIL_P(cap_index))
|
||||
rb_raise(rb_eArgError, "undefined interface.");
|
||||
capture = cvCaptureFromCAM(NUM2INT(cap_index));
|
||||
|
|
|
@ -135,7 +135,7 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
|||
VALUE face, font_option;
|
||||
rb_scan_args(argc, argv, "11", &face, &font_option);
|
||||
Check_Type(face, T_SYMBOL);
|
||||
face = rb_hash_aref(rb_const_get(cCvFont::rb_class(), rb_intern("FACE")), face);
|
||||
face = rb_hash_lookup(rb_const_get(cCvFont::rb_class(), rb_intern("FACE")), face);
|
||||
if (NIL_P(face)) {
|
||||
rb_raise(rb_eArgError, "undefined face.");
|
||||
}
|
||||
|
|
|
@ -753,7 +753,7 @@ rb_height(VALUE self)
|
|||
VALUE
|
||||
rb_depth(VALUE self)
|
||||
{
|
||||
return rb_hash_aref(rb_funcall(rb_const_get(rb_module_opencv(), rb_intern("DEPTH")), rb_intern("invert"), 0),
|
||||
return rb_hash_lookup(rb_funcall(rb_const_get(rb_module_opencv(), rb_intern("DEPTH")), rb_intern("invert"), 0),
|
||||
INT2FIX(CV_MAT_DEPTH(CVMAT(self)->type)));
|
||||
}
|
||||
|
||||
|
@ -1612,8 +1612,8 @@ VALUE
|
|||
rb_reshape(VALUE self, VALUE hash)
|
||||
{
|
||||
Check_Type(hash, T_HASH);
|
||||
VALUE channel = rb_hash_aref(hash, ID2SYM(rb_intern("channel")));
|
||||
VALUE rows = rb_hash_aref(hash, ID2SYM(rb_intern("rows")));
|
||||
VALUE channel = LOOKUP_HASH(hash, "channel");
|
||||
VALUE rows = LOOKUP_HASH(hash, "rows");
|
||||
CvMat *mat = NULL;
|
||||
try {
|
||||
mat = cvReshape(CVARR(self), RB_CVALLOC(CvMat), NIL_P(channel) ? 0 : NUM2INT(channel),
|
||||
|
@ -1869,9 +1869,9 @@ rb_convert_scale(VALUE self, VALUE hash)
|
|||
{
|
||||
Check_Type(hash, T_HASH);
|
||||
CvMat* self_ptr = CVMAT(self);
|
||||
VALUE depth = rb_hash_aref(hash, ID2SYM(rb_intern("depth"))),
|
||||
scale = rb_hash_aref(hash, ID2SYM(rb_intern("scale"))),
|
||||
shift = rb_hash_aref(hash, ID2SYM(rb_intern("shift")));
|
||||
VALUE depth = LOOKUP_HASH(hash, "depth");
|
||||
VALUE scale = LOOKUP_HASH(hash, "scale");
|
||||
VALUE shift = LOOKUP_HASH(hash, "shift");
|
||||
|
||||
VALUE dest = Qnil;
|
||||
try {
|
||||
|
@ -1899,8 +1899,8 @@ rb_convert_scale_abs(VALUE self, VALUE hash)
|
|||
{
|
||||
Check_Type(hash, T_HASH);
|
||||
CvMat* self_ptr = CVMAT(self);
|
||||
VALUE scale = rb_hash_aref(hash, ID2SYM(rb_intern("scale"))),
|
||||
shift = rb_hash_aref(hash, ID2SYM(rb_intern("shift")));
|
||||
VALUE scale = LOOKUP_HASH(hash, "scale");
|
||||
VALUE shift = LOOKUP_HASH(hash, "shift");
|
||||
VALUE dest = Qnil;
|
||||
try {
|
||||
dest = new_mat_kind_object(cvGetSize(self_ptr), self, CV_8U, CV_MAT_CN(CVMAT(self)->type));
|
||||
|
@ -5407,7 +5407,7 @@ rb_match_descriptors(int argc, VALUE *argv, VALUE self)
|
|||
VALUE _matches = rb_hash_new();
|
||||
for (size_t i=0; i<matches.size(); i++) {
|
||||
VALUE match = INT2FIX(matches[i].imgIdx);
|
||||
VALUE count = rb_hash_aref(_matches, match);
|
||||
VALUE count = rb_hash_lookup(_matches, match);
|
||||
if (NIL_P(count)) {
|
||||
count = INT2FIX(1);
|
||||
} else {
|
||||
|
|
|
@ -264,7 +264,7 @@ CVMETHOD(const char *name, VALUE method, int ifnone = 0)
|
|||
case T_STRING:
|
||||
method = rb_str_intern(method);
|
||||
case T_SYMBOL:
|
||||
value = rb_hash_aref(rb_const_get(rb_module_opencv(), rb_intern(name)), method);
|
||||
value = rb_hash_lookup(rb_const_get(rb_module_opencv(), rb_intern(name)), method);
|
||||
return NIL_P(value) ? ifnone : FIX2INT(value);
|
||||
default:
|
||||
raise_typeerror(method, rb_cSymbol);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue