mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
411f8ba9da
fixed the following problem [#27088] VALUE_TO_CVSCALAR wont allow float or double value http://rubyforge.org/tracker/index.php?func=detail&aid=27088&group_id=1066&atid=4198
63 lines
1.5 KiB
C
63 lines
1.5 KiB
C
/************************************************************
|
|
|
|
cvscalar.h -
|
|
|
|
$Author: lsxi $
|
|
|
|
Copyright (C) 2005 Masakazu Yonekura
|
|
|
|
************************************************************/
|
|
#ifndef RUBY_OPENCV_CVSCALAR_H
|
|
#define RUBY_OPENCV_CVSCALAR_H
|
|
|
|
#include "opencv.h"
|
|
|
|
#define __NAMESPACE_BEGIN_CVSCALAR namespace cCvScalar{
|
|
#define __NAMESPACE_END_CVSCALAR }
|
|
|
|
__NAMESPACE_BEGIN_OPENCV
|
|
__NAMESPACE_BEGIN_CVSCALAR
|
|
|
|
VALUE rb_class();
|
|
|
|
void define_ruby_class();
|
|
|
|
VALUE rb_compatible_q(VALUE klass, VALUE object);
|
|
|
|
VALUE rb_allocate(VALUE klass);
|
|
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
|
|
|
VALUE rb_aref(VALUE self, VALUE index);
|
|
VALUE rb_aset(VALUE self, VALUE index, VALUE value);
|
|
VALUE rb_sub(int argc, VALUE *argv, VALUE self);
|
|
|
|
VALUE rb_to_s(VALUE self);
|
|
VALUE rb_to_ary(VALUE self);
|
|
|
|
VALUE new_object();
|
|
VALUE new_object(CvScalar scalar);
|
|
|
|
__NAMESPACE_END_CVSCALAR
|
|
|
|
inline CvScalar*
|
|
CVSCALAR(VALUE object)
|
|
{
|
|
CvScalar *ptr;
|
|
Data_Get_Struct(object, CvScalar, ptr);
|
|
return ptr;
|
|
}
|
|
|
|
inline CvScalar
|
|
VALUE_TO_CVSCALAR(VALUE object)
|
|
{
|
|
if(FIXNUM_P(object))
|
|
return cvScalarAll(FIX2INT(object));
|
|
return cvScalar(NUM2DBL(rb_funcall(object, rb_intern("[]"), 1, INT2FIX(0))),
|
|
NUM2DBL(rb_funcall(object, rb_intern("[]"), 1, INT2FIX(1))),
|
|
NUM2DBL(rb_funcall(object, rb_intern("[]"), 1, INT2FIX(2))),
|
|
NUM2DBL(rb_funcall(object, rb_intern("[]"), 1, INT2FIX(3))));
|
|
}
|
|
|
|
__NAMESPACE_END_OPENCV
|
|
|
|
#endif // RUBY_OPENCV_CVSCALAR_H
|