1
0
Fork 0
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:
ser1zw 2011-11-28 08:31:12 +09:00
parent fcc66a0180
commit d37cefb3aa
9 changed files with 5516 additions and 5495 deletions

3
.gitignore vendored
View file

@ -3,6 +3,8 @@
examples/data
*.o
*.so
*.obj
*.pdb
Makefile
mkmf.log
opencv.bundle
@ -14,6 +16,7 @@ OpenCV-*
ruby-*
ext/opencv/test.txt
pkg/
doc/
log.txt
videowriter_result.avi
examples/contours/rotated-boxes-with-detected-bounding-rectangles.jpg

View file

@ -33,6 +33,7 @@ See http://www.haible.de/bruno/packages-ffcall.html
== INSTALLATION:
=== Install Ruby/OpenCV manually
==== Unix/Linux/Mac
$ git clone git://github.com/ser1zw/ruby-opencv.git
$ cd ruby-opencv
@ -41,6 +42,17 @@ See http://www.haible.de/bruno/packages-ffcall.html
$ make
$ 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).
For example, if you install OpenCV library to */opt/local/* like:

View file

@ -120,7 +120,7 @@ cvcapture_free(void *ptr)
VALUE
rb_open(int argc, VALUE *argv, VALUE self)
{
VALUE device, interface;
VALUE device;
rb_scan_args(argc, argv, "01", &device);
CvCapture *capture = 0;
try {
@ -131,12 +131,13 @@ rb_open(int argc, VALUE *argv, VALUE self)
case T_FIXNUM:
capture = cvCaptureFromCAM(FIX2INT(device));
break;
case T_SYMBOL:
interface = rb_hash_aref(rb_const_get(rb_class(), rb_intern("INTERFACE")), device);
if (NIL_P(interface))
rb_raise(rb_eArgError, "undefined interface.");
capture = cvCaptureFromCAM(NUM2INT(interface));
case T_SYMBOL: {
VALUE cap_index = rb_hash_aref(rb_const_get(rb_class(), rb_intern("INTERFACE")), device);
if (NIL_P(cap_index))
rb_raise(rb_eArgError, "undefined interface.");
capture = cvCaptureFromCAM(NUM2INT(cap_index));
break;
}
case T_NIL:
capture = cvCaptureFromCAM(CV_CAP_ANY);
break;

View file

@ -76,6 +76,7 @@ rb_initialize(int argc, VALUE *argv, VALUE self)
CVCONNECTEDCOMP(self)->rect = *CVRECT(rect);
if (!NIL_P(contour))
CVCONNECTEDCOMP(self)->contour = CVSEQ(contour);
return self;
}
/*

View file

@ -51,7 +51,7 @@ rb_allocate(VALUE klass)
return OPENCV_OBJECT(klass, 0);
}
VALUE
void
cvhaarclassifiercascade_free(void* ptr)
{
if (ptr) {
@ -150,7 +150,7 @@ rb_detect_objects(int argc, VALUE *argv, VALUE self)
VALUE result = Qnil;
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);
result = cCvSeq::new_sequence(cCvSeq::rb_class(), seq, cCvAvgComp::rb_class(), storage_val);
if (rb_block_given_p()) {

File diff suppressed because it is too large Load diff

View file

@ -52,6 +52,7 @@ extern "C" {
}
// standard c headers
#define _USE_MATH_DEFINES // for VC++
#include <math.h>
#include <limits.h>
#include <float.h>

View file

@ -290,7 +290,7 @@ rb_show_image(int argc, VALUE *argv, VALUE self)
{
CvArr* image = NULL;
if (argc > 0) {
image = CVMAT_WITH_CHECK(argv[0]);
image = CVARR_WITH_CHECK(argv[0]);
st_table *holder;
if (st_lookup(windows, (st_data_t)DATA_PTR(self), (st_data_t*)&holder))
st_insert(holder, cCvMat::rb_class(), argv[0]);

View file

@ -8,12 +8,12 @@ usage : ruby extconf.rb
VC : ruby extconf.rb
nmake
nmake install
=end
require "mkmf"
# option "opencv"
# extconf.rb --with-opencv-lib=/path/to/opencv/lib
# extconf.rb --with-opencv-include=/path/to/opencv/include
# extconf.rb --with-opencv-dir=/path/to/opencv
dir_config("opencv", "/usr/local/include", "/usr/local/lib")
if CONFIG["arch"].include?("darwin")
@ -37,10 +37,13 @@ opencv_libraries = ["opencv_calib3d", "opencv_contrib", "opencv_core", "opencv_f
puts ">> check require libraries..."
case CONFIG["arch"]
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|
have_library(lib)
raise "lib#{lib} not found." unless have_library(lib)
}
$CFLAGS << ' /EHsc'
else
opencv_libraries.each{|lib|
raise "lib#{lib} not found." unless have_library(lib)