2008-08-19 11:01:28 -04:00
|
|
|
/************************************************************
|
|
|
|
|
|
|
|
cvslice.h -
|
|
|
|
|
|
|
|
$Author: lsxi $
|
|
|
|
|
|
|
|
Copyright (C) 2005-2006 Masakazu Yonekura
|
|
|
|
|
|
|
|
************************************************************/
|
|
|
|
#ifndef RUBY_OPENCV_CVSLICE_H
|
|
|
|
#define RUBY_OPENCV_CVSLICE_H
|
|
|
|
|
|
|
|
#include "opencv.h"
|
|
|
|
|
2011-08-11 14:04:22 -04:00
|
|
|
#define __NAMESPACE_BEGIN_CVSLICE namespace cCvSlice {
|
2008-08-19 11:01:28 -04:00
|
|
|
#define __NAMESPACE_END_CVSLICE }
|
|
|
|
|
|
|
|
__NAMESPACE_BEGIN_OPENCV
|
|
|
|
__NAMESPACE_BEGIN_CVSLICE
|
|
|
|
|
|
|
|
VALUE rb_class();
|
|
|
|
|
|
|
|
void define_ruby_class();
|
|
|
|
|
|
|
|
VALUE rb_allocate(VALUE klass);
|
|
|
|
VALUE rb_initialize(VALUE self, VALUE start, VALUE end);
|
2011-05-21 07:43:16 -04:00
|
|
|
VALUE rb_start_index_aref(VALUE self);
|
|
|
|
VALUE rb_end_index_aref(VALUE self);
|
|
|
|
VALUE rb_start_index_aset(VALUE self, VALUE index);
|
|
|
|
VALUE rb_end_index_aset(VALUE self, VALUE index);
|
2008-08-19 11:01:28 -04:00
|
|
|
|
|
|
|
__NAMESPACE_END_CVSLICE
|
|
|
|
|
|
|
|
inline CvSlice*
|
|
|
|
CVSLICE(VALUE object)
|
|
|
|
{
|
|
|
|
CvSlice *ptr;
|
|
|
|
Data_Get_Struct(object, CvSlice, ptr);
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline CvSlice
|
|
|
|
VALUE_TO_CVSLICE(VALUE object)
|
|
|
|
{
|
2011-05-21 07:43:16 -04:00
|
|
|
if (rb_obj_is_kind_of(object, cCvSlice::rb_class())) {
|
|
|
|
CvSlice* ptr = CVSLICE(object);
|
|
|
|
return *ptr;
|
|
|
|
}
|
|
|
|
else if (rb_obj_is_kind_of(object, rb_cRange)) {
|
2008-08-19 11:01:28 -04:00
|
|
|
return cvSlice(NUM2INT(rb_funcall(object, rb_intern("begin"), 0)),
|
|
|
|
rb_funcall(object, rb_intern("exclude_end?"), 0) ? NUM2INT(rb_funcall(object, rb_intern("end"), 0)) : NUM2INT(rb_funcall(object, rb_intern("end"), 0)) - 1);
|
2011-05-21 07:43:16 -04:00
|
|
|
}
|
|
|
|
else {
|
2011-07-03 01:16:38 -04:00
|
|
|
raise_compatible_typeerror(object, cCvSlice::rb_class());
|
2008-08-19 11:01:28 -04:00
|
|
|
}
|
2011-12-27 09:47:08 -05:00
|
|
|
throw "Should never reach here";
|
2008-08-19 11:01:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
__NAMESPACE_END_OPENCV
|
|
|
|
|
|
|
|
#endif // RUBY_OPENCV_CVSLICE_H
|