Skip to content

Commit 9196cb1

Browse files
committed
Initial commit, with some minor changes from orig (date, exec bit, line endings, /usr/bin/env)
0 parents  commit 9196cb1

File tree

117 files changed

+16536
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+16536
-0
lines changed

History.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== 0.0.6 / 2008-06-27
2+
3+
* First gem release.
4+
5+
* Some OpenCV function wrapped.

License.txt

+30
Original file line numberDiff line numberDiff line change
@@ -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.

Manifest.txt

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
History.txt
2+
Manifest.txt
3+
README.txt
4+
License.txt
5+
Rakefile
6+
examples/convexhull.rb
7+
examples/face_detect.rb
8+
examples/houghcircle.rb
9+
examples/inpaint.png
10+
examples/inpaint.rb
11+
examples/paint.rb
12+
examples/snake.rb
13+
examples/stuff.jpg
14+
ext/curve.cpp
15+
ext/curve.h
16+
ext/cvavgcomp.cpp
17+
ext/cvavgcomp.h
18+
ext/cvbox2d.cpp
19+
ext/cvbox2d.h
20+
ext/cvcapture.cpp
21+
ext/cvcapture.h
22+
ext/cvchain.cpp
23+
ext/cvchain.h
24+
ext/cvchaincode.cpp
25+
ext/cvchaincode.h
26+
ext/cvcircle32f.cpp
27+
ext/cvcircle32f.h
28+
ext/cvcondensation.cpp
29+
ext/cvcondensation.h
30+
ext/cvconnectedcomp.cpp
31+
ext/cvconnectedcomp.h
32+
ext/cvcontour.cpp
33+
ext/cvcontour.h
34+
ext/cvcontourtree.cpp
35+
ext/cvcontourtree.h
36+
ext/cvconvexitydefect.cpp
37+
ext/cvconvexitydefect.h
38+
ext/cverror.cpp
39+
ext/cverror.h
40+
ext/cvfont.cpp
41+
ext/cvfont.h
42+
ext/cvhaarclassifiercascade.cpp
43+
ext/cvhaarclassifiercascade.h
44+
ext/cvhistogram.cpp
45+
ext/cvhistogram.h
46+
ext/cvindex.cpp
47+
ext/cvindex.h
48+
ext/cvline.cpp
49+
ext/cvline.h
50+
ext/cvmat.cpp
51+
ext/cvmat.h
52+
ext/cvmatnd.cpp
53+
ext/cvmatnd.h
54+
ext/cvmemstorage.cpp
55+
ext/cvmemstorage.h
56+
ext/cvmoments.cpp
57+
ext/cvmoments.h
58+
ext/cvpoint.cpp
59+
ext/cvpoint.h
60+
ext/cvpoint2d32f.cpp
61+
ext/cvpoint2d32f.h
62+
ext/cvpoint3d32f.cpp
63+
ext/cvpoint3d32f.h
64+
ext/cvrect.cpp
65+
ext/cvrect.h
66+
ext/cvscalar.cpp
67+
ext/cvscalar.h
68+
ext/cvseq.cpp
69+
ext/cvseq.h
70+
ext/cvset.cpp
71+
ext/cvset.h
72+
ext/cvsize.cpp
73+
ext/cvsize.h
74+
ext/cvsize2d32f.cpp
75+
ext/cvsize2d32f.h
76+
ext/cvslice.cpp
77+
ext/cvslice.h
78+
ext/cvsparsemat.cpp
79+
ext/cvsparsemat.h
80+
ext/cvtermcriteria.cpp
81+
ext/cvtermcriteria.h
82+
ext/cvtwopoints.cpp
83+
ext/cvtwopoints.h
84+
ext/cvvector.cpp
85+
ext/cvvector.h
86+
ext/cvvideowriter.cpp
87+
ext/cvvideowriter.h
88+
ext/extconf.rb
89+
ext/gui.cpp
90+
ext/gui.h
91+
ext/iplconvkernel.cpp
92+
ext/iplconvkernel.h
93+
ext/iplimage.cpp
94+
ext/iplimage.h
95+
ext/mouseevent.cpp
96+
ext/mouseevent.h
97+
ext/opencv.cpp
98+
ext/opencv.h
99+
ext/point3dset.cpp
100+
ext/point3dset.h
101+
ext/pointset.cpp
102+
ext/pointset.h
103+
ext/trackbar.cpp
104+
ext/trackbar.h
105+
ext/window.cpp
106+
ext/window.h
107+
images/CvMat_sobel.png
108+
images/CvMat_sub_rect.png
109+
images/CvSeq_relationmap.png
110+
images/face_detect_from_lena.jpg
111+
lib/opencv.rb
112+
lib/version.rb
113+
setup/setup.cygwin.rb
114+
setup/setup.mingw.rb
115+
setup/setup.mswin32.rb

README.txt

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
17+
== SYNOPSIS:
18+
19+
# Show image via GUI Window.
20+
21+
require "rubygems"
22+
gem "opencv"
23+
require "opencv"
24+
25+
image = OpenCV::IplImage.load("sample.jpg")
26+
window = OpenCV::GUI::Window.new("preview")
27+
window.show(image)
28+
OpenCV::GUI::wait_key
29+
30+
# other sample code, see examples/*.rb
31+
32+
== REQUIREMENTS:
33+
34+
* OpenCV 1.0 or later.
35+
http://sourceforge.net/projects/opencvlibrary/
36+
* ffcall (optional)
37+
http://www.haible.de/bruno/packages-ffcall.html
38+
39+
== INSTALL:
40+
41+
gem install opencv
42+
43+
== LICENSE:
44+
45+
The BSD Liscense
46+
47+
see LICENSE.txt

