Esempio n. 1
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * cvseq = rb_define_class_under(opencv, "CvSeq");
   * curve = rb_define_module_under(opencv, "Curve");
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  VALUE cvseq = cCvSeq::rb_class();
  VALUE curve = mCurve::rb_module();

  rb_klass = rb_define_class_under(opencv, "CvChain", cvseq);
  rb_include_module(rb_klass, curve);
  VALUE approx_chain_option = rb_hash_new();
  rb_define_const(rb_klass, "APPROX_CHAIN_OPTION", approx_chain_option); 
  rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("method")), ID2SYM(rb_intern("approx_simple")));
  rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("parameter")), rb_float_new(0));
  rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("minimal_perimeter")), INT2FIX(0));
  rb_hash_aset(approx_chain_option, ID2SYM(rb_intern("recursive")), Qfalse);

  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "origin", RUBY_METHOD_FUNC(rb_origin), 0);
  rb_define_method(rb_klass, "origin=", RUBY_METHOD_FUNC(rb_set_origin), 1);
  rb_define_method(rb_klass, "codes", RUBY_METHOD_FUNC(rb_codes), 0);
  rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
  rb_define_method(rb_klass, "approx_chains", RUBY_METHOD_FUNC(rb_approx_chains), -1);
  rb_define_alias(rb_klass, "approx", "approx_chains");
}
Esempio n. 2
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  
  rb_klass = rb_define_class_under(opencv, "CvPoint", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
  rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
  rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
  rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);

  rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
  rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
  rb_define_alias(rb_klass, "to_a", "to_ary");
}
Esempio n. 3
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  
  rb_klass = rb_define_class_under(opencv, "CvHuMoments", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 1);
  rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
  rb_define_alias(rb_klass, "to_a", "to_ary");
  
  DEFINE_CVHUMOMENTS_GETTER(hu1);
  DEFINE_CVHUMOMENTS_GETTER(hu2);
  DEFINE_CVHUMOMENTS_GETTER(hu3);
  DEFINE_CVHUMOMENTS_GETTER(hu4);
  DEFINE_CVHUMOMENTS_GETTER(hu5);
  DEFINE_CVHUMOMENTS_GETTER(hu6);
  DEFINE_CVHUMOMENTS_GETTER(hu7);
}
Esempio n. 4
0
void
define_ruby_class()
{
  if(rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvSURFPoint", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 5);
  rb_define_method(rb_klass, "pt", RUBY_METHOD_FUNC(rb_get_pt), 0);
  rb_define_method(rb_klass, "pt=", RUBY_METHOD_FUNC(rb_set_pt), 1);
  rb_define_method(rb_klass, "laplacian", RUBY_METHOD_FUNC(rb_get_laplacian), 0);
  rb_define_method(rb_klass, "laplacian=", RUBY_METHOD_FUNC(rb_set_laplacian), 1);
  rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
  rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
  rb_define_method(rb_klass, "dir", RUBY_METHOD_FUNC(rb_get_dir), 0);
  rb_define_method(rb_klass, "dir=", RUBY_METHOD_FUNC(rb_set_dir), 1);
  rb_define_method(rb_klass, "hessian", RUBY_METHOD_FUNC(rb_get_hessian), 0);
  rb_define_method(rb_klass, "hessian=", RUBY_METHOD_FUNC(rb_set_hessian), 1);
}
Esempio n. 5
0
void
define_ruby_class()
{
    if (rb_klass)
        return;
    /*
     * opencv = rb_define_module("OpenCV");
     *
     * note: this comment is used by rdoc.
     */
    VALUE opencv = rb_module_opencv();

    rb_klass = rb_define_class_under(opencv, "CvTermCriteria", rb_cObject);
    /* CvTermCriteria: class */
    rb_define_const(opencv, "CvTerm", rb_klass);
    rb_define_alloc_func(rb_klass, rb_allocate);
    rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
    rb_define_method(rb_klass, "max", RUBY_METHOD_FUNC(rb_max), 0);
    rb_define_method(rb_klass, "max=", RUBY_METHOD_FUNC(rb_set_max), 1);
    rb_define_method(rb_klass, "eps", RUBY_METHOD_FUNC(rb_eps), 0);
    rb_define_method(rb_klass, "eps=", RUBY_METHOD_FUNC(rb_set_eps), 1);
    rb_define_alias(rb_klass, "epsilon", "eps");
    rb_define_alias(rb_klass, "epsilon=", "eps=");
    rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
}
Esempio n. 6
0
void
define_ruby_class()
{
  if(rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvRect", rb_cObject);            
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_singleton_method(rb_klass, "compatible?", RUBY_METHOD_FUNC(rb_compatible_q), 1);
  rb_define_singleton_method(rb_klass, "max_rect", RUBY_METHOD_FUNC(rb_max_rect), 2);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);

  rb_define_method(rb_klass, "x", RUBY_METHOD_FUNC(rb_x), 0);
  rb_define_method(rb_klass, "x=", RUBY_METHOD_FUNC(rb_set_x), 1);
  rb_define_method(rb_klass, "y", RUBY_METHOD_FUNC(rb_y), 0);
  rb_define_method(rb_klass, "y=", RUBY_METHOD_FUNC(rb_set_y), 1);
  rb_define_method(rb_klass, "width", RUBY_METHOD_FUNC(rb_width), 0);
  rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
  rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_height), 0);
  rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);      
  rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
  rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
  rb_define_method(rb_klass, "top_left", RUBY_METHOD_FUNC(rb_top_left), 0);
  rb_define_method(rb_klass, "top_right", RUBY_METHOD_FUNC(rb_top_right), 0);
  rb_define_method(rb_klass, "bottom_left", RUBY_METHOD_FUNC(rb_bottom_left), 0);
  rb_define_method(rb_klass, "bottom_right", RUBY_METHOD_FUNC(rb_bottom_right), 0);
  // rb_define_method(rb_klass, "or", RUBY_METHOD_FUNC(rb_or), 1);
  // rb_define_alias(rb_klass, "|", "or");
}
Esempio n. 7
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * cvmat = rb_define_class_under(opencv, "CvMat", rb_cObject);
   *
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  VALUE cvmat = cCvMat::rb_class();
  rb_klass = rb_define_class_under(opencv, "IplImage", cvmat);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_singleton_method(rb_klass, "load", RUBY_METHOD_FUNC(rb_load_image), -1);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1); 
  rb_define_method(rb_klass, "get_roi", RUBY_METHOD_FUNC(rb_get_roi), 0);
  rb_define_alias(rb_klass, "roi", "get_roi");
  rb_define_method(rb_klass, "set_roi", RUBY_METHOD_FUNC(rb_set_roi), 1);
  rb_define_alias(rb_klass, "roi=", "set_roi");
  rb_define_method(rb_klass, "reset_roi", RUBY_METHOD_FUNC(rb_reset_roi), 0);
  rb_define_method(rb_klass, "get_coi", RUBY_METHOD_FUNC(rb_get_coi), 0);
  rb_define_alias(rb_klass, "coi", "get_coi");
  rb_define_method(rb_klass, "set_coi", RUBY_METHOD_FUNC(rb_set_coi), 1);
  rb_define_alias(rb_klass, "coi=", "set_coi");
  rb_define_method(rb_klass, "reset_coi", RUBY_METHOD_FUNC(rb_reset_coi), 0); 

  rb_define_method(rb_klass, "smoothness", RUBY_METHOD_FUNC(rb_smoothness), -1);
}
Esempio n. 8
0
void
init_ruby_class()
{
#if 0
  // For documentation using YARD
  VALUE opencv = rb_define_module("OpenCV");
#endif

  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvSURFPoint", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 5);
  rb_define_method(rb_klass, "pt", RUBY_METHOD_FUNC(rb_get_pt), 0);
  rb_define_method(rb_klass, "pt=", RUBY_METHOD_FUNC(rb_set_pt), 1);
  rb_define_method(rb_klass, "laplacian", RUBY_METHOD_FUNC(rb_get_laplacian), 0);
  rb_define_method(rb_klass, "laplacian=", RUBY_METHOD_FUNC(rb_set_laplacian), 1);
  rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_get_size), 0);
  rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
  rb_define_method(rb_klass, "dir", RUBY_METHOD_FUNC(rb_get_dir), 0);
  rb_define_method(rb_klass, "dir=", RUBY_METHOD_FUNC(rb_set_dir), 1);
  rb_define_method(rb_klass, "hessian", RUBY_METHOD_FUNC(rb_get_hessian), 0);
  rb_define_method(rb_klass, "hessian=", RUBY_METHOD_FUNC(rb_set_hessian), 1);
  rb_define_singleton_method(rb_klass, "flann", RUBY_METHOD_FUNC(rb_flann), 2);
}
Esempio n. 9
0
void
init_ruby_class()
{
#if 0
  // For documentation using YARD
  VALUE opencv = rb_define_module("OpenCV");
#endif

  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();  
  rb_klass = rb_define_class_under(opencv, "IplConvKernel", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);

  rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_size), 0);
  rb_define_method(rb_klass, "cols", RUBY_METHOD_FUNC(rb_cols), 0);
  rb_define_alias(rb_klass, "columns", "cols");
  rb_define_method(rb_klass, "rows", RUBY_METHOD_FUNC(rb_rows), 0);
  rb_define_method(rb_klass, "anchor", RUBY_METHOD_FUNC(rb_anchor), 0);
  rb_define_method(rb_klass, "anchor_x", RUBY_METHOD_FUNC(rb_anchor_x), 0);
  rb_define_method(rb_klass, "anchor_y", RUBY_METHOD_FUNC(rb_anchor_y), 0);
}
Esempio n. 10
0
void
define_ruby_class()
{
  if(rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvMemStorage", rb_cObject);
  //rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);     
}
Esempio n. 11
0
void
define_ruby_module()
{
  if(rb_module)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");      
   *
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_module = rb_define_module_under(opencv, "GUI");
  rb_define_singleton_method(rb_module, "wait_key", RUBY_METHOD_FUNC(rb_wait_key), -1);
}
Esempio n. 12
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "FisherFaces", cFaceRecognizer::rb_class());
  rb_define_alloc_func(rb_klass, cFaceRecognizer::allocate_facerecognizer);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
}
Esempio n. 13
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * cvmat = rb_define_class_under(opencv, "CvMat", rb_cObject);
   *
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv(), cvmat = cCvMat::rb_class();
  
  rb_klass = rb_define_class_under(opencv, "CvSparseMat", cvmat);
}
void define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  
  rb_klass = rb_define_class_under(opencv, "CvHaarClassifierCascade", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_singleton_method(rb_klass, "load", RUBY_METHOD_FUNC(rb_load), 1);
  rb_define_method(rb_klass, "detect_objects", RUBY_METHOD_FUNC(rb_detect_objects), -1);
}
Esempio n. 15
0
void
init_ruby_class()
{
#if 0
  // For documentation using YARD
  VALUE opencv = rb_define_module("OpenCV");
  VALUE cvseq = rb_define_class_under(opencv, "CvSeq");
  VALUE curve = rb_define_module_under(opencv, "Curve");
  VALUE pointset = rb_define_module_under(opencv, "PointSet");
#endif

  if (rb_klass)
    return;

  VALUE opencv = rb_module_opencv();
  VALUE cvseq = cCvSeq::rb_class();
  VALUE curve = mCurve::rb_module();
  VALUE pointset = mPointSet::rb_module();

  rb_klass = rb_define_class_under(opencv, "CvContour", cvseq);
  rb_include_module(rb_klass, curve);
  rb_include_module(rb_klass, pointset);

  rb_define_alloc_func(rb_klass, rb_allocate);

  VALUE approx_option = rb_hash_new();
  rb_define_const(rb_klass, "APPROX_OPTION", approx_option);
  rb_hash_aset(approx_option, ID2SYM(rb_intern("method")), INT2FIX(CV_POLY_APPROX_DP));
  rb_hash_aset(approx_option, ID2SYM(rb_intern("accuracy")), rb_float_new(1.0));
  rb_hash_aset(approx_option, ID2SYM(rb_intern("recursive")), Qfalse);
  
  rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "rect", RUBY_METHOD_FUNC(rb_rect), 0);
  rb_define_method(rb_klass, "color", RUBY_METHOD_FUNC(rb_color), 0);
  rb_define_method(rb_klass, "color=", RUBY_METHOD_FUNC(rb_set_color), 1);
  rb_define_method(rb_klass, "reserved", RUBY_METHOD_FUNC(rb_reserved), 0);
  rb_define_method(rb_klass, "approx_poly", RUBY_METHOD_FUNC(rb_approx_poly), -1);
  rb_define_alias(rb_klass, "approx", "approx_poly");
  rb_define_method(rb_klass, "bounding_rect", RUBY_METHOD_FUNC(rb_bounding_rect), 0);
  rb_define_method(rb_klass, "create_tree", RUBY_METHOD_FUNC(rb_create_tree), -1);
  rb_define_method(rb_klass, "in?", RUBY_METHOD_FUNC(rb_in_q), 1);
  rb_define_method(rb_klass, "measure_distance", RUBY_METHOD_FUNC(rb_measure_distance), 1);
  rb_define_method(rb_klass, "point_polygon_test", RUBY_METHOD_FUNC(rb_point_polygon_test), 2);
  rb_define_method(rb_klass, "match_shapes", RUBY_METHOD_FUNC(rb_match_shapes), -1);
}
Esempio n. 16
0
void
define_ruby_module()
{
  if(module)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   *
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  module = rb_define_module_under(opencv, "Curve");
  rb_define_method(module, "closed?", RUBY_METHOD_FUNC(rb_closed_q), 0);
  rb_define_method(module, "convex?", RUBY_METHOD_FUNC(rb_convex_q), 0);
  rb_define_method(module, "hole?", RUBY_METHOD_FUNC(rb_hole_q), 0);
  rb_define_method(module, "simple?", RUBY_METHOD_FUNC(rb_simple_q), 0);
  rb_define_method(module, "arc_length", RUBY_METHOD_FUNC(rb_arc_length), -1);
}
Esempio n. 17
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  
  rb_klass = rb_define_class_under(opencv, "CvScalar", rb_cObject);
  /* CvScalar: class */
  rb_define_const(opencv, "CvColor", rb_klass);
  rb_define_alloc_func(rb_klass, rb_allocate);      
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
  rb_define_method(rb_klass, "[]=", RUBY_METHOD_FUNC(rb_aset), 2);
  rb_define_method(rb_klass, "sub", RUBY_METHOD_FUNC(rb_sub), -1);
  rb_define_alias(rb_klass, "-", "sub");
  
  rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
  rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
  rb_define_alias(rb_klass, "to_a", "to_ary");

  rb_define_const(rb_klass, "Black", cCvScalar::new_object(cvScalar(0x0,0x0,0x0)));
  rb_define_const(rb_klass, "Silver", cCvScalar::new_object(cvScalar(0x0c,0x0c,0x0c)));
  rb_define_const(rb_klass, "Gray", cCvScalar::new_object(cvScalar(0x80,0x80,0x80)));
  rb_define_const(rb_klass, "White", cCvScalar::new_object(cvScalar(0xff,0xff,0xff)));
  rb_define_const(rb_klass, "Maroon", cCvScalar::new_object(cvScalar(0x0,0x0,0x80)));
  rb_define_const(rb_klass, "Red", cCvScalar::new_object(cvScalar(0x0,0x0,0xff)));
  rb_define_const(rb_klass, "Purple", cCvScalar::new_object(cvScalar(0x80,0x0,0x80)));
  rb_define_const(rb_klass, "Fuchsia", cCvScalar::new_object(cvScalar(0xff,0x0,0xff)));
  rb_define_const(rb_klass, "Green", cCvScalar::new_object(cvScalar(0x0,0x80,0x0)));
  rb_define_const(rb_klass, "Lime", cCvScalar::new_object(cvScalar(0x0,0xff,0x0)));
  rb_define_const(rb_klass, "Olive", cCvScalar::new_object(cvScalar(0x0,0x80,0x80)));
  rb_define_const(rb_klass, "Yellow", cCvScalar::new_object(cvScalar(0x0,0xff,0xff)));
  rb_define_const(rb_klass, "Navy", cCvScalar::new_object(cvScalar(0x80,0x0,0x0)));
  rb_define_const(rb_klass, "Blue", cCvScalar::new_object(cvScalar(0xff,0x0,0x0)));
  rb_define_const(rb_klass, "Teal", cCvScalar::new_object(cvScalar(0x80,0x80,0x0)));
  rb_define_const(rb_klass, "Aqua", cCvScalar::new_object(cvScalar(0xff,0xff,0x0)));
}
Esempio n. 18
0
void
init_ruby_class()
{
#if 0
  // For documentation using YARD
  VALUE opencv = rb_define_module("OpenCV");
#endif

  if (rb_klass)
    return;

  VALUE opencv = rb_module_opencv();

  rb_klass = rb_define_class_under(opencv, "CvConvexityDefect", rb_cObject);
  rb_define_method(rb_klass, "start", RUBY_METHOD_FUNC(rb_start), 0);
  rb_define_method(rb_klass, "end", RUBY_METHOD_FUNC(rb_end), 0);
  rb_define_method(rb_klass, "depth_point", RUBY_METHOD_FUNC(rb_depth_point), 0);
  rb_define_method(rb_klass, "depth", RUBY_METHOD_FUNC(rb_depth), 0);
}
Esempio n. 19
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  
  rb_klass = rb_define_class_under(opencv, "CvMoments", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "spatial", RUBY_METHOD_FUNC(rb_spatial), 2);
  rb_define_method(rb_klass, "central", RUBY_METHOD_FUNC(rb_central), 2);
  rb_define_method(rb_klass, "normalized_central", RUBY_METHOD_FUNC(rb_normalized_central), 2);
  rb_define_method(rb_klass, "hu", RUBY_METHOD_FUNC(rb_hu), 0);     
  rb_define_method(rb_klass, "gravity_center", RUBY_METHOD_FUNC(rb_gravity_center), 0);
  rb_define_method(rb_klass, "angle", RUBY_METHOD_FUNC(rb_angle), 0);

  DEFINE_CVMOMENTS_ACCESSOR(m00);
  DEFINE_CVMOMENTS_ACCESSOR(m10);
  DEFINE_CVMOMENTS_ACCESSOR(m01);
  DEFINE_CVMOMENTS_ACCESSOR(m20);
  DEFINE_CVMOMENTS_ACCESSOR(m11);
  DEFINE_CVMOMENTS_ACCESSOR(m02);
  DEFINE_CVMOMENTS_ACCESSOR(m30);
  DEFINE_CVMOMENTS_ACCESSOR(m21);
  DEFINE_CVMOMENTS_ACCESSOR(m12);
  DEFINE_CVMOMENTS_ACCESSOR(m03);

  DEFINE_CVMOMENTS_ACCESSOR(mu20);
  DEFINE_CVMOMENTS_ACCESSOR(mu11);
  DEFINE_CVMOMENTS_ACCESSOR(mu02);
  DEFINE_CVMOMENTS_ACCESSOR(mu30);
  DEFINE_CVMOMENTS_ACCESSOR(mu21);
  DEFINE_CVMOMENTS_ACCESSOR(mu12);
  DEFINE_CVMOMENTS_ACCESSOR(mu03);

  DEFINE_CVMOMENTS_ACCESSOR(inv_sqrt_m00);
}
Esempio n. 20
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvSeq", rb_cObject);
  rb_include_module(rb_klass, rb_mEnumerable);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "total", RUBY_METHOD_FUNC(rb_total), 0);
  rb_define_alias(rb_klass, "length", "total");
  rb_define_alias(rb_klass, "size", "total");
  rb_define_method(rb_klass, "empty?", RUBY_METHOD_FUNC(rb_empty_q), 0);
  rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
  rb_define_method(rb_klass, "first", RUBY_METHOD_FUNC(rb_first), 0);
  rb_define_method(rb_klass, "last", RUBY_METHOD_FUNC(rb_last), 0);
  
  rb_define_method(rb_klass, "h_prev", RUBY_METHOD_FUNC(rb_h_prev), 0);
  rb_define_method(rb_klass, "h_next", RUBY_METHOD_FUNC(rb_h_next), 0);
  rb_define_method(rb_klass, "v_prev", RUBY_METHOD_FUNC(rb_v_prev), 0);
  rb_define_method(rb_klass, "v_next", RUBY_METHOD_FUNC(rb_v_next), 0);

  rb_define_method(rb_klass, "push", RUBY_METHOD_FUNC(rb_push), -2);
  rb_define_alias(rb_klass, "<<", "push");
  rb_define_method(rb_klass, "pop", RUBY_METHOD_FUNC(rb_pop), 0);
  rb_define_method(rb_klass, "unshift", RUBY_METHOD_FUNC(rb_unshift), -2);
  rb_define_alias(rb_klass, "push_front", "unshift");
  rb_define_method(rb_klass, "shift", RUBY_METHOD_FUNC(rb_shift), 0);
  rb_define_alias(rb_klass, "pop_front", "shift");
  rb_define_method(rb_klass, "each", RUBY_METHOD_FUNC(rb_each), 0);
  rb_define_method(rb_klass, "each_index", RUBY_METHOD_FUNC(rb_each_index), 0);
  rb_define_method(rb_klass, "insert", RUBY_METHOD_FUNC(rb_insert), 2);
  rb_define_method(rb_klass, "remove", RUBY_METHOD_FUNC(rb_remove), 1);
  rb_define_alias(rb_klass, "delete_at", "remove");
  rb_define_method(rb_klass, "clear", RUBY_METHOD_FUNC(rb_clear), 0);
}
Esempio n. 21
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * cvseq = rb_define_class_under(opencv, "CvSeq");
   *
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  VALUE cvseq = cCvSeq::rb_class();
  
  rb_klass = rb_define_class_under(opencv, "CvContourTree", cvseq);
  rb_define_method(rb_klass, "p1", RUBY_METHOD_FUNC(rb_p1), 0);
  rb_define_method(rb_klass, "p2", RUBY_METHOD_FUNC(rb_p2), 0);
  rb_define_method(rb_klass, "contour", RUBY_METHOD_FUNC(rb_contour), 0);

}
Esempio n. 22
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  
  rb_klass = rb_define_class_under(opencv, "CvTwoPoints", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_method(rb_klass, "point1", RUBY_METHOD_FUNC(rb_point1), 0);
  rb_define_method(rb_klass, "point2", RUBY_METHOD_FUNC(rb_point2), 0);
  rb_define_method(rb_klass, "[]", RUBY_METHOD_FUNC(rb_aref), 1);
  rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
  rb_define_alias(rb_klass, "to_a", "to_ary");
}
Esempio n. 23
0
void
init_ruby_class()
{
#if 0
  // For documentation using YARD
  VALUE opencv = rb_define_module("OpenCV");
#endif

  if (rb_klass)
    return;

  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvFont", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  VALUE face = rb_hash_new();
  rb_define_const(rb_klass, "FACE", face);
  rb_hash_aset(face, ID2SYM(rb_intern("simplex")), INT2FIX(CV_FONT_HERSHEY_SIMPLEX));
  rb_hash_aset(face, ID2SYM(rb_intern("plain")), INT2FIX(CV_FONT_HERSHEY_PLAIN));
  rb_hash_aset(face, ID2SYM(rb_intern("duplex")), INT2FIX(CV_FONT_HERSHEY_DUPLEX));
  rb_hash_aset(face, ID2SYM(rb_intern("triplex")), INT2FIX(CV_FONT_HERSHEY_TRIPLEX));
  rb_hash_aset(face, ID2SYM(rb_intern("complex_small")), INT2FIX(CV_FONT_HERSHEY_COMPLEX_SMALL));
  rb_hash_aset(face, ID2SYM(rb_intern("script_simplex")), INT2FIX(CV_FONT_HERSHEY_SCRIPT_SIMPLEX));
  rb_hash_aset(face, ID2SYM(rb_intern("script_complex")), INT2FIX(CV_FONT_HERSHEY_SCRIPT_COMPLEX));

  VALUE default_option = rb_hash_new();
  rb_define_const(rb_klass, "FONT_OPTION", default_option);
  rb_hash_aset(default_option, ID2SYM(rb_intern("hscale")), rb_float_new(1.0));
  rb_hash_aset(default_option, ID2SYM(rb_intern("vscale")), rb_float_new(1.0));
  rb_hash_aset(default_option, ID2SYM(rb_intern("shear")), INT2FIX(0));
  rb_hash_aset(default_option, ID2SYM(rb_intern("thickness")), INT2FIX(1));
  rb_hash_aset(default_option, ID2SYM(rb_intern("line_type")), INT2FIX(8));
  
  rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "face", RUBY_METHOD_FUNC(rb_face), 0);
  rb_define_method(rb_klass, "hscale", RUBY_METHOD_FUNC(rb_hscale), 0);
  rb_define_method(rb_klass, "vscale", RUBY_METHOD_FUNC(rb_vscale), 0);
  rb_define_method(rb_klass, "shear", RUBY_METHOD_FUNC(rb_shear), 0);
  rb_define_method(rb_klass, "thickness", RUBY_METHOD_FUNC(rb_thickness), 0);
  rb_define_method(rb_klass, "line_type", RUBY_METHOD_FUNC(rb_line_type), 0);
  rb_define_method(rb_klass, "italic", RUBY_METHOD_FUNC(rb_italic), 0);
}
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  
  rb_klass = rb_define_class_under(opencv, "CvConnectedComp", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "area", RUBY_METHOD_FUNC(rb_area), 0);
  rb_define_method(rb_klass, "value", RUBY_METHOD_FUNC(rb_value), 0);
  rb_define_method(rb_klass, "rect", RUBY_METHOD_FUNC(rb_rect), 0);
  rb_define_method(rb_klass, "rect=", RUBY_METHOD_FUNC(rb_set_rect), 1);
  rb_define_method(rb_klass, "contour", RUBY_METHOD_FUNC(rb_contour), 0);
}
Esempio n. 25
0
void
define_ruby_class()
{
  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvBox2D", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "center", RUBY_METHOD_FUNC(rb_center), 0);
  rb_define_method(rb_klass, "center=", RUBY_METHOD_FUNC(rb_set_center), 1);
  rb_define_method(rb_klass, "size", RUBY_METHOD_FUNC(rb_size), 0);
  rb_define_method(rb_klass, "size=", RUBY_METHOD_FUNC(rb_set_size), 1);
  rb_define_method(rb_klass, "angle", RUBY_METHOD_FUNC(rb_angle), 0);
  rb_define_method(rb_klass, "angle=", RUBY_METHOD_FUNC(rb_set_angle), 1);
  rb_define_method(rb_klass, "points", RUBY_METHOD_FUNC(rb_points), 0);
}
Esempio n. 26
0
void
init_ruby_class()
{
#if 0
  // For documentation using YARD
  VALUE opencv = rb_define_module("OpenCV");
  VALUE alghorithm = rb_define_class_under(opencv, "Algorithm", rb_cObject);
  VALUE face_recognizer = rb_define_class_under(opencv, "FaceRecognizer", alghorithm);
#endif

  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  VALUE face_recognizer = cFaceRecognizer::rb_class();
  rb_klass = rb_define_class_under(opencv, "EigenFaces", face_recognizer);
  rb_define_alloc_func(rb_klass, cFaceRecognizer::allocate_facerecognizer);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
}
Esempio n. 27
0
void
define_ruby_class()
{
  if(rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvSURFParams", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_private_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
  rb_define_method(rb_klass, "hessian_threshold", RUBY_METHOD_FUNC(rb_get_hessian_threshold), 0);
  rb_define_method(rb_klass, "hessian_threshold=", RUBY_METHOD_FUNC(rb_set_hessian_threshold), 1);
  rb_define_method(rb_klass, "extended", RUBY_METHOD_FUNC(rb_get_extended), 0);
  rb_define_method(rb_klass, "extended=", RUBY_METHOD_FUNC(rb_set_extended), 1);
  rb_define_method(rb_klass, "n_octaves", RUBY_METHOD_FUNC(rb_get_n_octaves), 0);
  rb_define_method(rb_klass, "n_octaves=", RUBY_METHOD_FUNC(rb_set_n_octaves), 1);
  rb_define_method(rb_klass, "n_octave_layers", RUBY_METHOD_FUNC(rb_get_n_octave_layers), 0);
  rb_define_method(rb_klass, "n_octave_layers=", RUBY_METHOD_FUNC(rb_set_n_octave_layers), 1);
}
Esempio n. 28
0
void
init_ruby_class()
{
#if 0
  // For documentation using YARD
  VALUE opencv = rb_define_module("OpenCV");
#endif

  if (rb_klass)
    return;
  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();
  rb_klass = rb_define_class_under(opencv, "CvSlice", rb_cObject);
  rb_define_alloc_func(rb_klass, rb_allocate);
  rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), 2);
  rb_define_method(rb_klass, "start_index", RUBY_METHOD_FUNC(rb_start_index_aref), 0);
  rb_define_method(rb_klass, "end_index", RUBY_METHOD_FUNC(rb_end_index_aref), 0);
  rb_define_method(rb_klass, "start_index=", RUBY_METHOD_FUNC(rb_start_index_aset), 1);
  rb_define_method(rb_klass, "end_index=", RUBY_METHOD_FUNC(rb_end_index_aset), 1);
}
Esempio n. 29
0
void define_ruby_class()
{
  if (rb_klass)
    return;

  /* 
   * opencv = rb_define_module("OpenCV");
   * 
   * note: this comment is used by rdoc.
   */
  VALUE opencv = rb_module_opencv();

  rb_klass = rb_define_class_under(opencv, "CvError", rb_eStandardError);
  REGISTER_CVERROR("CvStsBackTrace", CV_StsBackTrace);
  REGISTER_CVERROR("CvStsError", CV_StsError);
  REGISTER_CVERROR("CvStsInternal", CV_StsInternal);
  REGISTER_CVERROR("CvStsNoMem", CV_StsNoMem);
  REGISTER_CVERROR("CvStsBadArg", CV_StsBadArg);
  REGISTER_CVERROR("CvStsBadFunc", CV_StsBadFunc);
  REGISTER_CVERROR("CvStsNoConv", CV_StsNoConv);
  REGISTER_CVERROR("CvStsAutoTrace", CV_StsAutoTrace);
  REGISTER_CVERROR("CvHeaderIsNull", CV_HeaderIsNull);
  REGISTER_CVERROR("CvBadImageSize", CV_BadImageSize);
  REGISTER_CVERROR("CvBadOffset", CV_BadOffset);
  REGISTER_CVERROR("CvBadDataPtr", CV_BadDataPtr);
  REGISTER_CVERROR("CvBadStep", CV_BadStep);
  REGISTER_CVERROR("CvBadModelOrChSeq", CV_BadModelOrChSeq);
  REGISTER_CVERROR("CvBadNumChannels", CV_BadNumChannels);
  REGISTER_CVERROR("CvBadNumChannel1U", CV_BadNumChannel1U);
  REGISTER_CVERROR("CvBadDepth", CV_BadDepth);
  REGISTER_CVERROR("CvBadAlphaChannel", CV_BadAlphaChannel);
  REGISTER_CVERROR("CvBadOrder", CV_BadOrder);
  REGISTER_CVERROR("CvBadOrigin", CV_BadOrigin);
  REGISTER_CVERROR("CvBadAlign", CV_BadAlign);
  REGISTER_CVERROR("CvBadCallBack", CV_BadCallBack);
  REGISTER_CVERROR("CvBadTileSize", CV_BadTileSize);
  REGISTER_CVERROR("CvBadCOI", CV_BadCOI);
  REGISTER_CVERROR("CvBadROISize", CV_BadROISize);
  REGISTER_CVERROR("CvMaskIsTiled", CV_MaskIsTiled);
  REGISTER_CVERROR("CvStsNullPtr", CV_StsNullPtr);
  REGISTER_CVERROR("CvStsVecLengthErr", CV_StsVecLengthErr);
  REGISTER_CVERROR("CvStsFilterStructContentErr", CV_StsFilterStructContentErr);
  REGISTER_CVERROR("CvStsKernelStructContentErr", CV_StsKernelStructContentErr);
  REGISTER_CVERROR("CvStsFilterOffsetErr", CV_StsFilterOffsetErr);
  REGISTER_CVERROR("CvStsBadSize", CV_StsBadSize);
  REGISTER_CVERROR("CvStsDivByZero", CV_StsDivByZero);
  REGISTER_CVERROR("CvStsInplaceNotSupported", CV_StsInplaceNotSupported);
  REGISTER_CVERROR("CvStsObjectNotFound", CV_StsObjectNotFound);
  REGISTER_CVERROR("CvStsUnmatchedFormats", CV_StsUnmatchedFormats);
  REGISTER_CVERROR("CvStsBadFlag", CV_StsBadFlag);
  REGISTER_CVERROR("CvStsBadPoint", CV_StsBadPoint);
  REGISTER_CVERROR("CvStsBadMask", CV_StsBadMask);
  REGISTER_CVERROR("CvStsUnmatchedSizes", CV_StsUnmatchedSizes);
  REGISTER_CVERROR("CvStsUnsupportedFormat", CV_StsUnsupportedFormat);
  REGISTER_CVERROR("CvStsOutOfRange", CV_StsOutOfRange);
  REGISTER_CVERROR("CvStsParseError", CV_StsParseError);
  REGISTER_CVERROR("CvStsNotImplemented", CV_StsNotImplemented);
  REGISTER_CVERROR("CvStsBadMemBlock", CV_StsBadMemBlock);
  REGISTER_CVERROR("CvStsAssert", CV_StsAssert);
  REGISTER_CVERROR("CvGpuNotSupported", CV_GpuNotSupported);
  REGISTER_CVERROR("CvGpuApiCallError", CV_GpuApiCallError);
}
Esempio n. 30
0
void
REGISTER_CVERROR(const char* object_name, int error_code)
{
  st_insert(cv_error, (st_data_t)error_code,
	    (st_data_t)rb_define_class_under(rb_module_opencv(), object_name, rb_klass));
}