ruby-opencv 0.0.8.pre-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +25 -0
- data/Gemfile +8 -0
- data/History.txt +5 -0
- data/License.txt +30 -0
- data/Manifest.txt +225 -0
- data/README.rdoc +149 -0
- data/Rakefile +32 -0
- data/examples/alpha_blend.rb +21 -0
- data/examples/box.png +0 -0
- data/examples/box_in_scene.png +0 -0
- data/examples/contours/bitmap-contours-with-labels.png +0 -0
- data/examples/contours/bitmap-contours.png +0 -0
- data/examples/contours/bounding-box-detect-canny.rb +62 -0
- data/examples/contours/contour_retrieval_modes.rb +139 -0
- data/examples/contours/rotated-boxes.jpg +0 -0
- data/examples/convexhull.rb +47 -0
- data/examples/face_detect.rb +20 -0
- data/examples/find_obj.rb +169 -0
- data/examples/houghcircle.rb +22 -0
- data/examples/inpaint.png +0 -0
- data/examples/inpaint.rb +57 -0
- data/examples/lenna-rotated.jpg +0 -0
- data/examples/lenna.jpg +0 -0
- data/examples/match_kdtree.rb +88 -0
- data/examples/matching_to_many_images.rb +16 -0
- data/examples/matching_to_many_images/query.png +0 -0
- data/examples/matching_to_many_images/train/1.png +0 -0
- data/examples/matching_to_many_images/train/2.png +0 -0
- data/examples/matching_to_many_images/train/3.png +0 -0
- data/examples/matching_to_many_images/train/trainImages.txt +3 -0
- data/examples/paint.rb +70 -0
- data/examples/snake.rb +43 -0
- data/examples/stuff.jpg +0 -0
- data/examples/tiffany.jpg +0 -0
- data/ext/opencv/curve.cpp +112 -0
- data/ext/opencv/curve.h +34 -0
- data/ext/opencv/cvavgcomp.cpp +67 -0
- data/ext/opencv/cvavgcomp.h +39 -0
- data/ext/opencv/cvbox2d.cpp +197 -0
- data/ext/opencv/cvbox2d.h +61 -0
- data/ext/opencv/cvcapture.cpp +499 -0
- data/ext/opencv/cvcapture.h +72 -0
- data/ext/opencv/cvchain.cpp +233 -0
- data/ext/opencv/cvchain.h +46 -0
- data/ext/opencv/cvcircle32f.cpp +116 -0
- data/ext/opencv/cvcircle32f.h +52 -0
- data/ext/opencv/cvcondensation.cpp +282 -0
- data/ext/opencv/cvcondensation.h +49 -0
- data/ext/opencv/cvconnectedcomp.cpp +143 -0
- data/ext/opencv/cvconnectedcomp.h +49 -0
- data/ext/opencv/cvcontour.cpp +296 -0
- data/ext/opencv/cvcontour.h +48 -0
- data/ext/opencv/cvcontourtree.cpp +91 -0
- data/ext/opencv/cvcontourtree.h +41 -0
- data/ext/opencv/cvconvexitydefect.cpp +103 -0
- data/ext/opencv/cvconvexitydefect.h +42 -0
- data/ext/opencv/cverror.cpp +159 -0
- data/ext/opencv/cverror.h +28 -0
- data/ext/opencv/cvfeaturetree.cpp +125 -0
- data/ext/opencv/cvfeaturetree.h +55 -0
- data/ext/opencv/cvfont.cpp +208 -0
- data/ext/opencv/cvfont.h +64 -0
- data/ext/opencv/cvhaarclassifiercascade.cpp +168 -0
- data/ext/opencv/cvhaarclassifiercascade.h +39 -0
- data/ext/opencv/cvhistogram.cpp +546 -0
- data/ext/opencv/cvhistogram.h +73 -0
- data/ext/opencv/cvhumoments.cpp +139 -0
- data/ext/opencv/cvhumoments.h +51 -0
- data/ext/opencv/cvline.cpp +154 -0
- data/ext/opencv/cvline.h +54 -0
- data/ext/opencv/cvmat.cpp +5848 -0
- data/ext/opencv/cvmat.h +284 -0
- data/ext/opencv/cvmatnd.cpp +44 -0
- data/ext/opencv/cvmatnd.h +28 -0
- data/ext/opencv/cvmemstorage.cpp +68 -0
- data/ext/opencv/cvmemstorage.h +53 -0
- data/ext/opencv/cvmoments.cpp +287 -0
- data/ext/opencv/cvmoments.h +75 -0
- data/ext/opencv/cvpoint.cpp +228 -0
- data/ext/opencv/cvpoint.h +64 -0
- data/ext/opencv/cvpoint2d32f.cpp +211 -0
- data/ext/opencv/cvpoint2d32f.h +63 -0
- data/ext/opencv/cvpoint3d32f.cpp +245 -0
- data/ext/opencv/cvpoint3d32f.h +66 -0
- data/ext/opencv/cvrect.cpp +333 -0
- data/ext/opencv/cvrect.h +79 -0
- data/ext/opencv/cvscalar.cpp +236 -0
- data/ext/opencv/cvscalar.h +71 -0
- data/ext/opencv/cvseq.cpp +599 -0
- data/ext/opencv/cvseq.h +74 -0
- data/ext/opencv/cvsize.cpp +221 -0
- data/ext/opencv/cvsize.h +65 -0
- data/ext/opencv/cvsize2d32f.cpp +209 -0
- data/ext/opencv/cvsize2d32f.h +64 -0
- data/ext/opencv/cvslice.cpp +120 -0
- data/ext/opencv/cvslice.h +61 -0
- data/ext/opencv/cvsparsemat.cpp +44 -0
- data/ext/opencv/cvsparsemat.h +28 -0
- data/ext/opencv/cvsurfparams.cpp +199 -0
- data/ext/opencv/cvsurfparams.h +58 -0
- data/ext/opencv/cvsurfpoint.cpp +223 -0
- data/ext/opencv/cvsurfpoint.h +52 -0
- data/ext/opencv/cvtermcriteria.cpp +192 -0
- data/ext/opencv/cvtermcriteria.h +71 -0
- data/ext/opencv/cvtwopoints.cpp +116 -0
- data/ext/opencv/cvtwopoints.h +51 -0
- data/ext/opencv/cvutils.cpp +194 -0
- data/ext/opencv/cvutils.h +29 -0
- data/ext/opencv/cvvideowriter.cpp +137 -0
- data/ext/opencv/cvvideowriter.h +43 -0
- data/ext/opencv/gui.cpp +68 -0
- data/ext/opencv/gui.h +30 -0
- data/ext/opencv/iplconvkernel.cpp +192 -0
- data/ext/opencv/iplconvkernel.h +71 -0
- data/ext/opencv/iplimage.cpp +644 -0
- data/ext/opencv/iplimage.h +73 -0
- data/ext/opencv/lib/opencv.rb +3 -0
- data/ext/opencv/lib/opencv/psyched_yaml.rb +22 -0
- data/ext/opencv/lib/opencv/version.rb +3 -0
- data/ext/opencv/mouseevent.cpp +181 -0
- data/ext/opencv/mouseevent.h +56 -0
- data/ext/opencv/opencv.cpp +722 -0
- data/ext/opencv/opencv.h +400 -0
- data/ext/opencv/pointset.cpp +274 -0
- data/ext/opencv/pointset.h +68 -0
- data/ext/opencv/trackbar.cpp +121 -0
- data/ext/opencv/trackbar.h +69 -0
- data/ext/opencv/window.cpp +357 -0
- data/ext/opencv/window.h +66 -0
- data/extconf.rb +75 -0
- data/images/CvMat_sobel.png +0 -0
- data/images/CvMat_sub_rect.png +0 -0
- data/images/CvSeq_relationmap.png +0 -0
- data/images/face_detect_from_lena.jpg +0 -0
- data/lib/opencv.rb +3 -0
- data/lib/opencv/psyched_yaml.rb +22 -0
- data/lib/opencv/version.rb +3 -0
- data/ruby-opencv.gemspec +43 -0
- data/test/helper.rb +166 -0
- data/test/runner.rb +30 -0
- data/test/samples/airplane.jpg +0 -0
- data/test/samples/baboon.jpg +0 -0
- data/test/samples/baboon200.jpg +0 -0
- data/test/samples/baboon200_rotated.jpg +0 -0
- data/test/samples/blank0.jpg +0 -0
- data/test/samples/blank1.jpg +0 -0
- data/test/samples/blank2.jpg +0 -0
- data/test/samples/blank3.jpg +0 -0
- data/test/samples/blank4.jpg +0 -0
- data/test/samples/blank5.jpg +0 -0
- data/test/samples/blank6.jpg +0 -0
- data/test/samples/blank7.jpg +0 -0
- data/test/samples/blank8.jpg +0 -0
- data/test/samples/blank9.jpg +0 -0
- data/test/samples/cat.jpg +0 -0
- data/test/samples/chessboard.jpg +0 -0
- data/test/samples/contours.jpg +0 -0
- data/test/samples/fruits.jpg +0 -0
- data/test/samples/haarcascade_frontalface_alt.xml.gz +0 -0
- data/test/samples/inpaint-mask.bmp +0 -0
- data/test/samples/lena-256x256.jpg +0 -0
- data/test/samples/lena-32x32.jpg +0 -0
- data/test/samples/lena-eyes.jpg +0 -0
- data/test/samples/lena-inpaint.jpg +0 -0
- data/test/samples/lena.jpg +0 -0
- data/test/samples/lines.jpg +0 -0
- data/test/samples/messy0.jpg +0 -0
- data/test/samples/messy1.jpg +0 -0
- data/test/samples/movie_sample.avi +0 -0
- data/test/samples/one_way_train_0000.jpg +0 -0
- data/test/samples/one_way_train_0001.jpg +0 -0
- data/test/samples/partially_blank0.jpg +0 -0
- data/test/samples/partially_blank1.jpg +0 -0
- data/test/samples/smooth0.jpg +0 -0
- data/test/samples/smooth1.jpg +0 -0
- data/test/samples/smooth2.jpg +0 -0
- data/test/samples/smooth3.jpg +0 -0
- data/test/samples/smooth4.jpg +0 -0
- data/test/samples/smooth5.jpg +0 -0
- data/test/samples/smooth6.jpg +0 -0
- data/test/samples/str-cv-rotated.jpg +0 -0
- data/test/samples/str-cv.jpg +0 -0
- data/test/samples/str-ov.jpg +0 -0
- data/test/samples/stuff.jpg +0 -0
- data/test/test_curve.rb +43 -0
- data/test/test_cvavgcomp.rb +24 -0
- data/test/test_cvbox2d.rb +76 -0
- data/test/test_cvcapture.rb +183 -0
- data/test/test_cvchain.rb +108 -0
- data/test/test_cvcircle32f.rb +41 -0
- data/test/test_cvconnectedcomp.rb +61 -0
- data/test/test_cvcontour.rb +150 -0
- data/test/test_cvcontourtree.rb +43 -0
- data/test/test_cverror.rb +50 -0
- data/test/test_cvfeaturetree.rb +65 -0
- data/test/test_cvfont.rb +58 -0
- data/test/test_cvhaarclassifiercascade.rb +63 -0
- data/test/test_cvhistogram.rb +271 -0
- data/test/test_cvhumoments.rb +83 -0
- data/test/test_cvline.rb +50 -0
- data/test/test_cvmat.rb +2947 -0
- data/test/test_cvmat_drawing.rb +349 -0
- data/test/test_cvmat_dxt.rb +150 -0
- data/test/test_cvmat_imageprocessing.rb +2025 -0
- data/test/test_cvmat_matching.rb +57 -0
- data/test/test_cvmoments.rb +180 -0
- data/test/test_cvpoint.rb +75 -0
- data/test/test_cvpoint2d32f.rb +75 -0
- data/test/test_cvpoint3d32f.rb +93 -0
- data/test/test_cvrect.rb +144 -0
- data/test/test_cvscalar.rb +113 -0
- data/test/test_cvseq.rb +295 -0
- data/test/test_cvsize.rb +75 -0
- data/test/test_cvsize2d32f.rb +75 -0
- data/test/test_cvslice.rb +31 -0
- data/test/test_cvsurfparams.rb +57 -0
- data/test/test_cvsurfpoint.rb +66 -0
- data/test/test_cvtermcriteria.rb +56 -0
- data/test/test_cvtwopoints.rb +40 -0
- data/test/test_cvvideowriter.rb +58 -0
- data/test/test_iplconvkernel.rb +54 -0
- data/test/test_iplimage.rb +236 -0
- data/test/test_mouseevent.rb +17 -0
- data/test/test_opencv.rb +324 -0
- data/test/test_pointset.rb +126 -0
- data/test/test_preliminary.rb +130 -0
- data/test/test_trackbar.rb +47 -0
- data/test/test_window.rb +115 -0
- metadata +414 -0
data/ext/opencv/window.h
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
/************************************************************
|
2
|
+
|
3
|
+
window.h -
|
4
|
+
|
5
|
+
$Author: lsxi $
|
6
|
+
|
7
|
+
Copyright (C) 2005-2006 Masakazu Yonekura
|
8
|
+
|
9
|
+
************************************************************/
|
10
|
+
#ifndef RUBY_OPENCV_GUI_H
|
11
|
+
#include "gui.h"
|
12
|
+
#endif
|
13
|
+
|
14
|
+
#ifndef RUBY_OPENCV_GUI_WINDOW_H
|
15
|
+
#define RUBY_OPENCV_GUI_WINDOW_H
|
16
|
+
|
17
|
+
#include "opencv.h"
|
18
|
+
#define __NAMESPACE_BEGIN_WINDOW namespace cWindow {
|
19
|
+
#define __NAMESPACE_END_WINDOW }
|
20
|
+
|
21
|
+
__NAMESPACE_BEGIN_OPENCV
|
22
|
+
__NAMESPACE_BEGIN_GUI
|
23
|
+
|
24
|
+
typedef struct Window {
|
25
|
+
VALUE name;
|
26
|
+
VALUE image;
|
27
|
+
VALUE trackbars;
|
28
|
+
VALUE blocks;
|
29
|
+
} Window;
|
30
|
+
|
31
|
+
__NAMESPACE_BEGIN_WINDOW
|
32
|
+
|
33
|
+
void define_ruby_class();
|
34
|
+
|
35
|
+
VALUE rb_allocate(VALUE klass);
|
36
|
+
|
37
|
+
void window_mark(void *ptr);
|
38
|
+
void window_free(void *ptr);
|
39
|
+
VALUE rb_alive_q(VALUE self);
|
40
|
+
VALUE rb_initialize(int argc, VALUE *argv, VALUE self);
|
41
|
+
VALUE rb_destroy(VALUE self);
|
42
|
+
VALUE rb_destroy_all(VALUE klass);
|
43
|
+
VALUE rb_resize(int argc, VALUE *argv, VALUE self);
|
44
|
+
VALUE rb_move(int argc, VALUE *argv, VALUE self);
|
45
|
+
VALUE rb_show_image(VALUE self, VALUE img);
|
46
|
+
VALUE rb_set_trackbar(int argc, VALUE *argv, VALUE self);
|
47
|
+
VALUE rb_set_mouse_callback(int argc, VALUE* argv, VALUE self);
|
48
|
+
|
49
|
+
inline Window*
|
50
|
+
WINDOW(VALUE object) {
|
51
|
+
Window *ptr;
|
52
|
+
Data_Get_Struct(object, Window, ptr);
|
53
|
+
return ptr;
|
54
|
+
}
|
55
|
+
|
56
|
+
inline const char*
|
57
|
+
GET_WINDOW_NAME(VALUE object) {
|
58
|
+
return StringValueCStr(WINDOW(object)->name);
|
59
|
+
}
|
60
|
+
|
61
|
+
__NAMESPACE_END_WINDOW
|
62
|
+
__NAMESPACE_END_GUI
|
63
|
+
__NAMESPACE_END_OPENCV
|
64
|
+
|
65
|
+
#endif // RUBY_OPENCV_GUI_WINDOW_H
|
66
|
+
|
data/extconf.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "mkmf"
|
3
|
+
|
4
|
+
def cv_version_suffix(incdir)
|
5
|
+
major, minor, subminor = nil, nil, nil
|
6
|
+
open("#{incdir}/opencv2/core/version.hpp", 'r') { |f|
|
7
|
+
f.read.lines.each { |line|
|
8
|
+
major = $1.to_s if line =~ /\A#define\s+CV_MAJOR_VERSION\s+(\d+)\s*\Z/
|
9
|
+
minor = $1.to_s if line =~ /\A#define\s+CV_MINOR_VERSION\s+(\d+)\s*\Z/
|
10
|
+
subminor = $1.to_s if line =~ /\A#define\s+CV_SUBMINOR_VERSION\s+(\d+)\s*\Z/
|
11
|
+
}
|
12
|
+
}
|
13
|
+
major + minor + subminor
|
14
|
+
end
|
15
|
+
|
16
|
+
incdir, libdir = dir_config("opencv", "/usr/local/include", "/usr/local/lib")
|
17
|
+
dir_config("libxml2", "/usr/include", "/usr/lib")
|
18
|
+
|
19
|
+
opencv_headers = ["opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/imgproc/imgproc_c.h",
|
20
|
+
"opencv2/imgproc/imgproc.hpp", "opencv2/video/tracking.hpp", "opencv2/features2d/features2d.hpp",
|
21
|
+
"opencv2/flann/flann.hpp", "opencv2/calib3d/calib3d.hpp", "opencv2/objdetect/objdetect.hpp",
|
22
|
+
"opencv2/legacy/compat.hpp", "opencv2/legacy/legacy.hpp", "opencv2/highgui/highgui_c.h",
|
23
|
+
"opencv2/highgui/highgui.hpp", "opencv2/photo/photo.hpp", "opencv2/nonfree/nonfree.hpp"]
|
24
|
+
|
25
|
+
opencv_libraries = ["opencv_calib3d", "opencv_contrib", "opencv_core", "opencv_features2d",
|
26
|
+
"opencv_flann", "opencv_gpu", "opencv_highgui", "opencv_imgproc",
|
27
|
+
"opencv_legacy", "opencv_ml", "opencv_objdetect", "opencv_video",
|
28
|
+
"opencv_photo", "opencv_nonfree"]
|
29
|
+
|
30
|
+
|
31
|
+
puts ">> Check the required libraries..."
|
32
|
+
case CONFIG["arch"]
|
33
|
+
when /mswin32/
|
34
|
+
suffix = cv_version_suffix(incdir)
|
35
|
+
opencv_libraries.map! {|lib| lib + suffix }
|
36
|
+
have_library("msvcrt")
|
37
|
+
opencv_libraries.each {|lib|
|
38
|
+
raise "#{lib}.lib not found." unless have_library(lib)
|
39
|
+
}
|
40
|
+
$CFLAGS << ' /EHsc'
|
41
|
+
when /mingw32/
|
42
|
+
suffix = cv_version_suffix(incdir)
|
43
|
+
opencv_libraries.map! {|lib| lib + suffix }
|
44
|
+
have_library("msvcrt")
|
45
|
+
opencv_libraries.each {|lib|
|
46
|
+
raise "lib#{lib} not found." unless have_library(lib)
|
47
|
+
}
|
48
|
+
else
|
49
|
+
opencv_libraries.each {|lib|
|
50
|
+
raise "lib#{lib} not found." unless have_library(lib)
|
51
|
+
}
|
52
|
+
have_library("stdc++")
|
53
|
+
end
|
54
|
+
|
55
|
+
# Check the required headers
|
56
|
+
puts ">> Check the required headers..."
|
57
|
+
opencv_headers.each {|header|
|
58
|
+
unless have_header(header)
|
59
|
+
if CONFIG["arch"] =~ /mswin32/ and File.exists? "#{incdir}/#{header}"
|
60
|
+
# In mswin32, have_header('opencv2/nonfree/nonfree.hpp') fails because of a syntax problem.
|
61
|
+
warn "warning: #{header} found but `have_header` failed."
|
62
|
+
$defs << "-DHAVE_#{header.tr_cpp}"
|
63
|
+
else
|
64
|
+
raise "#{header} not found."
|
65
|
+
end
|
66
|
+
end
|
67
|
+
}
|
68
|
+
have_header("stdarg.h")
|
69
|
+
|
70
|
+
# Quick fix for 1.8.7
|
71
|
+
$CFLAGS << " -I#{File.dirname(__FILE__)}/ext/opencv"
|
72
|
+
|
73
|
+
# Create Makefile
|
74
|
+
create_makefile("opencv", "./ext/opencv")
|
75
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/opencv.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- mode: ruby; coding: utf-8-unix -*-
|
2
|
+
# Psych loader for avoiding loading problem
|
3
|
+
# (borrowed from Bundler 1.1.rc.7 https://github.com/carlhuda/bundler/blob/v1.1.rc.7/lib/bundler/psyched_yaml.rb )
|
4
|
+
#
|
5
|
+
# See: https://github.com/ruby-opencv/ruby-opencv/pull/6
|
6
|
+
|
7
|
+
# Psych could be a gem
|
8
|
+
begin
|
9
|
+
gem 'psych'
|
10
|
+
rescue Gem::LoadError
|
11
|
+
end if defined?(Gem)
|
12
|
+
|
13
|
+
# Psych could be a stdlib
|
14
|
+
begin
|
15
|
+
# it's too late if Syck is already loaded
|
16
|
+
require 'psych' unless defined?(Syck)
|
17
|
+
rescue LoadError
|
18
|
+
end
|
19
|
+
|
20
|
+
# Psych might NOT EXIST AT ALL
|
21
|
+
require 'yaml'
|
22
|
+
|
data/ruby-opencv.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "ruby-opencv"
|
5
|
+
s.version = "0.0.8.pre.20130127091400"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["lsxi", "ser1zw", "pcting"]
|
9
|
+
s.date = "2013-01-27"
|
10
|
+
s.description = "OpenCV wrapper for Ruby"
|
11
|
+
s.email = ["masakazu.yonekura@gmail.com", "azariahsawtikes@gmail.com", "pcting@gmail.com"]
|
12
|
+
s.extensions = ["extconf.rb"]
|
13
|
+
s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "examples/matching_to_many_images/train/trainImages.txt"]
|
14
|
+
s.files = [".gitignore", "Gemfile", "History.txt", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "examples/alpha_blend.rb", "examples/box.png", "examples/box_in_scene.png", "examples/contours/bitmap-contours-with-labels.png", "examples/contours/bitmap-contours.png", "examples/contours/bounding-box-detect-canny.rb", "examples/contours/contour_retrieval_modes.rb", "examples/contours/rotated-boxes.jpg", "examples/convexhull.rb", "examples/face_detect.rb", "examples/find_obj.rb", "examples/houghcircle.rb", "examples/inpaint.png", "examples/inpaint.rb", "examples/lenna-rotated.jpg", "examples/lenna.jpg", "examples/match_kdtree.rb", "examples/matching_to_many_images.rb", "examples/matching_to_many_images/query.png", "examples/matching_to_many_images/train/1.png", "examples/matching_to_many_images/train/2.png", "examples/matching_to_many_images/train/3.png", "examples/matching_to_many_images/train/trainImages.txt", "examples/paint.rb", "examples/snake.rb", "examples/stuff.jpg", "examples/tiffany.jpg", "ext/opencv/curve.cpp", "ext/opencv/curve.h", "ext/opencv/cvavgcomp.cpp", "ext/opencv/cvavgcomp.h", "ext/opencv/cvbox2d.cpp", "ext/opencv/cvbox2d.h", "ext/opencv/cvcapture.cpp", "ext/opencv/cvcapture.h", "ext/opencv/cvchain.cpp", "ext/opencv/cvchain.h", "ext/opencv/cvcircle32f.cpp", "ext/opencv/cvcircle32f.h", "ext/opencv/cvcondensation.cpp", "ext/opencv/cvcondensation.h", "ext/opencv/cvconnectedcomp.cpp", "ext/opencv/cvconnectedcomp.h", "ext/opencv/cvcontour.cpp", "ext/opencv/cvcontour.h", "ext/opencv/cvcontourtree.cpp", "ext/opencv/cvcontourtree.h", "ext/opencv/cvconvexitydefect.cpp", "ext/opencv/cvconvexitydefect.h", "ext/opencv/cverror.cpp", "ext/opencv/cverror.h", "ext/opencv/cvfeaturetree.cpp", "ext/opencv/cvfeaturetree.h", "ext/opencv/cvfont.cpp", "ext/opencv/cvfont.h", "ext/opencv/cvhaarclassifiercascade.cpp", "ext/opencv/cvhaarclassifiercascade.h", "ext/opencv/cvhistogram.cpp", "ext/opencv/cvhistogram.h", "ext/opencv/cvhumoments.cpp", "ext/opencv/cvhumoments.h", "ext/opencv/cvline.cpp", "ext/opencv/cvline.h", "ext/opencv/cvmat.cpp", "ext/opencv/cvmat.h", "ext/opencv/cvmatnd.cpp", "ext/opencv/cvmatnd.h", "ext/opencv/cvmemstorage.cpp", "ext/opencv/cvmemstorage.h", "ext/opencv/cvmoments.cpp", "ext/opencv/cvmoments.h", "ext/opencv/cvpoint.cpp", "ext/opencv/cvpoint.h", "ext/opencv/cvpoint2d32f.cpp", "ext/opencv/cvpoint2d32f.h", "ext/opencv/cvpoint3d32f.cpp", "ext/opencv/cvpoint3d32f.h", "ext/opencv/cvrect.cpp", "ext/opencv/cvrect.h", "ext/opencv/cvscalar.cpp", "ext/opencv/cvscalar.h", "ext/opencv/cvseq.cpp", "ext/opencv/cvseq.h", "ext/opencv/cvsize.cpp", "ext/opencv/cvsize.h", "ext/opencv/cvsize2d32f.cpp", "ext/opencv/cvsize2d32f.h", "ext/opencv/cvslice.cpp", "ext/opencv/cvslice.h", "ext/opencv/cvsparsemat.cpp", "ext/opencv/cvsparsemat.h", "ext/opencv/cvsurfparams.cpp", "ext/opencv/cvsurfparams.h", "ext/opencv/cvsurfpoint.cpp", "ext/opencv/cvsurfpoint.h", "ext/opencv/cvtermcriteria.cpp", "ext/opencv/cvtermcriteria.h", "ext/opencv/cvtwopoints.cpp", "ext/opencv/cvtwopoints.h", "ext/opencv/cvutils.cpp", "ext/opencv/cvutils.h", "ext/opencv/cvvideowriter.cpp", "ext/opencv/cvvideowriter.h", "ext/opencv/gui.cpp", "ext/opencv/gui.h", "ext/opencv/iplconvkernel.cpp", "ext/opencv/iplconvkernel.h", "ext/opencv/iplimage.cpp", "ext/opencv/iplimage.h", "ext/opencv/lib/opencv.rb", "ext/opencv/lib/opencv/psyched_yaml.rb", "ext/opencv/lib/opencv/version.rb", "ext/opencv/mouseevent.cpp", "ext/opencv/mouseevent.h", "ext/opencv/opencv.cpp", "ext/opencv/opencv.h", "ext/opencv/pointset.cpp", "ext/opencv/pointset.h", "ext/opencv/trackbar.cpp", "ext/opencv/trackbar.h", "ext/opencv/window.cpp", "ext/opencv/window.h", "extconf.rb", "images/CvMat_sobel.png", "images/CvMat_sub_rect.png", "images/CvSeq_relationmap.png", "images/face_detect_from_lena.jpg", "ruby-opencv.gemspec", "test/helper.rb", "test/runner.rb", "test/samples/airplane.jpg", "test/samples/baboon.jpg", "test/samples/baboon200.jpg", "test/samples/baboon200_rotated.jpg", "test/samples/blank0.jpg", "test/samples/blank1.jpg", "test/samples/blank2.jpg", "test/samples/blank3.jpg", "test/samples/blank4.jpg", "test/samples/blank5.jpg", "test/samples/blank6.jpg", "test/samples/blank7.jpg", "test/samples/blank8.jpg", "test/samples/blank9.jpg", "test/samples/cat.jpg", "test/samples/chessboard.jpg", "test/samples/contours.jpg", "test/samples/fruits.jpg", "test/samples/haarcascade_frontalface_alt.xml.gz", "test/samples/inpaint-mask.bmp", "test/samples/lena-256x256.jpg", "test/samples/lena-32x32.jpg", "test/samples/lena-eyes.jpg", "test/samples/lena-inpaint.jpg", "test/samples/lena.jpg", "test/samples/lines.jpg", "test/samples/messy0.jpg", "test/samples/messy1.jpg", "test/samples/movie_sample.avi", "test/samples/one_way_train_0000.jpg", "test/samples/one_way_train_0001.jpg", "test/samples/partially_blank0.jpg", "test/samples/partially_blank1.jpg", "test/samples/smooth0.jpg", "test/samples/smooth1.jpg", "test/samples/smooth2.jpg", "test/samples/smooth3.jpg", "test/samples/smooth4.jpg", "test/samples/smooth5.jpg", "test/samples/smooth6.jpg", "test/samples/str-cv-rotated.jpg", "test/samples/str-cv.jpg", "test/samples/str-ov.jpg", "test/samples/stuff.jpg", "test/test_curve.rb", "test/test_cvavgcomp.rb", "test/test_cvbox2d.rb", "test/test_cvcapture.rb", "test/test_cvchain.rb", "test/test_cvcircle32f.rb", "test/test_cvconnectedcomp.rb", "test/test_cvcontour.rb", "test/test_cvcontourtree.rb", "test/test_cverror.rb", "test/test_cvfeaturetree.rb", "test/test_cvfont.rb", "test/test_cvhaarclassifiercascade.rb", "test/test_cvhistogram.rb", "test/test_cvhumoments.rb", "test/test_cvline.rb", "test/test_cvmat.rb", "test/test_cvmat_drawing.rb", "test/test_cvmat_dxt.rb", "test/test_cvmat_imageprocessing.rb", "test/test_cvmat_matching.rb", "test/test_cvmoments.rb", "test/test_cvpoint.rb", "test/test_cvpoint2d32f.rb", "test/test_cvpoint3d32f.rb", "test/test_cvrect.rb", "test/test_cvscalar.rb", "test/test_cvseq.rb", "test/test_cvsize.rb", "test/test_cvsize2d32f.rb", "test/test_cvslice.rb", "test/test_cvsurfparams.rb", "test/test_cvsurfpoint.rb", "test/test_cvtermcriteria.rb", "test/test_cvtwopoints.rb", "test/test_cvvideowriter.rb", "test/test_iplconvkernel.rb", "test/test_iplimage.rb", "test/test_mouseevent.rb", "test/test_opencv.rb", "test/test_pointset.rb", "test/test_preliminary.rb", "test/test_trackbar.rb", "test/test_window.rb"]
|
15
|
+
s.homepage = "https://github.com/ruby-opencv/ruby-opencv/"
|
16
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = "ruby-opencv"
|
19
|
+
s.rubygems_version = "1.8.23"
|
20
|
+
s.summary = "OpenCV wrapper for Ruby"
|
21
|
+
s.test_files = ["test/test_curve.rb", "test/test_cvavgcomp.rb", "test/test_cvbox2d.rb", "test/test_cvcapture.rb", "test/test_cvchain.rb", "test/test_cvcircle32f.rb", "test/test_cvconnectedcomp.rb", "test/test_cvcontour.rb", "test/test_cvcontourtree.rb", "test/test_cverror.rb", "test/test_cvfeaturetree.rb", "test/test_cvfont.rb", "test/test_cvhaarclassifiercascade.rb", "test/test_cvhistogram.rb", "test/test_cvhumoments.rb", "test/test_cvline.rb", "test/test_cvmat.rb", "test/test_cvmat_drawing.rb", "test/test_cvmat_dxt.rb", "test/test_cvmat_imageprocessing.rb", "test/test_cvmat_matching.rb", "test/test_cvmoments.rb", "test/test_cvpoint.rb", "test/test_cvpoint2d32f.rb", "test/test_cvpoint3d32f.rb", "test/test_cvrect.rb", "test/test_cvscalar.rb", "test/test_cvseq.rb", "test/test_cvsize.rb", "test/test_cvsize2d32f.rb", "test/test_cvslice.rb", "test/test_cvsurfparams.rb", "test/test_cvsurfpoint.rb", "test/test_cvtermcriteria.rb", "test/test_cvtwopoints.rb", "test/test_cvvideowriter.rb", "test/test_iplconvkernel.rb", "test/test_iplimage.rb", "test/test_mouseevent.rb", "test/test_opencv.rb", "test/test_pointset.rb", "test/test_preliminary.rb", "test/test_trackbar.rb", "test/test_window.rb"]
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
s.specification_version = 3
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.10"])
|
28
|
+
s.add_development_dependency(%q<rake-compiler>, [">= 0"])
|
29
|
+
s.add_development_dependency(%q<hoe-gemspec>, [">= 0"])
|
30
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.5"])
|
31
|
+
else
|
32
|
+
s.add_dependency(%q<rdoc>, ["~> 3.10"])
|
33
|
+
s.add_dependency(%q<rake-compiler>, [">= 0"])
|
34
|
+
s.add_dependency(%q<hoe-gemspec>, [">= 0"])
|
35
|
+
s.add_dependency(%q<hoe>, ["~> 3.5"])
|
36
|
+
end
|
37
|
+
else
|
38
|
+
s.add_dependency(%q<rdoc>, ["~> 3.10"])
|
39
|
+
s.add_dependency(%q<rake-compiler>, [">= 0"])
|
40
|
+
s.add_dependency(%q<hoe-gemspec>, [">= 0"])
|
41
|
+
s.add_dependency(%q<hoe>, ["~> 3.5"])
|
42
|
+
end
|
43
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- mode: ruby; coding: utf-8-unix -*-
|
3
|
+
require 'test/unit'
|
4
|
+
require 'digest/md5'
|
5
|
+
require 'opencv'
|
6
|
+
include OpenCV
|
7
|
+
|
8
|
+
class OpenCVTestCase < Test::Unit::TestCase
|
9
|
+
SAMPLE_DIR = File.expand_path(File.dirname(__FILE__)) + '/samples/'
|
10
|
+
FILENAME_CAT = SAMPLE_DIR + 'cat.jpg'
|
11
|
+
FILENAME_LENA256x256 = SAMPLE_DIR + 'lena-256x256.jpg'
|
12
|
+
FILENAME_LENA32x32 = SAMPLE_DIR + 'lena-32x32.jpg'
|
13
|
+
FILENAME_LENA_EYES = File.expand_path(File.dirname(__FILE__)) + '/samples/lena-eyes.jpg'
|
14
|
+
FILENAME_FRUITS = SAMPLE_DIR + 'fruits.jpg'
|
15
|
+
FILENAME_CONTOURS = File.expand_path(File.dirname(__FILE__)) + '/samples/contours.jpg'
|
16
|
+
FILENAME_CHESSBOARD = SAMPLE_DIR + 'chessboard.jpg'
|
17
|
+
HAARCASCADE_FRONTALFACE_ALT = SAMPLE_DIR + 'haarcascade_frontalface_alt.xml.gz'
|
18
|
+
AVI_SAMPLE = SAMPLE_DIR + 'movie_sample.avi'
|
19
|
+
|
20
|
+
DUMMY_OBJ = Digest::MD5.new # dummy object for argument type check test
|
21
|
+
|
22
|
+
def snap(*images)
|
23
|
+
n = -1
|
24
|
+
images.map! { |val|
|
25
|
+
n += 1
|
26
|
+
if val.is_a? Hash
|
27
|
+
val
|
28
|
+
elsif val.is_a? Array
|
29
|
+
{:title => val[0], :image => val[1] }
|
30
|
+
else
|
31
|
+
{:title => "snap-#{n}", :image => val }
|
32
|
+
end
|
33
|
+
}
|
34
|
+
|
35
|
+
pos = CvPoint.new(0, 0)
|
36
|
+
images.each { |img|
|
37
|
+
w = GUI::Window.new(img[:title])
|
38
|
+
w.show(img[:image])
|
39
|
+
w.move(pos)
|
40
|
+
pos.x += img[:image].width
|
41
|
+
if pos.x > 800
|
42
|
+
pos.y += img[:image].height
|
43
|
+
pos.x = 0
|
44
|
+
end
|
45
|
+
}
|
46
|
+
|
47
|
+
GUI::wait_key
|
48
|
+
GUI::Window::destroy_all
|
49
|
+
end
|
50
|
+
|
51
|
+
def hash_img(img)
|
52
|
+
# Compute a hash for an image, useful for image comparisons
|
53
|
+
Digest::MD5.hexdigest(img.data)
|
54
|
+
end
|
55
|
+
|
56
|
+
unless Test::Unit::TestCase.instance_methods.map {|m| m.to_sym }.include? :assert_false
|
57
|
+
def assert_false(actual, message = nil)
|
58
|
+
assert_equal(false, actual, message)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
alias original_assert_in_delta assert_in_delta
|
63
|
+
|
64
|
+
def assert_cvscalar_equal(expected, actual, message = nil)
|
65
|
+
assert_equal(CvScalar, actual.class, message)
|
66
|
+
assert_array_equal(expected.to_ary, actual.to_ary, message)
|
67
|
+
end
|
68
|
+
|
69
|
+
def assert_array_equal(expected, actual, message = nil)
|
70
|
+
assert_equal(expected.size, actual.size, message)
|
71
|
+
expected.zip(actual) { |e, a|
|
72
|
+
assert_equal(e, a, message)
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
def assert_in_delta(expected, actual, delta)
|
77
|
+
if expected.is_a? CvScalar or actual.is_a? CvScalar
|
78
|
+
expected = expected.to_ary if expected.is_a? CvScalar
|
79
|
+
actual = actual.to_ary if actual.is_a? CvScalar
|
80
|
+
assert_in_delta(expected, actual ,delta)
|
81
|
+
elsif expected.is_a? Array and actual.is_a? Array
|
82
|
+
assert_equal(expected.size, actual.size)
|
83
|
+
expected.zip(actual) { |e, a|
|
84
|
+
original_assert_in_delta(e, a, delta)
|
85
|
+
}
|
86
|
+
else
|
87
|
+
original_assert_in_delta(expected, actual, delta)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def create_cvmat(height, width, depth = :cv8u, channel = 4, &block)
|
92
|
+
m = CvMat.new(height, width, depth, channel)
|
93
|
+
block = lambda { |j, i, c| CvScalar.new(*([c + 1] * channel)) } unless block_given?
|
94
|
+
count = 0
|
95
|
+
height.times { |j|
|
96
|
+
width.times { |i|
|
97
|
+
m[j, i] = block.call(j, i, count)
|
98
|
+
count += 1
|
99
|
+
}
|
100
|
+
}
|
101
|
+
m
|
102
|
+
end
|
103
|
+
|
104
|
+
def create_iplimage(width, height, depth = :cv8u, channel = 4, &block)
|
105
|
+
m = IplImage.new(width, height, depth, channel)
|
106
|
+
block = lambda { |j, i, c| CvScalar.new(*([c + 1] * channel)) } unless block_given?
|
107
|
+
count = 0
|
108
|
+
height.times { |j|
|
109
|
+
width.times { |i|
|
110
|
+
m[j, i] = block.call(j, i, count)
|
111
|
+
count += 1
|
112
|
+
}
|
113
|
+
}
|
114
|
+
m
|
115
|
+
end
|
116
|
+
|
117
|
+
def assert_each_cvscalar(actual, delta = 0, &block)
|
118
|
+
raise unless block_given?
|
119
|
+
count = 0
|
120
|
+
actual.height.times { |j|
|
121
|
+
actual.width.times { |i|
|
122
|
+
expected = block.call(j, i, count)
|
123
|
+
if delta == 0
|
124
|
+
expected = expected.to_ary if expected.is_a? CvScalar
|
125
|
+
assert_array_equal(expected, actual[j, i].to_ary)
|
126
|
+
else
|
127
|
+
assert_in_delta(expected, actual[j, i], delta)
|
128
|
+
end
|
129
|
+
count += 1
|
130
|
+
}
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
def print_cvmat(mat)
|
135
|
+
s = []
|
136
|
+
mat.height.times { |j|
|
137
|
+
a = []
|
138
|
+
mat.width.times { |i|
|
139
|
+
tmp = mat[j, i].to_ary.map {|m| m.to_f.round(2) }.join(',')
|
140
|
+
a << "[#{tmp}]"
|
141
|
+
}
|
142
|
+
s << a.join(' ')
|
143
|
+
}
|
144
|
+
puts s.join("\n")
|
145
|
+
end
|
146
|
+
|
147
|
+
def count_threshold(mat, threshold, &block)
|
148
|
+
n = 0
|
149
|
+
block = lambda { |a, b| a > b } unless block_given?
|
150
|
+
(mat.rows * mat.cols).times { |i|
|
151
|
+
n += 1 if block.call(mat[i][0], threshold)
|
152
|
+
}
|
153
|
+
n
|
154
|
+
end
|
155
|
+
|
156
|
+
def color_hists(mat)
|
157
|
+
hists = [0] * mat.channel
|
158
|
+
(mat.rows * mat.cols).times { |i|
|
159
|
+
hists.size.times { |c|
|
160
|
+
hists[c] += mat[i][c]
|
161
|
+
}
|
162
|
+
}
|
163
|
+
hists
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
data/test/runner.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- mode: ruby; coding: utf-8-unix -*-
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
src_testdir = File.dirname(File.expand_path(__FILE__))
|
6
|
+
if Test::Unit.methods.include? :setup_argv
|
7
|
+
srcdir = File.dirname(src_testdir)
|
8
|
+
Test::Unit.setup_argv {|files|
|
9
|
+
if files.empty?
|
10
|
+
[src_testdir]
|
11
|
+
else
|
12
|
+
files.map {|f|
|
13
|
+
if File.exist? "#{src_testdir}/#{f}"
|
14
|
+
"#{src_testdir}/#{f}"
|
15
|
+
elsif File.exist? "#{srcdir}/#{f}"
|
16
|
+
"#{srcdir}/#{f}"
|
17
|
+
elsif File.exist? f
|
18
|
+
f
|
19
|
+
else
|
20
|
+
raise ArgumentError, "not found: #{f}"
|
21
|
+
end
|
22
|
+
}
|
23
|
+
end
|
24
|
+
}
|
25
|
+
elsif Test::Unit.constants.map {|c| c.to_sym }.include? :AutoRunner
|
26
|
+
Test::Unit::AutoRunner.run(true, src_testdir)
|
27
|
+
else
|
28
|
+
raise 'Test runner not found'
|
29
|
+
end
|
30
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|