Class: OpenCV::CvBox2D
- Inherits:
-
Object
- Object
- OpenCV::CvBox2D
- Includes:
- Curve
- Defined in:
- ext/opencv/cvbox2d.cpp,
ext/opencv/cvbox2d.cpp
Overview
Stores coordinates of a rotated rectangle.
Constant Summary collapse
- APPROX_CHAIN_OPTION =
approx_chain_option
Instance Method Summary collapse
-
#angle ⇒ Float
Returns angle of the box.
-
#angle= ⇒ CvBox2D
Set angle of the box.
-
#approx_chain(options) ⇒ CvSeq<CvPoint>
(also: #approx)
Approximates Freeman chains with a polygonal curve.
-
#center ⇒ CvPoint2D32f
Returns center point of the box.
-
#center= ⇒ CvBox2D
Set center point of the box.
-
#codes ⇒ Array<Integer>
Returns the chain codes.
-
#new(storage = nil) ⇒ CvChain
constructor
Create a new chain code.
-
#origin ⇒ CvPoint
Returns Freeman chain code origin.
-
#origin= ⇒ CvChain
Set Freeman chain code origin.
-
#points ⇒ Array<CvPoint>
Returns the points of the chain codes.
-
#size ⇒ CvSize2D32f
Returns size of the box.
-
#size= ⇒ CvBox2D
Set size of the box.
Methods included from Curve
#arc_length, #closed?, #convex?, #hole?, #simple?
Constructor Details
#new(storage = nil) ⇒ CvChain
Create a new chain code
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'ext/opencv/cvbox2d.cpp', line 42
VALUE
rb_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE center, size, angle;
CvBox2D* self_ptr = CVBOX2D(self);
rb_scan_args(argc, argv, "03", ¢er, &size, &angle);
if (!NIL_P(center)) {
self_ptr->center = VALUE_TO_CVPOINT2D32F(center);
}
if (!NIL_P(size)) {
self_ptr->size = VALUE_TO_CVSIZE2D32F(size);
self_ptr->angle = NUM2DBL(angle);
}
return self;
}
|
Instance Method Details
#angle ⇒ Float
Returns angle of the box
113 114 115 116 117 |
# File 'ext/opencv/cvbox2d.cpp', line 113
VALUE
rb_angle(VALUE self)
{
return rb_float_new(CVBOX2D(self)->angle);
}
|
#angle= ⇒ CvBox2D
Set angle of the box
125 126 127 128 129 130 |
# File 'ext/opencv/cvbox2d.cpp', line 125
VALUE
rb_set_angle(VALUE self, VALUE value)
{
CVBOX2D(self)->angle = NUM2DBL(value);
return self;
}
|
#approx_chain(options) ⇒ CvSeq<CvPoint> Also known as: approx
Approximates Freeman chains with a polygonal curve
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'ext/opencv/cvchain.cpp', line 163
VALUE
rb_approx_chains(int argc, VALUE *argv, VALUE self)
{
VALUE approx_chain_option;
rb_scan_args(argc, argv, "01", &approx_chain_option);
approx_chain_option = APPROX_CHAIN_OPTION(approx_chain_option);
VALUE storage = cCvMemStorage::new_object();
CvSeq *seq = cvApproxChains(CVSEQ(self), CVMEMSTORAGE(storage),
APPROX_CHAIN_METHOD(approx_chain_option),
APPROX_CHAIN_PARAMETER(approx_chain_option),
APPROX_CHAIN_MINIMAL_PERIMETER(approx_chain_option),
APPROX_CHAIN_RECURSIVE(approx_chain_option));
if (seq && seq->total > 0) {
return cCvSeq::new_sequence(cCvChain::rb_class(), seq, cCvPoint::rb_class(), storage);
}
return Qnil;
}
|
#center ⇒ CvPoint2D32f
Returns center point of the box
65 66 67 68 69 |
# File 'ext/opencv/cvbox2d.cpp', line 65
VALUE
rb_center(VALUE self)
{
return REFER_OBJECT(cCvPoint2D32f::rb_class(), &CVBOX2D(self)->center, self);
}
|
#center= ⇒ CvBox2D
Set center point of the box
77 78 79 80 81 82 |
# File 'ext/opencv/cvbox2d.cpp', line 77
VALUE
rb_set_center(VALUE self, VALUE value)
{
CVBOX2D(self)->center = VALUE_TO_CVPOINT2D32F(value);
return self;
}
|
#codes ⇒ Array<Integer>
Returns the chain codes
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'ext/opencv/cvchain.cpp', line 102
VALUE
rb_codes(VALUE self)
{
CvChain *chain = CVCHAIN(self);
CvChainPtReader reader;
int total = chain->total;
VALUE ary = rb_ary_new2(total);
try {
cvStartReadChainPoints(chain, &reader);
for (int i = 0; i < total; ++i) {
CV_READ_SEQ_ELEM(reader.code, (*((CvSeqReader*)&(reader))));
rb_ary_store(ary, i, INT2FIX(reader.code));
}
}
catch (cv::Exception& e) {
raise_cverror(e);
}
return ary;
}
|
#origin ⇒ CvPoint
Returns Freeman chain code origin
76 77 78 79 80 |
# File 'ext/opencv/cvchain.cpp', line 76
VALUE
rb_origin(VALUE self)
{
return cCvPoint::new_object(CVCHAIN(self)->origin);
}
|
#origin= ⇒ CvChain
Set Freeman chain code origin
88 89 90 91 92 93 |
# File 'ext/opencv/cvchain.cpp', line 88
VALUE
rb_set_origin(VALUE self, VALUE origin)
{
CVCHAIN(self)->origin = VALUE_TO_CVPOINT(origin);
return self;
}
|
#points ⇒ Array<CvPoint>
Returns the points of the chain codes
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'ext/opencv/cvbox2d.cpp', line 138
VALUE
rb_points(VALUE self)
{
const int n = 4;
CvPoint2D32f p[n];
try {
cvBoxPoints(*CVBOX2D(self), p);
}
catch (cv::Exception& e) {
raise_cverror(e);
}
VALUE points = rb_ary_new2(n);
for (int i = 0; i < n; ++i) {
rb_ary_store(points, i, cCvPoint2D32f::new_object(p[i]));
}
return points;
}
|
#size ⇒ CvSize2D32f
Returns size of the box
89 90 91 92 93 |
# File 'ext/opencv/cvbox2d.cpp', line 89
VALUE
rb_size(VALUE self)
{
return REFER_OBJECT(cCvSize2D32f::rb_class(), &CVBOX2D(self)->size, self);
}
|
#size= ⇒ CvBox2D
Set size of the box
101 102 103 104 105 106 |
# File 'ext/opencv/cvbox2d.cpp', line 101
VALUE
rb_set_size(VALUE self, VALUE value)
{
CVBOX2D(self)->size = VALUE_TO_CVSIZE2D32F(value);
return self;
}
|