From 39f851f7fda4e46942e082cd71eb2f029c12a7c0 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Sun, 13 Oct 2013 02:08:51 +0900 Subject: [PATCH 01/10] fix issue #33 --- ext/opencv/extconf.rb | 27 +++++++++++++++++++++------ ext/opencv/opencv.cpp | 2 ++ ext/opencv/opencv.h | 5 ++++- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/ext/opencv/extconf.rb b/ext/opencv/extconf.rb index 576b4c7..8dc665e 100755 --- a/ext/opencv/extconf.rb +++ b/ext/opencv/extconf.rb @@ -23,48 +23,63 @@ opencv_headers = ["opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/img "opencv2/imgproc/imgproc.hpp", "opencv2/video/tracking.hpp", "opencv2/features2d/features2d.hpp", "opencv2/flann/flann.hpp", "opencv2/calib3d/calib3d.hpp", "opencv2/objdetect/objdetect.hpp", "opencv2/legacy/compat.hpp", "opencv2/legacy/legacy.hpp", "opencv2/highgui/highgui_c.h", - "opencv2/highgui/highgui.hpp", "opencv2/photo/photo.hpp", "opencv2/nonfree/nonfree.hpp"] + "opencv2/highgui/highgui.hpp", "opencv2/photo/photo.hpp"] + +opencv_headers_opt = ["opencv2/nonfree/nonfree.hpp"] opencv_libraries = ["opencv_calib3d", "opencv_contrib", "opencv_core", "opencv_features2d", - "opencv_flann", "opencv_gpu", "opencv_highgui", "opencv_imgproc", - "opencv_legacy", "opencv_ml", "opencv_objdetect", "opencv_video", - "opencv_photo", "opencv_nonfree"] - + "opencv_flann", "opencv_highgui", "opencv_imgproc", "opencv_legacy", + "opencv_ml", "opencv_objdetect", "opencv_video", "opencv_photo"] +opencv_libraries_opt = ["opencv_gpu", "opencv_nonfree"] puts ">> Check the required libraries..." case CONFIG["arch"] when /mswin32/ suffix = cv_version_suffix(incdir) opencv_libraries.map! {|lib| lib + suffix } + opencv_libraries_opt.map! {|lib| lib + suffix } have_library("msvcrt") opencv_libraries.each {|lib| raise "#{lib}.lib not found." unless have_library(lib) } + opencv_libraries_opt.each {|lib| + warn "#{lib}.lib not found." unless have_library(lib) + } $CFLAGS << ' /EHsc' when /mingw32/ suffix = cv_version_suffix(incdir) opencv_libraries.map! {|lib| lib + suffix } + opencv_libraries_opt.map! {|lib| lib + suffix } have_library("msvcrt") opencv_libraries.each {|lib| raise "lib#{lib} not found." unless have_library(lib) } + opencv_libraries_opt.each {|lib| + warn "lib#{lib} not found." unless have_library(lib) + } else opencv_libraries.each {|lib| raise "lib#{lib} not found." unless have_library(lib) } + opencv_libraries_opt.each {|lib| + warn "lib#{lib} not found." unless have_library(lib) + } have_library("stdc++") end # Check the required headers puts ">> Check the required headers..." opencv_headers.each {|header| + raise "#{header} not found." unless have_header(header) +} +opencv_headers_opt.each {|header| unless have_header(header) if CONFIG["arch"] =~ /mswin32/ and File.exists? "#{incdir}/#{header}" # In mswin32, have_header('opencv2/nonfree/nonfree.hpp') fails because of a syntax problem. warn "warning: #{header} found but `have_header` failed." $defs << "-DHAVE_#{header.tr_cpp}" else - raise "#{header} not found." + warn "#{header} not found." end end } diff --git a/ext/opencv/opencv.cpp b/ext/opencv/opencv.cpp index c51aee8..8577417 100644 --- a/ext/opencv/opencv.cpp +++ b/ext/opencv/opencv.cpp @@ -772,6 +772,8 @@ extern "C" { */ #endif +#ifdef HAVE_NONFREE_H cv::initModule_nonfree(); +#endif } } diff --git a/ext/opencv/opencv.h b/ext/opencv/opencv.h index 6bf5e42..78c3d8b 100644 --- a/ext/opencv/opencv.h +++ b/ext/opencv/opencv.h @@ -62,7 +62,6 @@ extern "C" { #include "opencv2/video/tracking.hpp" #include "opencv2/video/background_segm.hpp" #include "opencv2/features2d/features2d.hpp" -#include "opencv2/nonfree/nonfree.hpp" #include "opencv2/flann/flann.hpp" #include "opencv2/calib3d/calib3d.hpp" #include "opencv2/objdetect/objdetect.hpp" @@ -79,6 +78,10 @@ extern "C" { #include "opencv2/ml/ml.hpp" #endif +#ifdef HAVE_NONFREE_H +#include "opencv2/nonfree/nonfree.hpp" +#endif + // Ruby/OpenCV headers #include "cvutils.h" #include "cverror.h" From 4433b4719005aa75027cbfd24d1fe490a654597b Mon Sep 17 00:00:00 2001 From: ser1zw Date: Sun, 9 Feb 2014 19:40:59 +0900 Subject: [PATCH 02/10] fix #44 --- ext/opencv/extconf.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ext/opencv/extconf.rb b/ext/opencv/extconf.rb index 576b4c7..03dae4a 100755 --- a/ext/opencv/extconf.rb +++ b/ext/opencv/extconf.rb @@ -1,4 +1,11 @@ #!/usr/bin/env ruby + +CC = RbConfig::CONFIG['CC'] +if CC =~ /clang/ + RbConfig::MAKEFILE_CONFIG['try_header'] = :try_cpp + RbConfig::CONFIG['CPP'] = "#{CC} -E" +end + require "mkmf" def cv_version_suffix(incdir) From 30709a1db0727a103481c625d64d1877666ebb46 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Tue, 11 Feb 2014 01:15:11 +0900 Subject: [PATCH 03/10] fix for mswin32 --- ext/opencv/extconf.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/ext/opencv/extconf.rb b/ext/opencv/extconf.rb index 03dae4a..951acd2 100755 --- a/ext/opencv/extconf.rb +++ b/ext/opencv/extconf.rb @@ -4,6 +4,9 @@ CC = RbConfig::CONFIG['CC'] if CC =~ /clang/ RbConfig::MAKEFILE_CONFIG['try_header'] = :try_cpp RbConfig::CONFIG['CPP'] = "#{CC} -E" +elsif RbConfig::CONFIG['arch'] =~ /mswin32/ + RbConfig::MAKEFILE_CONFIG['try_header'] = :try_cpp + RbConfig::CONFIG['CPP'] = "#{CC} /P" end require "mkmf" @@ -65,15 +68,7 @@ end # Check the required headers puts ">> Check the required headers..." opencv_headers.each {|header| - unless have_header(header) - if CONFIG["arch"] =~ /mswin32/ and File.exists? "#{incdir}/#{header}" - # In mswin32, have_header('opencv2/nonfree/nonfree.hpp') fails because of a syntax problem. - warn "warning: #{header} found but `have_header` failed." - $defs << "-DHAVE_#{header.tr_cpp}" - else - raise "#{header} not found." - end - end + raise "#{header} not found." unless have_header(header) } have_header("stdarg.h") From 23c714fe6279d6390d6356446a2873e976613a52 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Tue, 11 Feb 2014 01:43:25 +0900 Subject: [PATCH 04/10] add compiler option to use C++ exception in mswin32 --- ext/opencv/extconf.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/opencv/extconf.rb b/ext/opencv/extconf.rb index 951acd2..7829562 100755 --- a/ext/opencv/extconf.rb +++ b/ext/opencv/extconf.rb @@ -51,6 +51,7 @@ when /mswin32/ raise "#{lib}.lib not found." unless have_library(lib) } $CFLAGS << ' /EHsc' + CONFIG['CXXFLAGS'] << ' /EHsc' when /mingw32/ suffix = cv_version_suffix(incdir) opencv_libraries.map! {|lib| lib + suffix } From 7378e57cab7b034a3bb5e7aaa7aacf76dc95d931 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Sat, 29 Mar 2014 17:12:01 +0900 Subject: [PATCH 05/10] fix #33 and #49 --- ext/opencv/extconf.rb | 2 +- ext/opencv/opencv.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/opencv/extconf.rb b/ext/opencv/extconf.rb index f3720b6..0fa94cd 100755 --- a/ext/opencv/extconf.rb +++ b/ext/opencv/extconf.rb @@ -84,7 +84,7 @@ opencv_headers.each {|header| raise "#{header} not found." unless have_header(header) } opencv_headers_opt.each {|header| - raise "#{header} not found." unless have_header(header) + warn "#{header} not found." unless have_header(header) } have_header("stdarg.h") diff --git a/ext/opencv/opencv.cpp b/ext/opencv/opencv.cpp index 7f6f7a2..de88cf8 100644 --- a/ext/opencv/opencv.cpp +++ b/ext/opencv/opencv.cpp @@ -771,7 +771,7 @@ extern "C" { */ #endif -#ifdef HAVE_NONFREE_H +#ifdef HAVE_OPENCV2_NONFREE_NONFREE_HPP cv::initModule_nonfree(); #endif } From 5931644656f9d4eb080ecb63f2bde7de2de2641d Mon Sep 17 00:00:00 2001 From: ser1zw Date: Sat, 29 Mar 2014 20:29:53 +0900 Subject: [PATCH 06/10] bugfix --- ext/opencv/opencv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/opencv/opencv.h b/ext/opencv/opencv.h index 2f20551..97dc19f 100644 --- a/ext/opencv/opencv.h +++ b/ext/opencv/opencv.h @@ -78,7 +78,7 @@ extern "C" { #include "opencv2/ml/ml.hpp" #endif -#ifdef HAVE_NONFREE_H +#ifdef HAVE_OPENCV2_NONFREE_NONFREE_HPP #include "opencv2/nonfree/nonfree.hpp" #endif From 1f31343d3661ae43f78ae516395984147bf2b072 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Sat, 29 Mar 2014 20:31:10 +0900 Subject: [PATCH 07/10] refactoring --- ext/opencv/extconf.rb | 48 +++++++++++-------------------------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/ext/opencv/extconf.rb b/ext/opencv/extconf.rb index 0fa94cd..1500fa5 100755 --- a/ext/opencv/extconf.rb +++ b/ext/opencv/extconf.rb @@ -34,7 +34,6 @@ opencv_headers = ["opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/img "opencv2/flann/flann.hpp", "opencv2/calib3d/calib3d.hpp", "opencv2/objdetect/objdetect.hpp", "opencv2/legacy/compat.hpp", "opencv2/legacy/legacy.hpp", "opencv2/highgui/highgui_c.h", "opencv2/highgui/highgui.hpp", "opencv2/photo/photo.hpp"] - opencv_headers_opt = ["opencv2/nonfree/nonfree.hpp"] opencv_libraries = ["opencv_calib3d", "opencv_contrib", "opencv_core", "opencv_features2d", @@ -43,49 +42,26 @@ opencv_libraries = ["opencv_calib3d", "opencv_contrib", "opencv_core", "opencv_f opencv_libraries_opt = ["opencv_gpu", "opencv_nonfree"] puts ">> Check the required libraries..." -case CONFIG["arch"] -when /mswin32/ +if $mswin or $mingw suffix = cv_version_suffix(incdir) - opencv_libraries.map! {|lib| lib + suffix } - opencv_libraries_opt.map! {|lib| lib + suffix } + opencv_libraries.map! { |lib| lib + suffix } + opencv_libraries_opt.map! { |lib| lib + suffix } have_library("msvcrt") - opencv_libraries.each {|lib| - raise "#{lib}.lib not found." unless have_library(lib) - } - opencv_libraries_opt.each {|lib| - warn "#{lib}.lib not found." unless have_library(lib) - } - $CFLAGS << ' /EHsc' - CONFIG['CXXFLAGS'] << ' /EHsc' -when /mingw32/ - suffix = cv_version_suffix(incdir) - opencv_libraries.map! {|lib| lib + suffix } - opencv_libraries_opt.map! {|lib| lib + suffix } - have_library("msvcrt") - opencv_libraries.each {|lib| - raise "lib#{lib} not found." unless have_library(lib) - } - opencv_libraries_opt.each {|lib| - warn "lib#{lib} not found." unless have_library(lib) - } + if $mswin + $CFLAGS << ' /EHsc' + CONFIG['CXXFLAGS'] << ' /EHsc' + end else - opencv_libraries.each {|lib| - raise "lib#{lib} not found." unless have_library(lib) - } - opencv_libraries_opt.each {|lib| - warn "lib#{lib} not found." unless have_library(lib) - } have_library("stdc++") end +opencv_libraries.each { |lib| raise "#{lib} not found." unless have_library(lib) } +opencv_libraries_opt.each { |lib| warn "#{lib} not found." unless have_library(lib) } + # Check the required headers puts ">> Check the required headers..." -opencv_headers.each {|header| - raise "#{header} not found." unless have_header(header) -} -opencv_headers_opt.each {|header| - warn "#{header} not found." unless have_header(header) -} +opencv_headers.each { |header| raise "#{header} not found." unless have_header(header) } +opencv_headers_opt.each { |header| warn "#{header} not found." unless have_header(header) } have_header("stdarg.h") if $warnflags From 0988544e225cf0df6960659995247860537bdacc Mon Sep 17 00:00:00 2001 From: ser1zw Date: Sat, 29 Mar 2014 20:46:21 +0900 Subject: [PATCH 08/10] update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 69897c1..4389b26 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ An OpenCV wrapper for Ruby. * Web site: -* Ruby 1.9.3, 2.0.0, 2.1.0 and OpenCV 2.4.8 are supported. +* Ruby 1.9.3, 2.0.0, 2.1.x and OpenCV 2.4.8 are supported. ## Requirement @@ -24,10 +24,10 @@ Note: **/path/to/opencvdir** is the directory where you installed OpenCV. ### Windows -You can use pre-build binary for Windows (mswin32, mingw32). +You can use pre-build binary for Windows (mswin32). 1. Install [OpenCV](http://sourceforge.net/projects/opencvlibrary/files/opencv-win/) -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. +2. Set path to OpenCV libraries. When you installed OpenCV to **C:\opencv**, add **C:\opencv\build\x86\vc10\bin** to the systems path. 3. Install ruby-opencv ``` From 95420e83aadbd9404ea3a2054771028d83af09c7 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Sun, 30 Mar 2014 17:43:44 +0900 Subject: [PATCH 09/10] update .yardopts --- .yardopts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.yardopts b/.yardopts index 5c78b63..b41ba95 100644 --- a/.yardopts +++ b/.yardopts @@ -1,3 +1,3 @@ ---load yard_extension.rb +--load ./yard_extension.rb ext/opencv/*.cpp From e31c2683c31a0cf14c9e88717f1406e8c1193450 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Sun, 30 Mar 2014 17:47:42 +0900 Subject: [PATCH 10/10] update gemspec --- ruby-opencv.gemspec | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ruby-opencv.gemspec b/ruby-opencv.gemspec index 32ec2cb..2399039 100644 --- a/ruby-opencv.gemspec +++ b/ruby-opencv.gemspec @@ -1,15 +1,15 @@ # -*- encoding: utf-8 -*- -# stub: ruby-opencv 0.0.12.20140119050230 ruby lib +# stub: ruby-opencv 0.0.12.20140330174646 ruby lib # stub: ext/opencv/extconf.rb Gem::Specification.new do |s| s.name = "ruby-opencv" - s.version = "0.0.12.20140119050230" + s.version = "0.0.12.20140330174646" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.require_paths = ["lib"] s.authors = ["lsxi", "ser1zw", "pcting"] - s.date = "2014-01-18" + s.date = "2014-03-30" 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." s.email = ["masakazu.yonekura@gmail.com", "azariahsawtikes@gmail.com", "pcting@gmail.com"] s.extensions = ["ext/opencv/extconf.rb"] @@ -18,8 +18,7 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/ruby-opencv/ruby-opencv/" s.licenses = ["The BSD License"] s.rdoc_options = ["--main", "README.md"] - s.rubyforge_project = "ruby-opencv" - s.rubygems_version = "2.2.1" + s.rubygems_version = "2.2.2" s.summary = "OpenCV wrapper for Ruby" s.test_files = ["test/test_cvcontour.rb", "test/test_eigenfaces.rb", "test/test_cvmoments.rb", "test/test_cvseq.rb", "test/test_cvcontourtree.rb", "test/test_cvbox2d.rb", "test/test_iplimage.rb", "test/test_cvvideowriter.rb", "test/test_cvline.rb", "test/test_cvhumoments.rb", "test/test_cvfont.rb", "test/test_cvconnectedcomp.rb", "test/test_cvhistogram.rb", "test/test_trackbar.rb", "test/test_cvmat_imageprocessing.rb", "test/test_cvhaarclassifiercascade.rb", "test/test_cvcircle32f.rb", "test/test_cvcapture.rb", "test/test_cvmat_dxt.rb", "test/test_cvrect.rb", "test/test_iplconvkernel.rb", "test/test_cvsurfpoint.rb", "test/test_cvavgcomp.rb", "test/test_cvscalar.rb", "test/test_pointset.rb", "test/test_curve.rb", "test/test_cvtermcriteria.rb", "test/test_cvtwopoints.rb", "test/test_cvsurfparams.rb", "test/test_cvpoint2d32f.rb", "test/test_cvpoint3d32f.rb", "test/test_cvfeaturetree.rb", "test/test_mouseevent.rb", "test/test_cvchain.rb", "test/test_cvmat.rb", "test/test_fisherfaces.rb", "test/test_cverror.rb", "test/test_cvpoint.rb", "test/test_cvsize2d32f.rb", "test/test_preliminary.rb", "test/test_cvmat_drawing.rb", "test/test_lbph.rb", "test/test_cvsize.rb", "test/test_window.rb", "test/test_cvslice.rb", "test/test_opencv.rb"] @@ -30,17 +29,17 @@ Gem::Specification.new do |s| s.add_development_dependency(%q, ["~> 4.0"]) s.add_development_dependency(%q, ["~> 0"]) s.add_development_dependency(%q, ["~> 0"]) - s.add_development_dependency(%q, ["~> 3.8"]) + s.add_development_dependency(%q, ["~> 3.10"]) else s.add_dependency(%q, ["~> 4.0"]) s.add_dependency(%q, ["~> 0"]) s.add_dependency(%q, ["~> 0"]) - s.add_dependency(%q, ["~> 3.8"]) + s.add_dependency(%q, ["~> 3.10"]) end else s.add_dependency(%q, ["~> 4.0"]) s.add_dependency(%q, ["~> 0"]) s.add_dependency(%q, ["~> 0"]) - s.add_dependency(%q, ["~> 3.8"]) + s.add_dependency(%q, ["~> 3.10"]) end end