Class: OpenCV::GUI::Trackbar

Inherits:
Object
  • Object
show all
Defined in:
ext/opencv/trackbar.cpp,
ext/opencv/trackbar.cpp

Overview

Simple Trackbar wedget. OpenCV::GUI::Window can treat trackbar. Trackbar can treat only positive-integer value.

Instance Method Summary collapse

Constructor Details

#new(name, maxval[,val], &block) ⇒ Object #new(name, maxval[,val]) {|value| ... } ⇒ Object

Create new Trackbar. name should be String. maxval and val should be Fixnum. When Trackbar adjuster changed, block will be called.

Overloads:

  • #new(name, maxval[,val]) {|value| ... } ⇒ Object

    Yields:



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'ext/opencv/trackbar.cpp', line 53

VALUE rb_initialize(int argc, VALUE *argv, VALUE self) {
  VALUE name, maxval, val, block;
  rb_scan_args(argc, argv, "21&", &name, &maxval, &val, &block);
  if (NIL_P(block))
    rb_raise(rb_eArgError, "block not given.");
  Check_Type(name, T_STRING);
  Trackbar *trackbar = TRACKBAR(self);
  trackbar->name = strcpy(ALLOC_N(char, RSTRING_LEN(name) + 1), StringValueCStr(name));
  trackbar->maxval = NUM2INT(maxval);
  trackbar->val = IF_INT(val, 0);
  trackbar->block = block;
  return self;
}

Instance Method Details

#maxObject

Return the maximum value that can be taken this trackbar.



77
78
79
# File 'ext/opencv/trackbar.cpp', line 77

VALUE rb_max(VALUE self) {
  return INT2NUM(TRACKBAR(self)->maxval);
}

#nameObject

Return trackbar name.



70
71
72
# File 'ext/opencv/trackbar.cpp', line 70

VALUE rb_name(VALUE self) {
  return rb_str_new2(TRACKBAR(self)->name);
}

#valueObject

Return the value of this trackbar.



84
85
86
# File 'ext/opencv/trackbar.cpp', line 84

VALUE rb_value(VALUE self) {
  return INT2NUM(TRACKBAR(self)->val);
}

#value=(val) ⇒ Object

Set trackbar value.



94
95
96
97
# File 'ext/opencv/trackbar.cpp', line 94

VALUE rb_set_value(VALUE self, VALUE val) {
  TRACKBAR(self)->val = NUM2INT(val);
  return self;
}