Rakefile

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- ruby -*-
2+
3+
require 'rubygems'
4+
require 'hoe'
5+
require './lib/version'
6+
7+
Hoe.new('opencv', OpenCV::VERSION) do |p|
8+
p.author = ['Masakazu Yonekura']
9+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
10+
p.description = <<EOF
11+
OpenCV wrapper for Ruby
12+
EOF
13+
p.rubyforge_name = 'opencv'
14+
p.developer('lsxi', '[email protected]')
15+
p.email = ['[email protected]']
16+
17+
p.need_tar = false
18+
p.need_zip = false
19+
# p.rdoc_pattern =
20+
# p.remote_rdoc_dir =
21+
# p.rsync =
22+
p.spec_extras = {
23+
:extensions => %w{ext/extconf.rb}
24+
}
25+
p.summary = 'OpenCV wrapper for Ruby.'
26+
# p.test_globs = 'spec/**/*_spec.rb'
27+
p.clean_globs |= ['*.o']
28+
29+
p.url = 'http://blueruby.mydns.jp/opencv'
30+
31+
p.extra_deps << ['hoe']
32+
end
33+
34+
# vim: syntax=Ruby

examples/convexhull.rb

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env ruby
2+
# convexhull.rb
3+
gem "opencv"
4+
require "opencv"
5+
require "pp"
6+
include OpenCV
7+
8+
window = GUI::Window.new("convexhull")
9+
pp CvCapture::INTERFACE
10+
capture = CvCapture::open
11+
12+
accuracy = 0.1
13+
t = window.set_trackbar("accuracy", 100, 1){|v|
14+
accuracy = 0.1 * v
15+
}
16+
17+
while true
18+
key = GUI::wait_key(1)
19+
image = capture.query
20+
gray = image.BGR2GRAY
21+
bin = gray.threshold_binary(0x44, 0xFF)
22+
contours = bin.find_contours
23+
while contours
24+
image.poly_line! contours.approx(:accuracy => accuracy), :color => CvScalar::Red
25+
contours.convexity_defects.each{|cd|
26+
image.circle! cd.start, 1, :color => CvScalar::Blue
27+
image.circle! cd.end, 1, :color => CvScalar::Blue
28+
image.circle! cd.depth_point, 1, :color => CvScalar::Blue
29+
}
30+
31+
contours = contours.h_next
32+
end
33+
#pts = gray.good_features_to_track(0.01, 10)
34+
#puts pts.length
35+
window.show image
36+
next unless key
37+
case key.chr
38+
when "\e"
39+
exit
40+
end
41+
end

examples/face_detect.rb

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env ruby
2+
# face_detect.rb
3+
require "rubygems"
4+
gem "opencv"
5+
require "opencv"
6+
7+
include OpenCV
8+
9+
window = GUI::Window.new("face detect")
10+
capture = CvCapture.open
11+
detector = CvHaarClassifierCascade::load("C:/Program Files/OpenCV/data/haarcascades/haarcascade_frontalface_alt.xml")
12+
13+
while true
14+
key = GUI::wait_key(1)
15+
image = capture.query
16+
detector.detect_objects(image){|i|
17+
image.rectangle! i.top_left, i.bottom_right, :color => CvColor::Red
18+
}
19+
window.show image
20+
next unless key
21+
case key.chr
22+
when "\e"
23+
exit
24+
end
25+
end

examples/houghcircle.rb

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env ruby
2+
# houghcircle.rb
3+
require "rubygems"
4+
gem "opencv"
5+
require "opencv"
6+
include OpenCV
7+
8+
original_window = GUI::Window.new "original"
9+
hough_window = GUI::Window.new "hough circles"
10+
11+
image = IplImage::load "stuff.jpg"
12+
gray = image.BGR2GRAY
13+
14+
result = image.clone
15+
original_window.show image
16+
detect = gray.hough_circles_gradient(2.0, 10, 200, 50)
17+
puts detect.size
18+
detect.each{|circle|
19+
puts "#{circle.center.x},#{circle.center.y} - #{circle.radius}"
20+
result.circle! circle.center, circle.radius, :color => CvColor::Red, :thickness => 3
21+
}
22+
hough_window.show result
23+
GUI::wait_key

examples/inpaint.png

+2
Loading

examples/inpaint.rb

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env ruby
2+
# inpaint.rb
3+
require "rubygems"
4+
gem "opencv"
5+
require "opencv"
6+
7+
include OpenCV
8+
9+
owindow = GUI::Window.new "original"
10+
mwindow = GUI::Window.new "mask"
11+
iwindow = GUI::Window.new "inpaint"
12+
13+
image = IplImage::load "inpaint.png"
14+
b, g, r = image.split
15+
original_mask = r.threshold_binary_inverse(0x00, 0xFF) & b.threshold_binary_inverse(0x00, 0xFF)
16+
mask = original_mask.copy
17+
18+
num_dilate = 3
19+
radius = 5
20+
dilate_bar = mwindow.set_trackbar("dilate", 10, num_dilate){|v|
21+
num_dilate = v
22+
mask = original_mask.dilate(nil, num_dilate)
23+
mwindow.show mask
24+
}
25+
26+
radius_bar = mwindow.set_trackbar("radius", 30, radius){|v|
27+
radius = v
28+
}
29+
30+
owindow.show image
31+
mwindow.show mask
32+
33+
while key = GUI::wait_key
34+
case key.chr
35+
when "\e" # esc
36+
exit
37+
when "n"
38+
iwindow.show image.inpaint_ns(mask, radius)
39+
when "t"
40+
iwindow.show image.inpaint_telea(mask, radius)
41+
end
42+
end
43+

0 commit comments

Comments
 (0)