Class: OpenCV::CvPoint
- Inherits:
-
Object
- Object
- OpenCV::CvPoint
- Defined in:
- ext/opencv/cvpoint.cpp,
ext/opencv/cvpoint.cpp,
ext/opencv/mouseevent.cpp
Overview
This class means one point on X axis Y axis. X and Y takes the value of the Fixnum. see also CvPoint2D32F
C structure is here, very simple.
typdef struct CvPoint {
int x;
int y;
}
Direct Known Subclasses
Class Method Summary collapse
-
.combatible?(obj) ⇒ Boolean
Return compatibility to CvPoint.
Instance Method Summary collapse
- #!=(compare_to) ⇒ Object
-
#rb_check_equality(val[,mask]) ⇒ Object
Return true CvScalar if has same values as we do.
-
#rb_check_equality(val[,mask]) ⇒ Boolean
Return true CvScalar if has same values as we do.
- #hash ⇒ Object
-
#initialize(*args) ⇒ Object
constructor
Create new 2D-coordinate, (x, y).
-
#to_ary ⇒ Array
(also: #to_a)
Return x and y by Array.
-
#to_s ⇒ "<OpenCV::CvPoint:(self.x]
Return x and y by String.
-
#x ⇒ Object
Return parameter on x-axis.
-
#x=(val) ⇒ Object
Set x-axis parameter, return self.
-
#y ⇒ Object
Return parameter on y-axis.
-
#y=(val) ⇒ Object
Set y-axis parameter, return self.
Constructor Details
#new ⇒ CvPoint.new(0, 0) #new(obj) ⇒ CvPoint.new(obj.x.to_i] #new(x, y) ⇒ Object
Create new 2D-coordinate, (x, y). It is dropped below the decimal point.
new() is same as new(0, 0)
new(obj) is same as new(obj.x.to_i, obj.y.to_i)
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'ext/opencv/cvpoint.cpp', line 78
VALUE
rb_initialize(int argc, VALUE *argv, VALUE self)
{
CvPoint* self_ptr = CVPOINT(self);
switch (argc) {
case 0:
break;
case 1: {
CvPoint point = VALUE_TO_CVPOINT(argv[0]);
self_ptr->x = point.x;
self_ptr->y = point.y;
break;
}
case 2:
self_ptr->x = NUM2INT(argv[0]);
self_ptr->y = NUM2INT(argv[1]);
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc);
break;
}
return self;
}
|
Class Method Details
.combatible?(obj) ⇒ Boolean
53 54 55 56 57 |
# File 'ext/opencv/cvpoint.cpp', line 53
VALUE
rb_compatible_q(VALUE klass, VALUE object)
{
return (rb_respond_to(object, rb_intern("x")) && rb_respond_to(object, rb_intern("y"))) ? Qtrue : Qfalse;
}
|
Instance Method Details
#!=(compare_to) ⇒ Object
167 168 169 170 171 172 173 |
# File 'ext/opencv/cvpoint.cpp', line 167
VALUE
rb_check_inequality(VALUE self, VALUE compare_to) {
CvPoint compare = VALUE_TO_CVPOINT(compare_to);
CvPoint* self_ptr = CVPOINT(self);
return (self_ptr->x != compare.x || self_ptr->y != compare.y) ? Qtrue : Qfalse;
}
|
#rb_check_equality(val[,mask]) ⇒ Object
Return true CvScalar if has same values as we do
159 160 161 162 163 164 165 |
# File 'ext/opencv/cvpoint.cpp', line 159
VALUE
rb_check_equality(VALUE self, VALUE compare_to) {
CvPoint compare = VALUE_TO_CVPOINT(compare_to);
CvPoint* self_ptr = CVPOINT(self);
return (self_ptr->x == compare.x && self_ptr->y == compare.y) ? Qtrue : Qfalse;
}
|
#rb_check_equality(val[,mask]) ⇒ Boolean
Return true CvScalar if has same values as we do
159 160 161 162 163 164 165 |
# File 'ext/opencv/cvpoint.cpp', line 159
VALUE
rb_check_equality(VALUE self, VALUE compare_to) {
CvPoint compare = VALUE_TO_CVPOINT(compare_to);
CvPoint* self_ptr = CVPOINT(self);
return (self_ptr->x == compare.x && self_ptr->y == compare.y) ? Qtrue : Qfalse;
}
|
#hash ⇒ Object
175 176 177 178 179 |
# File 'ext/opencv/cvpoint.cpp', line 175 VALUE rb_hash(VALUE self) { CvPoint* self_ptr = CVPOINT(self); return INT2NUM(rb_memhash(self_ptr, sizeof(CvPoint))); } |
#to_ary ⇒ Array Also known as: to_a
Return x and y by Array.
205 206 207 208 209 210 |
# File 'ext/opencv/cvpoint.cpp', line 205
VALUE
rb_to_ary(VALUE self)
{
CvPoint* self_ptr = CVPOINT(self);
return rb_ary_new3(2, INT2NUM(self_ptr->x), INT2NUM(self_ptr->y));
}
|
#to_s ⇒ "<OpenCV::CvPoint:(self.x]
Return x and y by String.
187 188 189 190 191 192 193 194 195 196 197 |
# File 'ext/opencv/cvpoint.cpp', line 187
VALUE
rb_to_s(VALUE self)
{
const int i = 4;
VALUE str[i];
str[0] = rb_str_new2("<%s:(%d,%d)>");
str[1] = rb_str_new2(rb_class2name(CLASS_OF(self)));
str[2] = rb_x(self);
str[3] = rb_y(self);
return rb_f_sprintf(i, str);
}
|
#x ⇒ Object
Return parameter on x-axis.
105 106 107 108 109 |
# File 'ext/opencv/cvpoint.cpp', line 105
VALUE
rb_x(VALUE self)
{
return INT2NUM(CVPOINT(self)->x);
}
|
#x=(val) ⇒ Object
123 124 125 126 127 128 |
# File 'ext/opencv/cvpoint.cpp', line 123
VALUE
rb_set_x(VALUE self, VALUE x)
{
CVPOINT(self)->x = NUM2INT(x);
return self;
}
|
#y ⇒ Object
Return parameter on y-axis.
133 134 135 136 137 |
# File 'ext/opencv/cvpoint.cpp', line 133
VALUE
rb_y(VALUE self)
{
return INT2NUM(CVPOINT(self)->y);
}
|
#y=(val) ⇒ Object
Set y-axis parameter, return self. It is dropped below the decimal point.
146 147 148 149 150 151 |
# File 'ext/opencv/cvpoint.cpp', line 146
VALUE
rb_set_y(VALUE self, VALUE y)
{
CVPOINT(self)->y = NUM2INT(y);
return self;
}
|