bantic-ruby-opencv 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. data/CHANGELOG +2 -0
  2. data/License.txt +30 -0
  3. data/README.rdoc +90 -0
  4. data/Rakefile +15 -0
  5. data/examples/convexhull.rb +47 -0
  6. data/examples/face_detect.rb +24 -0
  7. data/examples/houghcircle.rb +23 -0
  8. data/examples/inpaint.png +0 -0
  9. data/examples/inpaint.rb +42 -0
  10. data/examples/paint.rb +71 -0
  11. data/examples/snake.rb +42 -0
  12. data/examples/stuff.jpg +0 -0
  13. data/ext/curve.cpp +103 -0
  14. data/ext/curve.h +34 -0
  15. data/ext/cvavgcomp.cpp +67 -0
  16. data/ext/cvavgcomp.h +39 -0
  17. data/ext/cvbox2d.cpp +114 -0
  18. data/ext/cvbox2d.h +53 -0
  19. data/ext/cvcapture.cpp +276 -0
  20. data/ext/cvcapture.h +54 -0
  21. data/ext/cvchain.cpp +184 -0
  22. data/ext/cvchain.h +43 -0
  23. data/ext/cvchaincode.cpp +49 -0
  24. data/ext/cvchaincode.h +43 -0
  25. data/ext/cvcircle32f.cpp +90 -0
  26. data/ext/cvcircle32f.h +53 -0
  27. data/ext/cvcondensation.cpp +230 -0
  28. data/ext/cvcondensation.h +49 -0
  29. data/ext/cvconnectedcomp.cpp +115 -0
  30. data/ext/cvconnectedcomp.h +46 -0
  31. data/ext/cvcontour.cpp +217 -0
  32. data/ext/cvcontour.h +47 -0
  33. data/ext/cvcontourtree.cpp +86 -0
  34. data/ext/cvcontourtree.h +41 -0
  35. data/ext/cvconvexitydefect.cpp +103 -0
  36. data/ext/cvconvexitydefect.h +42 -0
  37. data/ext/cverror.cpp +140 -0
  38. data/ext/cverror.h +79 -0
  39. data/ext/cvfont.cpp +173 -0
  40. data/ext/cvfont.h +56 -0
  41. data/ext/cvhaarclassifiercascade.cpp +159 -0
  42. data/ext/cvhaarclassifiercascade.h +41 -0
  43. data/ext/cvhistogram.cpp +200 -0
  44. data/ext/cvhistogram.h +51 -0
  45. data/ext/cvindex.cpp +73 -0
  46. data/ext/cvindex.h +40 -0
  47. data/ext/cvline.cpp +106 -0
  48. data/ext/cvline.h +52 -0
  49. data/ext/cvmat.cpp +4809 -0
  50. data/ext/cvmat.h +286 -0
  51. data/ext/cvmatnd.cpp +44 -0
  52. data/ext/cvmatnd.h +28 -0
  53. data/ext/cvmemstorage.cpp +64 -0
  54. data/ext/cvmemstorage.h +53 -0
  55. data/ext/cvmoments.cpp +204 -0
  56. data/ext/cvmoments.h +48 -0
  57. data/ext/cvpoint.cpp +229 -0
  58. data/ext/cvpoint.h +59 -0
  59. data/ext/cvpoint2d32f.cpp +213 -0
  60. data/ext/cvpoint2d32f.h +61 -0
  61. data/ext/cvpoint3d32f.cpp +245 -0
  62. data/ext/cvpoint3d32f.h +64 -0
  63. data/ext/cvrect.cpp +340 -0
  64. data/ext/cvrect.h +79 -0
  65. data/ext/cvscalar.cpp +227 -0
  66. data/ext/cvscalar.h +63 -0
  67. data/ext/cvseq.cpp +583 -0
  68. data/ext/cvseq.h +71 -0
  69. data/ext/cvset.cpp +63 -0
  70. data/ext/cvset.h +39 -0
  71. data/ext/cvsize.cpp +223 -0
  72. data/ext/cvsize.h +63 -0
  73. data/ext/cvsize2d32f.cpp +180 -0
  74. data/ext/cvsize2d32f.h +59 -0
  75. data/ext/cvslice.cpp +82 -0
  76. data/ext/cvslice.h +53 -0
  77. data/ext/cvsparsemat.cpp +44 -0
  78. data/ext/cvsparsemat.h +28 -0
  79. data/ext/cvtermcriteria.cpp +183 -0
  80. data/ext/cvtermcriteria.h +71 -0
  81. data/ext/cvtwopoints.cpp +98 -0
  82. data/ext/cvtwopoints.h +50 -0
  83. data/ext/cvvector.cpp +206 -0
  84. data/ext/cvvector.h +54 -0
  85. data/ext/cvvideowriter.cpp +116 -0
  86. data/ext/cvvideowriter.h +41 -0
  87. data/ext/extconf.rb +58 -0
  88. data/ext/gui.cpp +65 -0
  89. data/ext/gui.h +33 -0
  90. data/ext/iplconvkernel.cpp +177 -0
  91. data/ext/iplconvkernel.h +52 -0
  92. data/ext/iplimage.cpp +238 -0
  93. data/ext/iplimage.h +54 -0
  94. data/ext/mouseevent.cpp +184 -0
  95. data/ext/mouseevent.h +59 -0
  96. data/ext/opencv.cpp +481 -0
  97. data/ext/opencv.h +356 -0
  98. data/ext/point3dset.cpp +41 -0
  99. data/ext/point3dset.h +31 -0
  100. data/ext/pointset.cpp +238 -0
  101. data/ext/pointset.h +69 -0
  102. data/ext/trackbar.cpp +122 -0
  103. data/ext/trackbar.h +65 -0
  104. data/ext/window.cpp +368 -0
  105. data/ext/window.h +56 -0
  106. data/images/CvMat_sobel.png +0 -0
  107. data/images/CvMat_sub_rect.png +0 -0
  108. data/images/CvSeq_relationmap.png +0 -0
  109. data/images/face_detect_from_lena.jpg +0 -0
  110. data/lib/opencv.rb +3 -0
  111. data/lib/version.rb +3 -0
  112. data/metadata +191 -0
  113. data/ruby-opencv.gemspec +33 -0
  114. data/setup/setup.cygwin.rb +120 -0
  115. data/setup/setup.mingw.rb +99 -0
  116. data/setup/setup.mswin32.rb +103 -0
  117. data/test/test_opencv.rb +6 -0
  118. metadata +272 -0
