mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
fixed for installing on Windows (mswin32)
This commit is contained in:
parent
fcc66a0180
commit
d37cefb3aa
9 changed files with 5516 additions and 5495 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -3,6 +3,8 @@
|
||||||
examples/data
|
examples/data
|
||||||
*.o
|
*.o
|
||||||
*.so
|
*.so
|
||||||
|
*.obj
|
||||||
|
*.pdb
|
||||||
Makefile
|
Makefile
|
||||||
mkmf.log
|
mkmf.log
|
||||||
opencv.bundle
|
opencv.bundle
|
||||||
|
@ -14,6 +16,7 @@ OpenCV-*
|
||||||
ruby-*
|
ruby-*
|
||||||
ext/opencv/test.txt
|
ext/opencv/test.txt
|
||||||
pkg/
|
pkg/
|
||||||
|
doc/
|
||||||
log.txt
|
log.txt
|
||||||
videowriter_result.avi
|
videowriter_result.avi
|
||||||
examples/contours/rotated-boxes-with-detected-bounding-rectangles.jpg
|
examples/contours/rotated-boxes-with-detected-bounding-rectangles.jpg
|
||||||
|
|
12
README.rdoc
12
README.rdoc
|
@ -33,6 +33,7 @@ See http://www.haible.de/bruno/packages-ffcall.html
|
||||||
|
|
||||||
== INSTALLATION:
|
== INSTALLATION:
|
||||||
=== Install Ruby/OpenCV manually
|
=== Install Ruby/OpenCV manually
|
||||||
|
==== Unix/Linux/Mac
|
||||||
|
|
||||||
$ git clone git://github.com/ser1zw/ruby-opencv.git
|
$ git clone git://github.com/ser1zw/ruby-opencv.git
|
||||||
$ cd ruby-opencv
|
$ cd ruby-opencv
|
||||||
|
@ -41,6 +42,17 @@ See http://www.haible.de/bruno/packages-ffcall.html
|
||||||
$ make
|
$ make
|
||||||
$ make install
|
$ make install
|
||||||
|
|
||||||
|
==== Windows (mswin32)
|
||||||
|
Use "nmake" instead of "make".
|
||||||
|
|
||||||
|
$ git clone git://github.com/ser1zw/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
|
||||||
|
$ ruby extconf.rb --with-opencv-dir=/path/to/opencvdir
|
||||||
|
$ nmake
|
||||||
|
$ nmake install
|
||||||
|
|
||||||
|
|
||||||
*/path/to/opencvdir* is the path you installs OpenCV library (default: /usr/local).
|
*/path/to/opencvdir* is the path you installs OpenCV library (default: /usr/local).
|
||||||
|
|
||||||
For example, if you install OpenCV library to */opt/local/* like:
|
For example, if you install OpenCV library to */opt/local/* like:
|
||||||
|
|
|
@ -120,7 +120,7 @@ cvcapture_free(void *ptr)
|
||||||
VALUE
|
VALUE
|
||||||
rb_open(int argc, VALUE *argv, VALUE self)
|
rb_open(int argc, VALUE *argv, VALUE self)
|
||||||
{
|
{
|
||||||
VALUE device, interface;
|
VALUE device;
|
||||||
rb_scan_args(argc, argv, "01", &device);
|
rb_scan_args(argc, argv, "01", &device);
|
||||||
CvCapture *capture = 0;
|
CvCapture *capture = 0;
|
||||||
try {
|
try {
|
||||||
|
@ -131,12 +131,13 @@ rb_open(int argc, VALUE *argv, VALUE self)
|
||||||
case T_FIXNUM:
|
case T_FIXNUM:
|
||||||
capture = cvCaptureFromCAM(FIX2INT(device));
|
capture = cvCaptureFromCAM(FIX2INT(device));
|
||||||
break;
|
break;
|
||||||
case T_SYMBOL:
|
case T_SYMBOL: {
|
||||||
interface = rb_hash_aref(rb_const_get(rb_class(), rb_intern("INTERFACE")), device);
|
VALUE cap_index = rb_hash_aref(rb_const_get(rb_class(), rb_intern("INTERFACE")), device);
|
||||||
if (NIL_P(interface))
|
if (NIL_P(cap_index))
|
||||||
rb_raise(rb_eArgError, "undefined interface.");
|
rb_raise(rb_eArgError, "undefined interface.");
|
||||||
capture = cvCaptureFromCAM(NUM2INT(interface));
|
capture = cvCaptureFromCAM(NUM2INT(cap_index));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case T_NIL:
|
case T_NIL:
|
||||||
capture = cvCaptureFromCAM(CV_CAP_ANY);
|
capture = cvCaptureFromCAM(CV_CAP_ANY);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -76,6 +76,7 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
|
||||||
CVCONNECTEDCOMP(self)->rect = *CVRECT(rect);
|
CVCONNECTEDCOMP(self)->rect = *CVRECT(rect);
|
||||||
if (!NIL_P(contour))
|
if (!NIL_P(contour))
|
||||||
CVCONNECTEDCOMP(self)->contour = CVSEQ(contour);
|
CVCONNECTEDCOMP(self)->contour = CVSEQ(contour);
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -51,7 +51,7 @@ rb_allocate(VALUE klass)
|
||||||
return OPENCV_OBJECT(klass, 0);
|
return OPENCV_OBJECT(klass, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
void
|
||||||
cvhaarclassifiercascade_free(void* ptr)
|
cvhaarclassifiercascade_free(void* ptr)
|
||||||
{
|
{
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
|
@ -150,7 +150,7 @@ rb_detect_objects(int argc, VALUE *argv, VALUE self)
|
||||||
|
|
||||||
VALUE result = Qnil;
|
VALUE result = Qnil;
|
||||||
try {
|
try {
|
||||||
CvSeq *seq = cvHaarDetectObjects(CVMAT_WITH_CHECK(image), CVHAARCLASSIFIERCASCADE(self), CVMEMSTORAGE(storage_val),
|
CvSeq *seq = cvHaarDetectObjects(CVARR_WITH_CHECK(image), CVHAARCLASSIFIERCASCADE(self), CVMEMSTORAGE(storage_val),
|
||||||
scale_factor, min_neighbors, flags, min_size, max_size);
|
scale_factor, min_neighbors, flags, min_size, max_size);
|
||||||
result = cCvSeq::new_sequence(cCvSeq::rb_class(), seq, cCvAvgComp::rb_class(), storage_val);
|
result = cCvSeq::new_sequence(cCvSeq::rb_class(), seq, cCvAvgComp::rb_class(), storage_val);
|
||||||
if (rb_block_given_p()) {
|
if (rb_block_given_p()) {
|
||||||
|
|
10964
ext/opencv/cvmat.cpp
10964
ext/opencv/cvmat.cpp
File diff suppressed because it is too large
Load diff
|
@ -52,6 +52,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard c headers
|
// standard c headers
|
||||||
|
#define _USE_MATH_DEFINES // for VC++
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
|
@ -290,7 +290,7 @@ rb_show_image(int argc, VALUE *argv, VALUE self)
|
||||||
{
|
{
|
||||||
CvArr* image = NULL;
|
CvArr* image = NULL;
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
image = CVMAT_WITH_CHECK(argv[0]);
|
image = CVARR_WITH_CHECK(argv[0]);
|
||||||
st_table *holder;
|
st_table *holder;
|
||||||
if (st_lookup(windows, (st_data_t)DATA_PTR(self), (st_data_t*)&holder))
|
if (st_lookup(windows, (st_data_t)DATA_PTR(self), (st_data_t*)&holder))
|
||||||
st_insert(holder, cCvMat::rb_class(), argv[0]);
|
st_insert(holder, cCvMat::rb_class(), argv[0]);
|
||||||
|
|
11
extconf.rb
11
extconf.rb
|
@ -8,12 +8,12 @@ usage : ruby extconf.rb
|
||||||
|
|
||||||
VC : ruby extconf.rb
|
VC : ruby extconf.rb
|
||||||
nmake
|
nmake
|
||||||
|
nmake install
|
||||||
=end
|
=end
|
||||||
require "mkmf"
|
require "mkmf"
|
||||||
|
|
||||||
# option "opencv"
|
# option "opencv"
|
||||||
# extconf.rb --with-opencv-lib=/path/to/opencv/lib
|
# extconf.rb --with-opencv-dir=/path/to/opencv
|
||||||
# extconf.rb --with-opencv-include=/path/to/opencv/include
|
|
||||||
|
|
||||||
dir_config("opencv", "/usr/local/include", "/usr/local/lib")
|
dir_config("opencv", "/usr/local/include", "/usr/local/lib")
|
||||||
if CONFIG["arch"].include?("darwin")
|
if CONFIG["arch"].include?("darwin")
|
||||||
|
@ -37,10 +37,13 @@ opencv_libraries = ["opencv_calib3d", "opencv_contrib", "opencv_core", "opencv_f
|
||||||
puts ">> check require libraries..."
|
puts ">> check require libraries..."
|
||||||
case CONFIG["arch"]
|
case CONFIG["arch"]
|
||||||
when /mswin32/
|
when /mswin32/
|
||||||
have_library("msvcrt", nil)
|
OPENCV_VERSION_SUFFIX = '231'
|
||||||
|
opencv_libraries.map! {|lib| lib + OPENCV_VERSION_SUFFIX }
|
||||||
|
have_library("msvcrt")
|
||||||
opencv_libraries.each{|lib|
|
opencv_libraries.each{|lib|
|
||||||
have_library(lib)
|
raise "lib#{lib} not found." unless have_library(lib)
|
||||||
}
|
}
|
||||||
|
$CFLAGS << ' /EHsc'
|
||||||
else
|
else
|
||||||
opencv_libraries.each{|lib|
|
opencv_libraries.each{|lib|
|
||||||
raise "lib#{lib} not found." unless have_library(lib)
|
raise "lib#{lib} not found." unless have_library(lib)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue