diff --git a/README.rdoc b/README.rdoc index b216138..913d9df 100644 --- a/README.rdoc +++ b/README.rdoc @@ -14,7 +14,7 @@ OpenCV wrapper for Ruby == FEATURES/PROBLEMS: * Some OpenCV functions are wrapped. -* Ruby 1.8.7, 1.9.3 and OpenCV 2.3.1 are supported. +* Ruby 1.8.7, 1.9.3 and OpenCV 2.4.0 are supported. == DEPENDENCIES: @@ -35,7 +35,7 @@ OpenCV wrapper for Ruby $ git clone git://github.com/ruby-opencv/ruby-opencv.git $ cd ruby-opencv - $ git checkout master # for OpenCV 2.3 or later. To use OpenCV 2.2, type "git checkout OpenCV_2.2" instead + $ git checkout OpenCV_2.4 $ ruby extconf.rb --with-opencv-dir=/path/to/opencvdir $ make $ make install @@ -46,7 +46,7 @@ Use *nmake* instead of *make*. $ git clone git://github.com/ruby-opencv/ruby-opencv.git $ cd ruby-opencv - $ git checkout master # for OpenCV 2.3 or later. To use OpenCV 2.2, type "git checkout OpenCV_2.2" instead + $ git checkout OpenCV_2.4 $ ruby extconf.rb --with-opencv-dir=C:\path\to\opencvdir\install # for your own built OpenCV library $ nmake $ nmake install @@ -62,7 +62,7 @@ Type the following commands on the *MSYS* *console*. $ git clone git://github.com/ruby-opencv/ruby-opencv.git $ cd ruby-opencv - $ git checkout master # for OpenCV 2.3 or later. To use OpenCV 2.2, type "git checkout OpenCV_2.2" instead + $ git checkout OpenCV_2.4 $ ruby extconf.rb --with-opencv-dir=/C/path/to/opencvdir/install # for your own built OpenCV library $ make $ make install @@ -78,7 +78,7 @@ To use pre-built OpenCV libraries, set the following option to extconf.rb. For example, if you install OpenCV library to */opt/local/* like: - $ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/opt/local/ ./OpenCV-2.3.1 + $ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/opt/local/ ./OpenCV-2.4.0-beta2 $ make $ make install @@ -94,7 +94,7 @@ You can also install this library creating a gem like: $ git clone git://github.com/ruby-opencv/ruby-opencv.git $ cd ruby-opencv - $ git checkout master # for OpenCV 2.3 or later. To use OpenCV 2.2, type "git checkout OpenCV_2.2" instead + $ git checkout OpenCV_2.4 $ bundle install $ rake gem $ gem install pkg/opencv-*.gem -- --with-opencv-dir=/path/to/opencvdir diff --git a/ext/opencv/cverror.cpp b/ext/opencv/cverror.cpp index fd9232d..1c7bb04 100644 --- a/ext/opencv/cverror.cpp +++ b/ext/opencv/cverror.cpp @@ -139,8 +139,6 @@ void define_ruby_class() REGISTER_CVERROR("CvStsAssert", CV_StsAssert); REGISTER_CVERROR("CvGpuNotSupported", CV_GpuNotSupported); REGISTER_CVERROR("CvGpuApiCallError", CV_GpuApiCallError); - REGISTER_CVERROR("CvGpuNppCallError", CV_GpuNppCallError); - REGISTER_CVERROR("CvGpuCufftCallError", CV_GpuCufftCallError); } VALUE diff --git a/ext/opencv/cvfont.cpp b/ext/opencv/cvfont.cpp index 1437967..ef8d937 100644 --- a/ext/opencv/cvfont.cpp +++ b/ext/opencv/cvfont.cpp @@ -141,9 +141,13 @@ rb_initialize(int argc, VALUE *argv, VALUE self) } font_option = FONT_OPTION(font_option); + int font_face = NUM2INT(face); + if (FO_ITALIC(font_option)) { + font_face |= CV_FONT_ITALIC; + } try { cvInitFont(CVFONT(self), - (FIX2INT(face) | FO_ITALIC(font_option)), + font_face, FO_HSCALE(font_option), FO_VSCALE(font_option), FO_SHEAR(font_option), diff --git a/ext/opencv/cvmat.cpp b/ext/opencv/cvmat.cpp index 7990759..d419721 100644 --- a/ext/opencv/cvmat.cpp +++ b/ext/opencv/cvmat.cpp @@ -5404,8 +5404,8 @@ rb_optical_flow_bm(int argc, VALUE *argv, VALUE self) int use_previous = 0; try { CvSize image_size = cvGetSize(self_ptr); - CvSize velocity_size = cvSize((image_size.width - block_size.width) / shift_size.width, - (image_size.height - block_size.height) / shift_size.height); + CvSize velocity_size = cvSize((image_size.width - block_size.width + shift_size.width) / shift_size.width, + (image_size.height - block_size.height + shift_size.height) / shift_size.height); CvMat *velx_ptr, *vely_ptr; if (NIL_P(velx) && NIL_P(vely)) { int type = CV_MAKETYPE(CV_32F, 1); diff --git a/ext/opencv/opencv.cpp b/ext/opencv/opencv.cpp index 889339b..3247a17 100644 --- a/ext/opencv/opencv.cpp +++ b/ext/opencv/opencv.cpp @@ -695,5 +695,7 @@ extern "C" { mOpenCV::mMachineLearning::define_ruby_module(); */ #endif + + cv::initModule_nonfree(); } } diff --git a/ext/opencv/opencv.h b/ext/opencv/opencv.h index 388a7a0..eb5b440 100644 --- a/ext/opencv/opencv.h +++ b/ext/opencv/opencv.h @@ -62,6 +62,7 @@ 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" @@ -72,6 +73,7 @@ extern "C" { #include "opencv2/highgui/highgui_c.h" #include "opencv2/highgui/highgui.hpp" #include "opencv2/core/internal.hpp" +#include "opencv2/photo/photo.hpp" #ifdef HAVE_ML_H #include "opencv2/ml/ml.hpp" diff --git a/extconf.rb b/extconf.rb index 635dd3c..fb1bd8e 100755 --- a/extconf.rb +++ b/extconf.rb @@ -18,16 +18,17 @@ 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/highgui/highgui.hpp", "opencv2/photo/photo.hpp", "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_legacy", "opencv_ml", "opencv_objdetect", "opencv_video", + "opencv_photo", "opencv_nonfree"] puts ">> Check the required libraries..." -OPENCV_VERSION_SUFFIX = '231' +OPENCV_VERSION_SUFFIX = '240' case CONFIG["arch"] when /mswin32/ opencv_libraries.map! {|lib| lib + OPENCV_VERSION_SUFFIX } diff --git a/test/test_curve.rb b/test/test_curve.rb index ab806ca..8a1ffc8 100755 --- a/test/test_curve.rb +++ b/test/test_curve.rb @@ -36,8 +36,8 @@ class TestCurve < OpenCVTestCase def test_arc_length assert_in_delta(211.480, @contour2.arc_length, 0.001) - assert_in_delta(18.071, @contour2.arc_length(CvSlice.new(0, 9), true), 0.001) - assert_in_delta(18.071, @contour2.arc_length(0..10, true), 0.001) + assert_in_delta(32.181, @contour2.arc_length(CvSlice.new(0, 9), true), 0.001) + assert_in_delta(32.181, @contour2.arc_length(0..10, true), 0.001) end end diff --git a/test/test_cverror.rb b/test/test_cverror.rb index cc61196..55ed3ea 100755 --- a/test/test_cverror.rb +++ b/test/test_cverror.rb @@ -18,7 +18,7 @@ class TestCvError < OpenCVTestCase end def test_subclass - errors = [CvStsBackTrace, CvStsError, CvStsInternal, CvStsNoMem, CvStsBadArg, CvStsBadFunc, CvStsNoConv, CvStsAutoTrace, CvHeaderIsNull, CvBadImageSize, CvBadOffset, CvBadDataPtr, CvBadStep, CvBadModelOrChSeq, CvBadNumChannels, CvBadNumChannel1U, CvBadDepth, CvBadAlphaChannel, CvBadOrder, CvBadOrigin, CvBadAlign, CvBadCallBack, CvBadTileSize, CvBadCOI, CvBadROISize, CvMaskIsTiled, CvStsNullPtr, CvStsVecLengthErr, CvStsFilterStructContentErr, CvStsKernelStructContentErr, CvStsFilterOffsetErr, CvStsBadSize, CvStsDivByZero, CvStsInplaceNotSupported, CvStsObjectNotFound, CvStsUnmatchedFormats, CvStsBadFlag, CvStsBadPoint, CvStsBadMask, CvStsUnmatchedSizes, CvStsUnsupportedFormat, CvStsOutOfRange, CvStsParseError, CvStsNotImplemented, CvStsBadMemBlock, CvStsAssert, CvGpuNotSupported, CvGpuApiCallError, CvGpuNppCallError, CvGpuCufftCallError] + errors = [CvStsBackTrace, CvStsError, CvStsInternal, CvStsNoMem, CvStsBadArg, CvStsBadFunc, CvStsNoConv, CvStsAutoTrace, CvHeaderIsNull, CvBadImageSize, CvBadOffset, CvBadDataPtr, CvBadStep, CvBadModelOrChSeq, CvBadNumChannels, CvBadNumChannel1U, CvBadDepth, CvBadAlphaChannel, CvBadOrder, CvBadOrigin, CvBadAlign, CvBadCallBack, CvBadTileSize, CvBadCOI, CvBadROISize, CvMaskIsTiled, CvStsNullPtr, CvStsVecLengthErr, CvStsFilterStructContentErr, CvStsKernelStructContentErr, CvStsFilterOffsetErr, CvStsBadSize, CvStsDivByZero, CvStsInplaceNotSupported, CvStsObjectNotFound, CvStsUnmatchedFormats, CvStsBadFlag, CvStsBadPoint, CvStsBadMask, CvStsUnmatchedSizes, CvStsUnsupportedFormat, CvStsOutOfRange, CvStsParseError, CvStsNotImplemented, CvStsBadMemBlock, CvStsAssert, CvGpuNotSupported, CvGpuApiCallError] errors.each { |err| assert_equal(CvError, err.superclass) diff --git a/test/test_opencv.rb b/test/test_opencv.rb index cf21cbd..2ef9bb1 100755 --- a/test/test_opencv.rb +++ b/test/test_opencv.rb @@ -9,10 +9,10 @@ include OpenCV class TestOpenCV < OpenCVTestCase def test_constants # OpenCV version - assert_equal('2.3.1', CV_VERSION) + assert_equal('2.4.0', CV_VERSION) assert_equal(2, CV_MAJOR_VERSION) - assert_equal(3, CV_MINOR_VERSION) - assert_equal(1, CV_SUBMINOR_VERSION) + assert_equal(4, CV_MINOR_VERSION) + assert_equal(0, CV_SUBMINOR_VERSION) # Depths assert_equal(0, CV_8U)