mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
remove dependencies of ffcall
This commit is contained in:
parent
fadad7f893
commit
e752f57d5b
4 changed files with 10 additions and 48 deletions
|
@ -24,13 +24,6 @@ Ruby/OpenCV relies on the OpenCV library.
|
|||
See http://opencv.willowgarage.com/wiki/InstallGuide
|
||||
|
||||
|
||||
* ffcall (optional)
|
||||
ffcall is needed to use GUI trackbar component.
|
||||
Other GUI components work without ffcall.
|
||||
|
||||
See http://www.haible.de/bruno/packages-ffcall.html
|
||||
|
||||
|
||||
== INSTALLATION:
|
||||
=== Install Ruby/OpenCV manually
|
||||
==== Unix/Linux/Mac
|
||||
|
|
|
@ -38,10 +38,6 @@ extern "C" {
|
|||
#include <st.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CALLBACK_H
|
||||
#include <callback.h> // callhack.h is ffcall header
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#define va_init_list(a,b) va_start(a,b)
|
||||
|
|
|
@ -306,6 +306,12 @@ rb_show_image(int argc, VALUE *argv, VALUE self)
|
|||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
trackbar_callback(int value, void* block)
|
||||
{
|
||||
rb_funcall((VALUE)block, rb_intern("call"), 1, INT2NUM(value));
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* set_trackbar(<i>trackbar</i>)
|
||||
|
@ -315,15 +321,6 @@ rb_show_image(int argc, VALUE *argv, VALUE self)
|
|||
* Create Trackbar on this window. Return new Trackbar.
|
||||
* see Trackbar.new
|
||||
*/
|
||||
#ifdef HAVE_CALLBACK_H
|
||||
void
|
||||
trackbar_callback(VALUE block, va_alist ap)
|
||||
{
|
||||
va_start_void(ap);
|
||||
rb_funcall(block, rb_intern("call"), 1, INT2FIX(va_arg_int(ap)));
|
||||
va_return_void(ap);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_set_trackbar(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
|
@ -335,10 +332,9 @@ rb_set_trackbar(int argc, VALUE *argv, VALUE self)
|
|||
instance = cTrackbar::rb_initialize(argc, argv, cTrackbar::rb_allocate(cTrackbar::rb_class()));
|
||||
}
|
||||
Trackbar *trackbar = TRACKBAR(instance);
|
||||
void *callback = (void *)alloc_callback(&trackbar_callback, trackbar->block);
|
||||
try {
|
||||
cvCreateTrackbar(trackbar->name, GET_WINDOW_NAME(self), &(trackbar->val), trackbar->maxval,
|
||||
(CvTrackbarCallback)callback);
|
||||
cv::createTrackbar(trackbar->name, GET_WINDOW_NAME(self), &(trackbar->val), trackbar->maxval,
|
||||
(cv::TrackbarCallback)trackbar_callback, (void*)(trackbar->block));
|
||||
}
|
||||
catch (cv::Exception& e) {
|
||||
raise_cverror(e);
|
||||
|
@ -349,17 +345,10 @@ rb_set_trackbar(int argc, VALUE *argv, VALUE self)
|
|||
}
|
||||
return instance;
|
||||
}
|
||||
#else
|
||||
VALUE
|
||||
rb_set_trackbar(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
rb_raise(rb_eFatal, "ffcall is required to use Window#set_trackbar");
|
||||
return Qnil;
|
||||
}
|
||||
#endif // HAVE_CALLBACK_H
|
||||
|
||||
void
|
||||
on_mouse(int event, int x, int y, int flags, void* param) {
|
||||
on_mouse(int event, int x, int y, int flags, void* param)
|
||||
{
|
||||
VALUE block = (VALUE)param;
|
||||
if (rb_obj_is_kind_of(block, rb_cProc))
|
||||
rb_funcall(block, rb_intern("call"), 1, cMouseEvent::new_object(event, x, y, flags));
|
||||
|
|
16
extconf.rb
16
extconf.rb
|
@ -16,11 +16,6 @@ require "mkmf"
|
|||
# extconf.rb --with-opencv-dir=/path/to/opencv
|
||||
|
||||
dir_config("opencv", "/usr/local/include", "/usr/local/lib")
|
||||
if CONFIG["arch"].include?("darwin")
|
||||
dir_config("ffcall", "/opt/local/include", "/opt/local/lib")
|
||||
else
|
||||
dir_config("ffcall", "/usr/local/include", "/usr/local/lib")
|
||||
end
|
||||
dir_config("libxml2", "/usr/include", "/usr/lib")
|
||||
|
||||
opencv_headers = ["opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/imgproc/imgproc_c.h",
|
||||
|
@ -63,17 +58,6 @@ have_header("stdarg.h")
|
|||
# check require functions.
|
||||
# todo
|
||||
|
||||
# optional libraies check.
|
||||
puts ">> ----- optional -----"
|
||||
puts ">> check ffcall..."
|
||||
# check ffcall
|
||||
if have_library("callback") && have_header("callback.h")
|
||||
puts ">> support OpenCV::GUI::Window#set_trackbar"
|
||||
else
|
||||
puts ">> ! unsupport OpenCV::GUI::Window#set_trackbar (if need it. install ffcall)"
|
||||
puts "http://www.haible.de/bruno/packages-ffcall.html"
|
||||
end
|
||||
|
||||
# Quick fix for 1.8.7
|
||||
$CFLAGS << " -I#{File.dirname(__FILE__)}/ext/opencv"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue