ruby-opencv 0.0.8.pre-mswin32 → 0.0.9.pre2-mswin32
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.
- checksums.yaml +7 -0
- data/DEVELOPERS_NOTE.md +137 -0
- data/Gemfile +1 -1
- data/License.txt +30 -30
- data/Manifest.txt +7 -5
- data/README.md +98 -0
- data/Rakefile +63 -5
- data/config.yml +7 -0
- data/examples/alpha_blend.rb +21 -21
- data/examples/find_obj.rb +169 -169
- data/examples/match_kdtree.rb +88 -88
- data/ext/opencv/cvcapture.cpp +19 -12
- data/ext/opencv/cvutils.cpp +192 -194
- data/ext/opencv/cvutils.h +30 -29
- data/{extconf.rb → ext/opencv/extconf.rb} +12 -4
- data/lib/opencv.rb +12 -3
- data/lib/opencv/psyched_yaml.rb +22 -22
- data/lib/opencv/version.rb +1 -1
- data/ruby-opencv.gemspec +44 -43
- data/test/helper.rb +1 -1
- data/test/runner.rb +30 -30
- data/test/test_curve.rb +1 -1
- data/test/test_cvavgcomp.rb +24 -24
- data/test/test_cvbox2d.rb +76 -76
- data/test/test_cvcapture.rb +183 -183
- data/test/test_cvchain.rb +108 -108
- data/test/test_cvcircle32f.rb +41 -41
- data/test/test_cvconnectedcomp.rb +61 -61
- data/test/test_cvcontour.rb +150 -150
- data/test/test_cvcontourtree.rb +43 -43
- data/test/test_cverror.rb +1 -1
- data/test/test_cvfeaturetree.rb +65 -65
- data/test/test_cvfont.rb +58 -58
- data/test/test_cvhaarclassifiercascade.rb +63 -63
- data/test/test_cvhistogram.rb +1 -1
- data/test/test_cvhumoments.rb +83 -83
- data/test/test_cvline.rb +50 -50
- data/test/test_cvmat.rb +1 -1
- data/test/test_cvmat_drawing.rb +1 -1
- data/test/test_cvmat_dxt.rb +1 -1
- data/test/test_cvmat_imageprocessing.rb +1 -1
- data/test/test_cvmat_matching.rb +1 -1
- data/test/test_cvmoments.rb +180 -180
- data/test/test_cvpoint.rb +75 -75
- data/test/test_cvpoint2d32f.rb +75 -75
- data/test/test_cvpoint3d32f.rb +93 -93
- data/test/test_cvrect.rb +144 -144
- data/test/test_cvscalar.rb +113 -113
- data/test/test_cvseq.rb +295 -295
- data/test/test_cvsize.rb +75 -75
- data/test/test_cvsize2d32f.rb +75 -75
- data/test/test_cvslice.rb +31 -31
- data/test/test_cvsurfparams.rb +57 -57
- data/test/test_cvsurfpoint.rb +66 -66
- data/test/test_cvtermcriteria.rb +56 -56
- data/test/test_cvtwopoints.rb +40 -40
- data/test/test_cvvideowriter.rb +58 -58
- data/test/test_iplconvkernel.rb +54 -54
- data/test/test_iplimage.rb +1 -1
- data/test/test_mouseevent.rb +17 -17
- data/test/test_opencv.rb +1 -1
- data/test/test_pointset.rb +1 -1
- data/test/test_preliminary.rb +130 -130
- data/test/test_trackbar.rb +47 -47
- data/test/test_window.rb +115 -115
- metadata +28 -56
- data/README.rdoc +0 -149
- data/ext/opencv/lib/opencv.rb +0 -3
- data/ext/opencv/lib/opencv/psyched_yaml.rb +0 -22
- data/ext/opencv/lib/opencv/version.rb +0 -3
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1c537ec10efac9d5e231685ac6adeaff0253d370
|
4
|
+
data.tar.gz: aaceb07211c27b308b2da2c8f1d509e71924556f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 924321f87474eb144e53bc4da9d71d5aa0693d9c2a84c3809dae4226be929d387a511a52ed88de226436e4c8c489f6af00b509c9524895125519155a7eb5daaf
|
7
|
+
data.tar.gz: 54f844f2394bf49a4c050e8cae1326db68d46e5c71fc2e26c7b03640bb53ed80e81ddcc8381404ec9509c38e2cfd1dacaa1240a85035ee983e9b0dd0721d03af
|
data/DEVELOPERS_NOTE.md
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
# DEVELOPER'S NOTE
|
2
|
+
|
3
|
+
## Requirement to develop ruby-opencv
|
4
|
+
|
5
|
+
* OpenCV
|
6
|
+
* Git
|
7
|
+
* Microsoft Visual C++ (for mswin32)
|
8
|
+
* <http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express>
|
9
|
+
* MinGW and MSYS (for mingw32)
|
10
|
+
* gcc, g++ and MSYS are needed.
|
11
|
+
* <http://www.mingw.org>
|
12
|
+
* Some gems (see Gemfile)
|
13
|
+
* [bundler](https://github.com/carlhuda/bundler/)
|
14
|
+
* [hoe](https://github.com/seattlerb/hoe)
|
15
|
+
* [hoe-gemspec](https://github.com/flavorjones/hoe-gemspec)
|
16
|
+
* [rake-compiler](https://github.com/luislavena/rake-compiler)
|
17
|
+
|
18
|
+
|
19
|
+
## Create ruby-opencv gem
|
20
|
+
Run the following commands.
|
21
|
+
When you use mingw32, use **MSYS console**, or when you use mswin32,
|
22
|
+
use [**Visual Studio Command Prompt**](http://msdn.microsoft.com/en-us/library/ms229859.aspx)
|
23
|
+
instead of cmd.exe.
|
24
|
+
|
25
|
+
```
|
26
|
+
$ git clone git://github.com/ruby-opencv/ruby-opencv.git
|
27
|
+
$ cd ruby-opencv
|
28
|
+
$ git checkout master
|
29
|
+
$ bundle install
|
30
|
+
$ git ls-files > Manifest.txt
|
31
|
+
$ rake gem:spec
|
32
|
+
$ rake gem
|
33
|
+
```
|
34
|
+
**ruby-opencv-x.y.z.gem** will be created in **pkg** directory.
|
35
|
+
|
36
|
+
To create pre-build binaries, create a config file firstly:
|
37
|
+
|
38
|
+
```yml
|
39
|
+
# config.yml
|
40
|
+
platform: mingw32
|
41
|
+
rubies:
|
42
|
+
- C:/ruby-1.9.3-p392-mingw32/bin/ruby.exe
|
43
|
+
- C:/ruby-2.0.0-p0-mingw32/bin/ruby.exe
|
44
|
+
extopts:
|
45
|
+
- --with-opencv-include=C:/opencv/build/include
|
46
|
+
- --with-opencv-lib=C:/opencv/build/x86/mingw/lib
|
47
|
+
```
|
48
|
+
|
49
|
+
Entries are below:
|
50
|
+
|
51
|
+
- **platform**: Target platform (e.g. mingw32, mswin32)
|
52
|
+
- **rubies**: Array of target versions of ruby's paths (You can create fat gems if you specify multiple versions of ruby)
|
53
|
+
- **extopts**: Array of options to be passed to **extconf.rb**
|
54
|
+
|
55
|
+
Then, run the following command:
|
56
|
+
|
57
|
+
```
|
58
|
+
$ rake gem:precompile CONFIG=config.yml
|
59
|
+
```
|
60
|
+
|
61
|
+
**ruby-opencv-x.y.z-mingw32.gem** will be created when you use mingw32, or
|
62
|
+
**ruby-opencv-x.y.z-x86-mswin32.gem** when you use mswin32.
|
63
|
+
|
64
|
+
|
65
|
+
## Install ruby-opencv manually
|
66
|
+
### Linux/Mac
|
67
|
+
|
68
|
+
```
|
69
|
+
$ git clone git://github.com/ruby-opencv/ruby-opencv.git
|
70
|
+
$ cd ruby-opencv
|
71
|
+
$ git checkout master
|
72
|
+
$ ruby ext/opencv/extconf.rb --with-opencv-dir=/path/to/opencvdir
|
73
|
+
$ make
|
74
|
+
$ make install
|
75
|
+
```
|
76
|
+
|
77
|
+
Note: **/path/to/opencvdir** is the directory where you installed OpenCV.
|
78
|
+
|
79
|
+
|
80
|
+
### Windows (mswin32)
|
81
|
+
|
82
|
+
Run the following commands on [**Visual Studio Command Prompt**](http://msdn.microsoft.com/en-us/library/ms229859.aspx).
|
83
|
+
|
84
|
+
```
|
85
|
+
$ git clone git://github.com/ruby-opencv/ruby-opencv.git
|
86
|
+
$ cd ruby-opencv
|
87
|
+
$ git checkout master
|
88
|
+
$ ruby ext/opencv/extconf.rb --with-opencv-dir=C:\path\to\opencvdir\install # for your own built OpenCV library
|
89
|
+
$ nmake
|
90
|
+
$ nmake install
|
91
|
+
```
|
92
|
+
|
93
|
+
To use pre-built OpenCV libraries, set the following option to extconf.rb.
|
94
|
+
|
95
|
+
```
|
96
|
+
$ ruby ext/opencv/extconf.rb --with-opencv-include=C:\path\to\opencvdir\build\include --with-opencv-lib=C:\path\to\opencvdir\build\x86\vc10\lib
|
97
|
+
```
|
98
|
+
|
99
|
+
|
100
|
+
### Windows (mingw32)
|
101
|
+
|
102
|
+
Run the following commands on **MSYS console**.
|
103
|
+
|
104
|
+
```
|
105
|
+
$ git clone git://github.com/ruby-opencv/ruby-opencv.git
|
106
|
+
$ cd ruby-opencv
|
107
|
+
$ git checkout master
|
108
|
+
$ ruby ext/opencv/extconf.rb --with-opencv-dir=/C/path/to/opencvdir/install # for your own built OpenCV library
|
109
|
+
$ make
|
110
|
+
$ make install
|
111
|
+
```
|
112
|
+
|
113
|
+
To use pre-built OpenCV libraries, set the following option to extconf.rb.
|
114
|
+
|
115
|
+
```
|
116
|
+
$ ruby ext/opencv/extconf.rb --with-opencv-include=/c/path/to/opencvdir/build/include --with-opencv-lib=/c/path/to/opencvdir/build/x86/mingw/lib
|
117
|
+
```
|
118
|
+
|
119
|
+
|
120
|
+
## Run tests
|
121
|
+
|
122
|
+
To run all tests, run **test/runner.rb**
|
123
|
+
|
124
|
+
```
|
125
|
+
$ cd ruby-opencv/test
|
126
|
+
$ ruby runner.rb
|
127
|
+
```
|
128
|
+
|
129
|
+
To run tests of the specified function, run a specific test with --name option.
|
130
|
+
|
131
|
+
The following sample runs tests for CvMat#initialize
|
132
|
+
|
133
|
+
```
|
134
|
+
$ cd ruby-opencv/test
|
135
|
+
$ ruby test_cvmat.rb --name=test_initialize
|
136
|
+
```
|
137
|
+
|
data/Gemfile
CHANGED
data/License.txt
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
The BSD
|
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.
|
1
|
+
The BSD License
|
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.
|
data/Manifest.txt
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
.gitignore
|
2
|
+
DEVELOPERS_NOTE.md
|
2
3
|
Gemfile
|
3
4
|
History.txt
|
4
5
|
License.txt
|
5
6
|
Manifest.txt
|
6
|
-
README.
|
7
|
+
README.md
|
7
8
|
Rakefile
|
9
|
+
config.yml
|
8
10
|
examples/alpha_blend.rb
|
9
11
|
examples/box.png
|
10
12
|
examples/box_in_scene.png
|
@@ -108,15 +110,13 @@ ext/opencv/cvutils.cpp
|
|
108
110
|
ext/opencv/cvutils.h
|
109
111
|
ext/opencv/cvvideowriter.cpp
|
110
112
|
ext/opencv/cvvideowriter.h
|
113
|
+
ext/opencv/extconf.rb
|
111
114
|
ext/opencv/gui.cpp
|
112
115
|
ext/opencv/gui.h
|
113
116
|
ext/opencv/iplconvkernel.cpp
|
114
117
|
ext/opencv/iplconvkernel.h
|
115
118
|
ext/opencv/iplimage.cpp
|
116
119
|
ext/opencv/iplimage.h
|
117
|
-
ext/opencv/lib/opencv.rb
|
118
|
-
ext/opencv/lib/opencv/psyched_yaml.rb
|
119
|
-
ext/opencv/lib/opencv/version.rb
|
120
120
|
ext/opencv/mouseevent.cpp
|
121
121
|
ext/opencv/mouseevent.h
|
122
122
|
ext/opencv/opencv.cpp
|
@@ -127,11 +127,13 @@ ext/opencv/trackbar.cpp
|
|
127
127
|
ext/opencv/trackbar.h
|
128
128
|
ext/opencv/window.cpp
|
129
129
|
ext/opencv/window.h
|
130
|
-
extconf.rb
|
131
130
|
images/CvMat_sobel.png
|
132
131
|
images/CvMat_sub_rect.png
|
133
132
|
images/CvSeq_relationmap.png
|
134
133
|
images/face_detect_from_lena.jpg
|
134
|
+
lib/opencv.rb
|
135
|
+
lib/opencv/psyched_yaml.rb
|
136
|
+
lib/opencv/version.rb
|
135
137
|
ruby-opencv.gemspec
|
136
138
|
test/helper.rb
|
137
139
|
test/runner.rb
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# ruby-opencv
|
2
|
+
|
3
|
+
An OpenCV wrapper for Ruby.
|
4
|
+
|
5
|
+
* Web site: <https://github.com/ruby-opencv/ruby-opencv>
|
6
|
+
* Ruby 1.9.3, 2.0.0 and OpenCV 2.4.5 are supported.
|
7
|
+
|
8
|
+
## Requirement
|
9
|
+
|
10
|
+
* OpenCV <http://opencv.org/>
|
11
|
+
* [Download](http://sourceforge.net/projects/opencvlibrary/)
|
12
|
+
* [Install guide](http://docs.opencv.org/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.html#table-of-content-introduction)
|
13
|
+
|
14
|
+
## Install
|
15
|
+
### Linux/Mac
|
16
|
+
1. Install [OpenCV](http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/)
|
17
|
+
2. Install ruby-opencv
|
18
|
+
|
19
|
+
```
|
20
|
+
$ gem install ruby-opencv -- --with-opencv-dir=/path/to/opencvdir
|
21
|
+
```
|
22
|
+
|
23
|
+
Note: **/path/to/opencvdir** is the directory where you installed OpenCV.
|
24
|
+
|
25
|
+
|
26
|
+
### Windows
|
27
|
+
You can use pre-build binary for Windows (mswin32, mingw32).
|
28
|
+
|
29
|
+
1. Install [OpenCV](http://sourceforge.net/projects/opencvlibrary/files/opencv-win/)
|
30
|
+
2. Set path to OpenCV libraries. When you installed OpenCV to **C:\opencv**, add **C:\opencv\build\x86\vc10\bin (for mswin32)** or **C:\opencv\build\x86\mingw\bin (for mingw32)** to the systems path.
|
31
|
+
3. Install ruby-opencv
|
32
|
+
|
33
|
+
```
|
34
|
+
$ gem install ruby-opencv
|
35
|
+
```
|
36
|
+
|
37
|
+
## Sample code
|
38
|
+
### Load and Display an Image
|
39
|
+
|
40
|
+
A sample to load and display an image. An equivalent code of [this tutorial](http://docs.opencv.org/doc/tutorials/introduction/display_image/display_image.html#display-image).
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
require 'opencv'
|
44
|
+
include OpenCV
|
45
|
+
|
46
|
+
if ARGV.size == 0
|
47
|
+
puts "Usage: ruby #{__FILE__} ImageToLoadAndDisplay"
|
48
|
+
exit
|
49
|
+
end
|
50
|
+
|
51
|
+
image = nil
|
52
|
+
begin
|
53
|
+
image = CvMat.load(ARGV[0], CV_LOAD_IMAGE_COLOR) # Read the file.
|
54
|
+
rescue
|
55
|
+
puts 'Could not open or find the image.'
|
56
|
+
exit
|
57
|
+
end
|
58
|
+
|
59
|
+
window = GUI::Window.new('Display window') # Create a window for display.
|
60
|
+
window.show(image) # Show our image inside it.
|
61
|
+
GUI::wait_key # Wait for a keystroke in the window.
|
62
|
+
```
|
63
|
+
|
64
|
+
### Face Detection
|
65
|
+
|
66
|
+
A sample to detect faces from an image.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
require 'opencv'
|
70
|
+
include OpenCV
|
71
|
+
|
72
|
+
if ARGV.length < 2
|
73
|
+
puts "Usage: ruby #{__FILE__} source dest"
|
74
|
+
exit
|
75
|
+
end
|
76
|
+
|
77
|
+
data = './data/haarcascades/haarcascade_frontalface_alt.xml'
|
78
|
+
detector = CvHaarClassifierCascade::load(data)
|
79
|
+
image = CvMat.load(ARGV[0])
|
80
|
+
detector.detect_objects(image).each do |region|
|
81
|
+
color = CvColor::Blue
|
82
|
+
image.rectangle! region.top_left, region.bottom_right, :color => color
|
83
|
+
end
|
84
|
+
|
85
|
+
image.save_image(ARGV[1])
|
86
|
+
window = GUI::Window.new('Face detection')
|
87
|
+
window.show(image)
|
88
|
+
GUI::wait_key
|
89
|
+
```
|
90
|
+
|
91
|
+
For more samples, see examples/*.rb
|
92
|
+
|
93
|
+
## LICENSE:
|
94
|
+
|
95
|
+
The BSD Liscense
|
96
|
+
|
97
|
+
see LICENSE.txt
|
98
|
+
|
data/Rakefile
CHANGED
@@ -1,27 +1,36 @@
|
|
1
|
-
# -*- mode: ruby; coding: utf-8
|
1
|
+
# -*- mode: ruby; coding: utf-8 -*-
|
2
2
|
require 'rubygems'
|
3
|
-
require
|
3
|
+
require "rubygems/ext"
|
4
|
+
require "rubygems/installer"
|
4
5
|
require 'hoe'
|
5
6
|
require 'rake/extensiontask'
|
7
|
+
require 'fileutils'
|
8
|
+
require './lib/opencv/psyched_yaml'
|
9
|
+
|
10
|
+
SO_FILE = 'opencv.so'
|
6
11
|
|
7
12
|
Hoe.plugin :gemspec
|
8
13
|
|
9
14
|
hoespec = Hoe.spec 'ruby-opencv' do |s|
|
10
15
|
s.summary = 'OpenCV wrapper for Ruby'
|
16
|
+
s.description = 'ruby-opencv is a wrapper of OpenCV for Ruby. It helps you to write computer vision programs (e.g. detecting faces from pictures) with Ruby.'
|
17
|
+
s.licenses = ['The BSD License']
|
11
18
|
s.developer('lsxi', 'masakazu.yonekura@gmail.com')
|
12
19
|
s.developer('ser1zw', 'azariahsawtikes@gmail.com')
|
13
20
|
s.developer('pcting', 'pcting@gmail.com')
|
14
21
|
|
15
|
-
s.readme_file = 'README.
|
22
|
+
s.readme_file = 'README.md'
|
16
23
|
s.history_file = 'History.txt'
|
17
|
-
|
24
|
+
|
25
|
+
s.spec_extras = { :extensions => ['ext/opencv/extconf.rb'] }
|
26
|
+
|
18
27
|
s.test_globs = ['test/test_*.rb']
|
19
28
|
s.urls = ['https://github.com/ruby-opencv/ruby-opencv/']
|
20
29
|
|
21
30
|
s.extra_dev_deps << ['rake-compiler', '>= 0'] << ['hoe-gemspec']
|
22
31
|
|
23
32
|
Rake::ExtensionTask.new('opencv', spec) do |ext|
|
24
|
-
ext.lib_dir =
|
33
|
+
ext.lib_dir = 'lib'
|
25
34
|
end
|
26
35
|
end
|
27
36
|
|
@@ -29,4 +38,53 @@ hoespec.spec.files.delete('.gemtest')
|
|
29
38
|
|
30
39
|
Rake::Task[:test].prerequisites << :compile
|
31
40
|
|
41
|
+
desc 'Create a pre-compiled gem'
|
42
|
+
task 'gem:precompile' => ['gem'] do
|
43
|
+
tmp_dir = Dir.mktmpdir('tmp', '.')
|
44
|
+
gemfile = Dir.glob("pkg/*.gem")[0]
|
45
|
+
target_dir = File.join(tmp_dir, File.basename(gemfile, '.gem'))
|
46
|
+
|
47
|
+
installer = Gem::Installer.new(gemfile)
|
48
|
+
installer.unpack(target_dir)
|
49
|
+
|
50
|
+
gemspec = installer.spec
|
51
|
+
extension = gemspec.extensions[0]
|
52
|
+
gemspec.extensions.clear
|
53
|
+
|
54
|
+
config = ENV['CONFIG'] ? YAML.load_file(ENV['CONFIG']) : {}
|
55
|
+
rubies = config['rubies'] || [Gem.ruby]
|
56
|
+
args = config['extopts'] || []
|
57
|
+
gemspec.platform = config['platform'] || Gem::Platform::CURRENT
|
58
|
+
|
59
|
+
multi = rubies.size > 1
|
60
|
+
rubies.each { |ruby|
|
61
|
+
lib_dir = 'lib'
|
62
|
+
if multi
|
63
|
+
major, minor, _ = `#{ruby} -e "print RUBY_VERSION"`.chomp.split('.')
|
64
|
+
lib_dir = File.join(lib_dir, [major, minor].join('.'))
|
65
|
+
end
|
66
|
+
|
67
|
+
make_cmd = (`#{ruby} -e "print RUBY_PLATFORM"` =~ /mswin/) ? 'nmake' : 'make'
|
68
|
+
Dir.chdir(target_dir) {
|
69
|
+
cmd = [ruby, extension, *args].join(' ')
|
70
|
+
results = []
|
71
|
+
Gem::Ext::ExtConfBuilder.run(cmd, results)
|
72
|
+
Gem::Ext::ExtConfBuilder.make('', results)
|
73
|
+
|
74
|
+
FileUtils.mkdir_p lib_dir
|
75
|
+
FileUtils.mv SO_FILE, lib_dir
|
76
|
+
sh "#{make_cmd} clean"
|
77
|
+
}
|
78
|
+
|
79
|
+
gemspec.files << File.join(lib_dir, SO_FILE)
|
80
|
+
}
|
81
|
+
|
82
|
+
Dir.chdir(target_dir) {
|
83
|
+
gemfile = Gem::Package.build(gemspec)
|
84
|
+
FileUtils.mv gemfile, File.dirname(__FILE__)
|
85
|
+
}
|
86
|
+
|
87
|
+
FileUtils.rm_rf tmp_dir
|
88
|
+
end
|
89
|
+
|
32
90
|
# vim: syntax=ruby
|