Module: OpenCV::Curve

Included in:
CvBox2D, CvCapture
Defined in:
ext/opencv/curve.cpp,
ext/opencv/cvchain.cpp,
ext/opencv/cvcontour.cpp

Instance Method Summary collapse

Instance Method Details

#arc_length(slice = nil, is_closed = nil) ⇒ Number

Calculates length of a curve

Parameters:

  • slice (Range, CvSlice, nil) (defaults to: nil)

    Starting and ending points of the curve. By default, the whole curve length is calculated.

  • is_closed (Boolean, nil) (defaults to: nil)

    Indicates whether the curve is closed or not. There are 3 cases:

    • is_closed = true - the curve is assumed to be unclosed.

    • is_closed = false - the curve is assumed to be closed.

    • is_closed = nil (default) use self#closed?

Returns:

  • (Number)

    Length of the curve



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'ext/opencv/curve.cpp', line 88

VALUE
rb_arc_length(int argc, VALUE *argv, VALUE self)
{
  VALUE slice, is_closed;
  rb_scan_args(argc, argv, "02", &slice, &is_closed);
  double length = 0;
  try {
    length = cvArcLength(CVARR(self),
			 NIL_P(slice) ? CV_WHOLE_SEQ : VALUE_TO_CVSLICE(slice),
			 TRUE_OR_FALSE(is_closed, -1));
  }
  catch (cv::Exception& e) {
    raise_cverror(e);
  }
  return rb_float_new(length);
}

#closed?Boolean

If the curve is closed, return true. Otherwise return false.

Returns:

  • (Boolean)

    Closed or not



33
34
35
36
37
# File 'ext/opencv/curve.cpp', line 33

VALUE
rb_closed_q(VALUE self)
{
  return CV_IS_SEQ_CLOSED(CVSEQ(self)) ? Qtrue : Qfalse;
}

#convex?Boolean

If the curve is convex, return true. Otherwise return false.

Returns:

  • (Boolean)

    Convex or not



45
46
47
48
49
# File 'ext/opencv/curve.cpp', line 45

VALUE
rb_convex_q(VALUE self)
{
  return CV_IS_SEQ_CONVEX(CVSEQ(self)) ? Qtrue : Qfalse;
}

#hole?Boolean

If the curve is hole(inner contour), return true. Otherwise return false.

Returns:

  • (Boolean)

    Hole or not



57
58
59
60
61
# File 'ext/opencv/curve.cpp', line 57

VALUE
rb_hole_q(VALUE self)
{  
  return CV_IS_SEQ_HOLE(CVSEQ(self)) ? Qtrue : Qfalse;
}

#simple?Boolean

If the curve is simple, return true. Otherwise return false.

Returns:

  • (Boolean)

    Simple or not



69
70
71
72
73
# File 'ext/opencv/curve.cpp', line 69

VALUE
rb_simple_q(VALUE self)
{
  return CV_IS_SEQ_SIMPLE(CVSEQ(self)) ? Qtrue : Qfalse;
}