Permalink
Browse files

Initial commit, with some minor changes from orig (date, exec bit, li…

…ne endings, /usr/bin/env)
  • Loading branch information...
ryanfb committed Aug 19, 2008
0 parents commit 9196cb13aa8e3ab4b58139c75ce7017e44a2d969
Showing with 16,536 additions and 0 deletions.
  1. +5 −0 History.txt
  2. +30 −0 License.txt
  3. +115 −0 Manifest.txt
  4. +47 −0 README.txt
  5. +34 −0 Rakefile
  6. +41 −0 examples/convexhull.rb
  7. +25 −0 examples/face_detect.rb
  8. +23 −0 examples/houghcircle.rb
  9. +2 −0 examples/inpaint.png
  10. +43 −0 examples/inpaint.rb
  11. +72 −0 examples/paint.rb
  12. +43 −0 examples/snake.rb
  13. +1 −0 examples/stuff.jpg
  14. +103 −0 ext/curve.cpp
  15. +34 −0 ext/curve.h
  16. +67 −0 ext/cvavgcomp.cpp
  17. +39 −0 ext/cvavgcomp.h
  18. +114 −0 ext/cvbox2d.cpp
  19. +53 −0 ext/cvbox2d.h
  20. +276 −0 ext/cvcapture.cpp
  21. +54 −0 ext/cvcapture.h
  22. +184 −0 ext/cvchain.cpp
  23. +43 −0 ext/cvchain.h
  24. +49 −0 ext/cvchaincode.cpp
  25. +43 −0 ext/cvchaincode.h
  26. +90 −0 ext/cvcircle32f.cpp
  27. +53 −0 ext/cvcircle32f.h
  28. +230 −0 ext/cvcondensation.cpp
  29. +49 −0 ext/cvcondensation.h
  30. +115 −0 ext/cvconnectedcomp.cpp
  31. +46 −0 ext/cvconnectedcomp.h
  32. +219 −0 ext/cvcontour.cpp
  33. +47 −0 ext/cvcontour.h
  34. +86 −0 ext/cvcontourtree.cpp
  35. +41 −0 ext/cvcontourtree.h
  36. +103 −0 ext/cvconvexitydefect.cpp
  37. +42 −0 ext/cvconvexitydefect.h
  38. +140 −0 ext/cverror.cpp
  39. +79 −0 ext/cverror.h
  40. +173 −0 ext/cvfont.cpp
  41. +56 −0 ext/cvfont.h
  42. +159 −0 ext/cvhaarclassifiercascade.cpp
  43. +41 −0 ext/cvhaarclassifiercascade.h
  44. +200 −0 ext/cvhistogram.cpp
  45. +51 −0 ext/cvhistogram.h
  46. +73 −0 ext/cvindex.cpp
  47. +40 −0 ext/cvindex.h
  48. +106 −0 ext/cvline.cpp
  49. +52 −0 ext/cvline.h
  50. +4,809 −0 ext/cvmat.cpp
  51. +286 −0 ext/cvmat.h
  52. +44 −0 ext/cvmatnd.cpp
  53. +28 −0 ext/cvmatnd.h
  54. +64 −0 ext/cvmemstorage.cpp
  55. +53 −0 ext/cvmemstorage.h
  56. +204 −0 ext/cvmoments.cpp
  57. +48 −0 ext/cvmoments.h
  58. +229 −0 ext/cvpoint.cpp
  59. +59 −0 ext/cvpoint.h
  60. +213 −0 ext/cvpoint2d32f.cpp
  61. +61 −0 ext/cvpoint2d32f.h
  62. +245 −0 ext/cvpoint3d32f.cpp
  63. +64 −0 ext/cvpoint3d32f.h
  64. +340 −0 ext/cvrect.cpp
  65. +79 −0 ext/cvrect.h
  66. +227 −0 ext/cvscalar.cpp
  67. +63 −0 ext/cvscalar.h
  68. +583 −0 ext/cvseq.cpp
  69. +71 −0 ext/cvseq.h
  70. +63 −0 ext/cvset.cpp
  71. +39 −0 ext/cvset.h
  72. +223 −0 ext/cvsize.cpp
  73. +63 −0 ext/cvsize.h
  74. +180 −0 ext/cvsize2d32f.cpp
  75. +59 −0 ext/cvsize2d32f.h
  76. +82 −0 ext/cvslice.cpp
  77. +53 −0 ext/cvslice.h
  78. +44 −0 ext/cvsparsemat.cpp
  79. +28 −0 ext/cvsparsemat.h
  80. +183 −0 ext/cvtermcriteria.cpp
  81. +71 −0 ext/cvtermcriteria.h
  82. +98 −0 ext/cvtwopoints.cpp
  83. +50 −0 ext/cvtwopoints.h
  84. +206 −0 ext/cvvector.cpp
  85. +54 −0 ext/cvvector.h
  86. +116 −0 ext/cvvideowriter.cpp
  87. +41 −0 ext/cvvideowriter.h
  88. +61 −0 ext/extconf.rb
  89. +65 −0 ext/gui.cpp
  90. +33 −0 ext/gui.h
  91. +177 −0 ext/iplconvkernel.cpp
  92. +52 −0 ext/iplconvkernel.h
  93. +238 −0 ext/iplimage.cpp
  94. +54 −0 ext/iplimage.h
  95. +184 −0 ext/mouseevent.cpp
  96. +59 −0 ext/mouseevent.h
  97. +481 −0 ext/opencv.cpp
  98. +356 −0 ext/opencv.h
  99. +41 −0 ext/point3dset.cpp
  100. +31 −0 ext/point3dset.h
  101. +238 −0 ext/pointset.cpp
  102. +69 −0 ext/pointset.h
  103. +122 −0 ext/trackbar.cpp
  104. +65 −0 ext/trackbar.h
  105. +368 −0 ext/window.cpp
  106. +56 −0 ext/window.h
  107. +2 −0 images/CvMat_sobel.png
  108. +2 −0 images/CvMat_sub_rect.png
  109. +2 −0 images/CvSeq_relationmap.png
  110. +1 −0 images/face_detect_from_lena.jpg
  111. +3 −0 lib/opencv.rb
  112. +3 −0 lib/version.rb
  113. +191 −0 metadata
  114. +120 −0 setup/setup.cygwin.rb
  115. +99 −0 setup/setup.mingw.rb
  116. +103 −0 setup/setup.mswin32.rb
  117. +6 −0 test/test_opencv.rb