@@ -0,0 +1,2 @@
1
+ v0.0.7. Moving to Echoe and github
2
+ v0.0.6. Some OpenCV function wrapped.
@@ -0,0 +1,30 @@
1
+ The BSD Liscense
2
+
3
+ Copyright (c) 2008, Masakazu Yonekura
4
+ All rights reserved.
5
+
6
+ Redistribution and use of this software in source and binary forms, with or without modification, are
7
+ permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above
10
+ copyright notice, this list of conditions and the
11
+ following disclaimer.
12
+
13
+ * Redistributions in binary form must reproduce the above
14
+ copyright notice, this list of conditions and the
15
+ following disclaimer in the documentation and/or other
16
+ materials provided with the distribution.
17
+
18
+ * Neither the name of Masakazu Yonekura. nor the names of its
19
+ contributors may be used to endorse or promote products
20
+ derived from this software without specific prior
21
+ written permission of Masakazu Yonekura.
22
+
23
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
29
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,90 @@
1
+ = opencv
2
+
3
+ OpenCV Sourceforge Project
4
+ http://sourceforge.net/projects/opencvlibrary/
5
+
6
+ Ruby/OpenCV Author's Web Page
7
+ http://blueruby.mydns.jp/opencv
8
+
9
+ == DESCRIPTION:
10
+
11
+ OpenCV Ruby Wrapper
12
+
13
+ == FEATURES/PROBLEMS:
14
+
15
+ * First release rubygems, Some OpenCV function wrapped.
16
+ * Use of Carbon windows on Mac OS X is a little buggy, especially when called from the command line.
17
+ * Sadly, use of X Windows as an alternative on Mac OS X is similarly buggy.
18
+
19
+ == REQUIREMENTS:
20
+
21
+ * OpenCV 1.0 or later.
22
+ http://sourceforge.net/projects/opencvlibrary/
23
+ * OpenCV has several dependencies, see INSTALLATION INSTRUCTIONS below
24
+ * ffcall (optional)
25
+ http://www.haible.de/bruno/packages-ffcall.html
26
+
27
+ == INSTALLATION INSTRUCTIONS
28
+
29
+ * OpenCV is a requirement. Unfortunately there's a bug in the code that affects our ability to use Carbon windows, so we can't install from a port. We'll have to install from source.
30
+ * First, these are the dependencies we'll need:
31
+ * atk
32
+ * pango
33
+ * jpeg
34
+ * tiff
35
+ * libpng
36
+ * pkgconfig
37
+ * gtk2
38
+ * glib2
39
+ * ffcall
40
+ * Use ports to install them:
41
+ $ sudo port install atk pango jpeg tiff libpng pkgconfig gtk2 glib2 ffcall
42
+ * Ports is going to install them in /opt/local, which is where this gem will go looking for ffcall, so that will work well for us.
43
+
44
+ * Next, download version 1.1pre1 of the opencv-linux package here: https://sourceforge.net/project/showfiles.php?group_id=22870
45
+ * Navigate to where you downloaded it and:
46
+ tar xzvf opencv-1.1pre1.tar.gz
47
+ cd opencv-1.1.0/
48
+ * Important: Before we configure and build, we need to fix a small bug in the code. Open up the file otherlibs/highgui/window_carbon.cpp in a text editor and make this change to line 645:
49
+
50
+ return NULL;
51
+ should be changed to
52
+ return result;
53
+ (This bug is tracked in sourceforge here: https://sourceforge.net/tracker/index.php?func=detail&aid=2668857&group_id=22870&atid=376677)
54
+ * Now save the file and we can continue.
55
+ ./configure --with-carbon=yes CPPFLAGS="-I/opt/local/include -I/usr/include/malloc" LDFLAGS=-L/opt/local/lib
56
+ After configure runs, it will print out a display showing which libraries are in use. Double-check that the windowing system is using "Carbon/Mac OS X" and not gtk
57
+ Finish installing:
58
+ make
59
+ sudo make install
60
+ The last of the output from the install command will probably complain about not being able to find ldconfig. That's fine. You're on a Mac; you don't need ldconfig (http://macosx.com/forums/mac-os-x-system-mac-software/5200-ldconfig.html).
61
+
62
+ * Now install the gem
63
+ sudo gem install bantic-ruby-opencv
64
+
65
+ * Check your work:
66
+ $ irb
67
+ irb> require 'rubygems'
68
+ => true
69
+ irb> require 'opencv'
70
+ => true
71
+
72
+ == SYNOPSIS:
73
+
74
+ # Show image via GUI Window.
75
+
76
+ require "rubygems"
77
+ require "opencv"
78
+
79
+ image = OpenCV::IplImage.load("sample.jpg")
80
+ window = OpenCV::GUI::Window.new("preview")
81
+ window.show(image)
82
+ OpenCV::GUI::wait_key
83
+
84
+ # other sample code, see examples/*.rb
85
+
86
+ == LICENSE:
87
+
88
+ The BSD Liscense
89
+
90
+ see LICENSE.txt
@@ -0,0 +1,15 @@
1
+ # Rakefile
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'echoe'
5
+
6
+ Echoe.new('ruby-opencv', '0.0.7') do |p|
7
+ p.description = "OpenCV wrapper for Ruby."
8
+ p.url = "http://github.com/adamb/ruby-opencv"
9
+ p.author = "Masakazu Yonekura"
10
+ p.email = "masakazu.yonekura@gmail.com"
11
+ p.ignore_pattern = ["tmp/*", "script/*", "ext/*.o"]
12
+ p.development_dependencies = []
13
+ end
14
+
15
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+ # convexhull.rb
3
+
4
+ require 'rubygems'
5
+ require "opencv"
6
+ require "pp"
7
+ include OpenCV
8
+
9
+ window = GUI::Window.new("thewindow", true)
10
+ pp CvCapture::INTERFACE
11
+ capture = CvCapture::open
12
+
13
+ accuracy = 0.1
14
+ t = window.set_trackbar("accuracy", 100, 1){|v|
15
+ accuracy = 0.1 * v
16
+ }
17
+
18
+ while true
19
+ key = GUI::wait_key(1)
20
+ image = capture.query
21
+ gray = image.BGR2GRAY
22
+ bin = gray.threshold_binary(0x44, 0xFF)
23
+ contours = bin.find_contours
24
+ while contours
25
+ approx_contours = contours.approx_poly(:accuracy => accuracy)
26
+ if approx_contours.nil?
27
+ puts "No approx contours for accuracy #{accuracy}"
28
+ approx_contours = contours
29
+ end
30
+ image.poly_line! approx_contours, :color => CvScalar::Red
31
+ approx_contours.convexity_defects.each{|cd|
32
+ image.circle! cd.start, 1, :color => CvScalar::Blue
33
+ image.circle! cd.end, 1, :color => CvScalar::Blue
34
+ image.circle! cd.depth_point, 1, :color => CvScalar::Blue
35
+ }
36
+
37
+ contours = contours.h_next
38
+ end
39
+ #pts = gray.good_features_to_track(0.01, 10)
40
+ #puts pts.length
41
+ window.show image
42
+ next unless key
43
+ case key.chr
44
+ when "\e"
45
+ exit
46
+ end
47
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ # face_detect.rb
3
+ require "rubygems"
4
+ require "opencv"
5
+
6
+ include OpenCV
7
+
8
+ window = GUI::Window.new("thewindow")
9
+ capture = CvCapture.open
10
+ detector = CvHaarClassifierCascade::load("haarcascade_frontalface_alt.xml")
11
+
12
+ while true
13
+ key = GUI::wait_key(1)
14
+ image = capture.query
15
+ detector.detect_objects(image){|i|
16
+ image.rectangle! i.top_left, i.bottom_right, :color => CvColor::Red
17
+ }
18
+ window.show image
19
+ next unless key
20
+ case key.chr
21
+ when "\e"
22
+ exit
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ # houghcircle.rb
3
+ require "rubygems"
4
+ require "opencv"
5
+ include OpenCV
6
+
7
+ original_window = GUI::Window.new "thewindow"
8
+ # hough_window = GUI::Window.new "hough circles"
9
+
10
+ image = IplImage::load "stuff.jpg"
11
+ gray = image.BGR2GRAY
12
+
13
+ result = image.clone
14
+ original_window.show image
15
+ detect = gray.hough_circles_gradient(2.0, 10, 200, 50)
16
+ puts detect.size
17
+ detect.each{|circle|
18
+ puts "#{circle.center.x},#{circle.center.y} - #{circle.radius}"
19
+ result.circle! circle.center, circle.radius, :color => CvColor::Red, :thickness => 3
20
+ }
21
+ GUI::wait_key
22
+ original_window.show result
23
+ GUI::wait_key
Binary file
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+ # inpaint.rb
3
+ require "rubygems"
4
+ require "opencv"
5
+
6
+ include OpenCV
7
+
8
+ owindow = GUI::Window.new "original"
9
+ mwindow = GUI::Window.new "mask"
10
+ iwindow = GUI::Window.new "inpaint"
11
+
12
+ image = IplImage::load "inpaint.png"
13
+ b, g, r = image.split
14
+ original_mask = r.threshold_binary_inverse(0x00, 0xFF) & b.threshold_binary_inverse(0x00, 0xFF)
15
+ mask = original_mask.copy
16
+
17
+ num_dilate = 3
18
+ radius = 5
19
+ dilate_bar = mwindow.set_trackbar("dilate", 10, num_dilate){|v|
20
+ num_dilate = v
21
+ mask = original_mask.dilate(nil, num_dilate)
22
+ mwindow.show mask
23
+ }
24
+
25
+ radius_bar = mwindow.set_trackbar("radius", 30, radius){|v|
26
+ radius = v
27
+ }
28
+
29
+ owindow.show image
30
+ mwindow.show mask
31
+
32
+ while key = GUI::wait_key
33
+ case key.chr
34
+ when "\e" # esc
35
+ exit
36
+ when "n"
37
+ iwindow.show image.inpaint_ns(mask, radius)
38
+ when "t"
39
+ iwindow.show image.inpaint_telea(mask, radius)
40
+ end
41
+ end
42
+
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+ # paint.rb
3
+ require "rubygems"
4
+ require "opencv"
5
+
6
+ include OpenCV
7
+
8
+ window = GUI::Window.new("thewindow")
9
+ canvas = CvMat.new(500, 500, 0, 3).fill!(0xFF) # create white canvas
10
+ window.show canvas
11
+
12
+ colors = CvColor::constants.collect{|i| i.to_s }
13
+
14
+ usage =<<USAGE
15
+ [mouse]
16
+ drag - draw
17
+ right button - fill by color
18
+ [keyborad]
19
+ 1 to 9 - change thickness of line
20
+ type color name - change color
21
+ esc - exit
22
+ USAGE
23
+ puts usage
24
+
25
+ point = nil
26
+
27
+ # drawing option
28
+ opt = {
29
+ :color => CvColor::Black,
30
+ :tickness => 1
31
+ }
32
+
33
+ window.on_mouse{|m|
34
+ case m.event
35
+ when :move
36
+ if m.left_button?
37
+ canvas.line!(point, m, opt) if point
38
+ point = m
39
+ end
40
+ when :left_button_down
41
+ canvas.line!(m, m, opt)
42
+ point = m
43
+ when :left_button_up
44
+ point = nil
45
+ when :right_button_down
46
+ mask = canvas.flood_fill!(m, opt[:color])
47
+ end
48
+ window.show canvas
49
+ }
50
+
51
+ color_name = ''
52
+ while key = GUI.wait_key
53
+ next if key < 0
54
+ case key.chr
55
+ when "\e" # [esc] - exit
56
+ exit
57
+ when '1'..'9'
58
+ puts "change thickness to #{key.chr.to_i}."
59
+ opt[:thickness] = key.chr.to_i
60
+ else
61
+ color_name << key.chr
62
+ choice = colors.find_all{|i| i =~ /\A#{color_name}/i}
63
+ if choice.size == 1
64
+ color,= choice
65
+ puts "change color to #{color}."
66
+ opt[:color] = CvColor::const_get(color)
67
+ end
68
+ color_name = '' if choice.length < 2
69
+ end
70
+ end
71
+
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+ # snake.rb
3
+ require "rubygems"
4
+ require "opencv"
5
+ include OpenCV
6
+
7
+ puts <<USAGE
8
+ usage:
9
+ left-click: set point
10
+ right-click: do snake
11
+ USAGE
12
+
13
+ window = GUI::Window.new "snake demo"
14
+ image = CvMat.new(256, 256, :cv8u, 1).clear!
15
+ image.circle!(CvPoint.new(128,128), 40, :color => CvColor::White, :thickness => -1)
16
+ display = image.GRAY2BGR
17
+
18
+ window.show display
19
+
20
+ points = []
21
+
22
+ window.on_mouse{|mouse|
23
+ case mouse.event
24
+ when :left_button_down
25
+ display[mouse.x, mouse.y] = CvColor::Red
26
+ puts "set point (#{mouse.x},#{mouse.y})"
27
+ points << CvPoint.new(mouse.x, mouse.y)
28
+ window.show display
29
+ when :right_button_down
30
+ if points.length < 3
31
+ puts "please set more point!"
32
+ next
33
+ end
34
+ points = image.snake_image(points, 1.0, 0.5, 1.5, CvSize.new(3, 3), 100)
35
+ display = image.GRAY2BGR
36
+ display.poly_line! points, :color => CvColor::Red, :is_closed => true
37
+ window.show display
38
+ end
39
+ }
40
+
41
+ GUI::wait_key
42
+
Binary file
@@ -0,0 +1,103 @@
1
+ /************************************************************
2
+
3
+ curve.cpp -
4
+
5
+ $Author: lsxi $
6
+
7
+ Copyright (C) 2005 Masakazu Yonekura
8
+
9
+ ************************************************************/
10
+ #include"curve.h"
11
+ /*
12
+ * Document-class: OpenCV::Curve
13
+ *
14
+ * Curve sequence.
15
+ */
16
+ __NAMESPACE_BEGIN_OPENCV
17
+ __NAMESPACE_BEGIN_CURVE
18
+
19
+ VALUE module;
20
+
21
+ VALUE
22
+ rb_module()
23
+ {
24
+ return module;
25
+ }
26
+
27
+ void
28
+ define_ruby_module()
29
+ {
30
+ if(module)
31
+ return;
32
+ /*
33
+ * opencv = rb_define_module("OpenCV");
34
+ *
35
+ * note: this comment is used by rdoc.
36
+ */
37
+ VALUE opencv = rb_module_opencv();
38
+ module = rb_define_module_under(opencv, "Curve");
39
+ rb_define_method(module, "close?", RUBY_METHOD_FUNC(rb_closed_q), 0);
40
+ rb_define_method(module, "convex?", RUBY_METHOD_FUNC(rb_convex_q), 0);
41
+ rb_define_method(module, "hole?", RUBY_METHOD_FUNC(rb_hole_q), 0);
42
+ rb_define_method(module, "simple?", RUBY_METHOD_FUNC(rb_simple_q), 0);
43
+ rb_define_method(module, "arc_length", RUBY_METHOD_FUNC(rb_arc_length), -1);
44
+ }
45
+
46
+ /*
47
+ * If curve is closed, return true. Otherwise return false.
48
+ */
49
+ VALUE
50
+ rb_closed_q(VALUE self)
51
+ {
52
+ return CV_IS_SEQ_CLOSED(CVSEQ(self)) ? Qtrue : Qfalse;
53
+ }
54
+
55
+ /*
56
+ * If curve is convex, return true. Otherwise return false.
57
+ */
58
+ VALUE
59
+ rb_convex_q(VALUE self)
60
+ {
61
+ return CV_IS_SEQ_CONVEX(CVSEQ(self)) ? Qtrue : Qfalse;
62
+ }
63
+
64
+ /*
65
+ * If curve is hole(inner contour), return true. Otherwise return false.
66
+ */
67
+ VALUE
68
+ rb_hole_q(VALUE self)
69
+ {
70
+ return CV_IS_SEQ_HOLE(CVSEQ(self)) ? Qtrue : Qfalse;
71
+ }
72
+
73
+ /*
74
+ * no idia.
75
+ */
76
+ VALUE
77
+ rb_simple_q(VALUE self)
78
+ {
79
+ return CV_IS_SEQ_SIMPLE(CVSEQ(self)) ? Qtrue : Qfalse;
80
+ }
81
+
82
+ /*
83
+ * call-seq:
84
+ * arc_length(<i>[slice = nil][,is_closed = nil]</i>) -> float
85
+ *
86
+ * Calculates contour perimeter or curve length.
87
+ * <i>slice</i> is starting and ending points of the curve.
88
+ * <i>is_closed</i> is indicates whether the curve is closed or not. There are 3 cases:
89
+ * * is_closed = true - the curve is assumed to be unclosed.
90
+ * * is_closed = false - the curve is assumed to be closed.
91
+ * * is_closed = nil (default) use self#close?
92
+ */
93
+ VALUE
94
+ rb_arc_length(int argc, VALUE *argv, VALUE self)
95
+ {
96
+ VALUE slice, is_closed;
97
+ rb_scan_args(argc, argv, "02", &slice, &is_closed);
98
+ return rb_float_new(cvArcLength(CVARR(self), NIL_P(slice) ? CV_WHOLE_SEQ : VALUE_TO_CVSLICE(slice), TRUE_OR_FALSE(is_closed, -1)));
99
+ }
100
+
101
+ __NAMESPACE_END_CURVE
102
+ __NAMESPACE_END_OPENCV
103
+