@@ -0,0 +1,5 @@
+=== 0.0.6 / 2008-06-27
+
+* First gem release.
+
+ * Some OpenCV function wrapped.
@@ -0,0 +1,30 @@
+The BSD Liscense
+
+Copyright (c) 2008, Masakazu Yonekura
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms, with or without modification, are
+permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above
+ copyright notice, this list of conditions and the
+ following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+* Neither the name of Masakazu Yonekura. nor the names of its
+ contributors may be used to endorse or promote products
+ derived from this software without specific prior
+ written permission of Masakazu Yonekura.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,115 @@
+History.txt
+Manifest.txt
+README.txt
+License.txt
+Rakefile
+examples/convexhull.rb
+examples/face_detect.rb
+examples/houghcircle.rb
+examples/inpaint.png
+examples/inpaint.rb
+examples/paint.rb
+examples/snake.rb
+examples/stuff.jpg
+ext/curve.cpp
+ext/curve.h
+ext/cvavgcomp.cpp
+ext/cvavgcomp.h
+ext/cvbox2d.cpp
+ext/cvbox2d.h
+ext/cvcapture.cpp
+ext/cvcapture.h
+ext/cvchain.cpp
+ext/cvchain.h
+ext/cvchaincode.cpp
+ext/cvchaincode.h
+ext/cvcircle32f.cpp
+ext/cvcircle32f.h
+ext/cvcondensation.cpp
+ext/cvcondensation.h
+ext/cvconnectedcomp.cpp
+ext/cvconnectedcomp.h
+ext/cvcontour.cpp
+ext/cvcontour.h
+ext/cvcontourtree.cpp
+ext/cvcontourtree.h
+ext/cvconvexitydefect.cpp
+ext/cvconvexitydefect.h
+ext/cverror.cpp
+ext/cverror.h
+ext/cvfont.cpp
+ext/cvfont.h
+ext/cvhaarclassifiercascade.cpp
+ext/cvhaarclassifiercascade.h
+ext/cvhistogram.cpp
+ext/cvhistogram.h
+ext/cvindex.cpp
+ext/cvindex.h
+ext/cvline.cpp
+ext/cvline.h
+ext/cvmat.cpp
+ext/cvmat.h
+ext/cvmatnd.cpp
+ext/cvmatnd.h
+ext/cvmemstorage.cpp
+ext/cvmemstorage.h
+ext/cvmoments.cpp
+ext/cvmoments.h
+ext/cvpoint.cpp
+ext/cvpoint.h
+ext/cvpoint2d32f.cpp
+ext/cvpoint2d32f.h
+ext/cvpoint3d32f.cpp
+ext/cvpoint3d32f.h
+ext/cvrect.cpp
+ext/cvrect.h
+ext/cvscalar.cpp
+ext/cvscalar.h
+ext/cvseq.cpp
+ext/cvseq.h
+ext/cvset.cpp
+ext/cvset.h
+ext/cvsize.cpp
+ext/cvsize.h
+ext/cvsize2d32f.cpp
+ext/cvsize2d32f.h
+ext/cvslice.cpp
+ext/cvslice.h
+ext/cvsparsemat.cpp
+ext/cvsparsemat.h
+ext/cvtermcriteria.cpp
+ext/cvtermcriteria.h
+ext/cvtwopoints.cpp
+ext/cvtwopoints.h
+ext/cvvector.cpp
+ext/cvvector.h
+ext/cvvideowriter.cpp
+ext/cvvideowriter.h
+ext/extconf.rb
+ext/gui.cpp
+ext/gui.h
+ext/iplconvkernel.cpp
+ext/iplconvkernel.h
+ext/iplimage.cpp
+ext/iplimage.h
+ext/mouseevent.cpp
+ext/mouseevent.h
+ext/opencv.cpp
+ext/opencv.h
+ext/point3dset.cpp
+ext/point3dset.h
+ext/pointset.cpp
+ext/pointset.h
+ext/trackbar.cpp
+ext/trackbar.h
+ext/window.cpp
+ext/window.h
+images/CvMat_sobel.png
+images/CvMat_sub_rect.png
+images/CvSeq_relationmap.png
+images/face_detect_from_lena.jpg
+lib/opencv.rb
+lib/version.rb
+setup/setup.cygwin.rb
+setup/setup.mingw.rb
+setup/setup.mswin32.rb
@@ -0,0 +1,47 @@
+= opencv
+
+OpenCV Sourceforge Project
+http://sourceforge.net/projects/opencvlibrary/
+
+Ruby/OpenCV Author's Web Page
+http://blueruby.mydns.jp/opencv
+
+== DESCRIPTION:
+
+OpenCV Ruby Wrapper
+
+== FEATURES/PROBLEMS:
+
+* First release rubygems, Some OpenCV function wrapped.
+
+== SYNOPSIS:
+
+# Show image via GUI Window.
+
+require "rubygems"
+gem "opencv"
+require "opencv"
+
+image = OpenCV::IplImage.load("sample.jpg")
+window = OpenCV::GUI::Window.new("preview")
+window.show(image)
+OpenCV::GUI::wait_key
+
+# other sample code, see examples/*.rb
+
+== REQUIREMENTS:
+
+* OpenCV 1.0 or later.
+ http://sourceforge.net/projects/opencvlibrary/
+* ffcall (optional)
+ http://www.haible.de/bruno/packages-ffcall.html
+
+== INSTALL:
+
+gem install opencv
+
+== LICENSE:
+
+The BSD Liscense
+
+see LICENSE.txt
@@ -0,0 +1,34 @@
+# -*- ruby -*-
+
+require 'rubygems'
+require 'hoe'
+require './lib/version'
+
+Hoe.new('opencv', OpenCV::VERSION) do |p|
+ p.author = ['Masakazu Yonekura']
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
+ p.description = <<EOF
+OpenCV wrapper for Ruby
+EOF
+ p.rubyforge_name = 'opencv'
+ p.developer('lsxi', 'masakazu.yonekura@gmail.com')
+ p.email = ['masakazu.yonekura@gmail.com']
+
+ p.need_tar = false
+ p.need_zip = false
+ # p.rdoc_pattern =
+ # p.remote_rdoc_dir =
+ # p.rsync =
+ p.spec_extras = {
+ :extensions => %w{ext/extconf.rb}
+ }
+ p.summary = 'OpenCV wrapper for Ruby.'
+ # p.test_globs = 'spec/**/*_spec.rb'
+ p.clean_globs |= ['*.o']
+
+ p.url = 'http://blueruby.mydns.jp/opencv'
+
+ p.extra_deps << ['hoe']
+end
+
+# vim: syntax=Ruby
@@ -0,0 +1,41 @@
+#!/usr/bin/env ruby
+# convexhull.rb
+gem "opencv"
+require "opencv"
+require "pp"
+include OpenCV
+
+window = GUI::Window.new("convexhull")
+pp CvCapture::INTERFACE
+capture = CvCapture::open
+
+accuracy = 0.1
+t = window.set_trackbar("accuracy", 100, 1){|v|
+ accuracy = 0.1 * v
+}
+
+while true
+ key = GUI::wait_key(1)
+ image = capture.query
+ gray = image.BGR2GRAY
+ bin = gray.threshold_binary(0x44, 0xFF)
+ contours = bin.find_contours
+ while contours
+ image.poly_line! contours.approx(:accuracy => accuracy), :color => CvScalar::Red
+ contours.convexity_defects.each{|cd|
+ image.circle! cd.start, 1, :color => CvScalar::Blue
+ image.circle! cd.end, 1, :color => CvScalar::Blue
+ image.circle! cd.depth_point, 1, :color => CvScalar::Blue
+ }
+
+ contours = contours.h_next
+ end
+ #pts = gray.good_features_to_track(0.01, 10)
+ #puts pts.length
+ window.show image
+ next unless key
+ case key.chr
+ when "\e"
+ exit
+ end
+end
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+# face_detect.rb
+require "rubygems"
+gem "opencv"
+require "opencv"
+
+include OpenCV
+
+window = GUI::Window.new("face detect")
+capture = CvCapture.open
+detector = CvHaarClassifierCascade::load("C:/Program Files/OpenCV/data/haarcascades/haarcascade_frontalface_alt.xml")
+
+while true
+ key = GUI::wait_key(1)
+ image = capture.query
+ detector.detect_objects(image){|i|
+ image.rectangle! i.top_left, i.bottom_right, :color => CvColor::Red
+ }
+ window.show image
+ next unless key
+ case key.chr
+ when "\e"
+ exit
+ end
+end
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+# houghcircle.rb
+require "rubygems"
+gem "opencv"
+require "opencv"
+include OpenCV
+
+original_window = GUI::Window.new "original"
+hough_window = GUI::Window.new "hough circles"
+
+image = IplImage::load "stuff.jpg"
+gray = image.BGR2GRAY
+
+result = image.clone
+original_window.show image
+detect = gray.hough_circles_gradient(2.0, 10, 200, 50)
+puts detect.size
+detect.each{|circle|
+ puts "#{circle.center.x},#{circle.center.y} - #{circle.radius}"
+ result.circle! circle.center, circle.radius, :color => CvColor::Red, :thickness => 3
+}
+hough_window.show result
+GUI::wait_key
@@ -0,0 +1,2 @@
+�PNG
+
@@ -0,0 +1,43 @@
+#!/usr/bin/env ruby
+# inpaint.rb
+require "rubygems"
+gem "opencv"
+require "opencv"
+
+include OpenCV
+
+owindow = GUI::Window.new "original"
+mwindow = GUI::Window.new "mask"
+iwindow = GUI::Window.new "inpaint"
+
+image = IplImage::load "inpaint.png"
+b, g, r = image.split
+original_mask = r.threshold_binary_inverse(0x00, 0xFF) & b.threshold_binary_inverse(0x00, 0xFF)
+mask = original_mask.copy
+
+num_dilate = 3
+radius = 5
+dilate_bar = mwindow.set_trackbar("dilate", 10, num_dilate){|v|
+ num_dilate = v
+ mask = original_mask.dilate(nil, num_dilate)
+ mwindow.show mask
+}
+
+radius_bar = mwindow.set_trackbar("radius", 30, radius){|v|
+ radius = v
+}
+
+owindow.show image
+mwindow.show mask
+
+while key = GUI::wait_key
+ case key.chr
+ when "\e" # esc
+ exit
+ when "n"
+ iwindow.show image.inpaint_ns(mask, radius)
+ when "t"
+ iwindow.show image.inpaint_telea(mask, radius)
+ end
+end
+
Oops, something went wrong.

0 comments on commit 9196cb1

Please sign in to comment.