From d72fbd7c2c862f69f302bdec13a7d55fc98a1ab7 Mon Sep 17 00:00:00 2001 From: ser1zw Date: Fri, 12 Aug 2011 00:53:48 +0900 Subject: [PATCH] changed some functions' name --- ext/opencv/cvcontour.cpp | 4 +- ext/opencv/cvseq.cpp | 6 +- ext/opencv/opencv.cpp | 154 +++++++++++++++++++-------------------- ext/opencv/opencv.h | 16 ++-- 4 files changed, 90 insertions(+), 90 deletions(-) diff --git a/ext/opencv/cvcontour.cpp b/ext/opencv/cvcontour.cpp index b607188..48c0c86 100644 --- a/ext/opencv/cvcontour.cpp +++ b/ext/opencv/cvcontour.cpp @@ -81,7 +81,7 @@ VALUE rb_allocate(VALUE klass) { CvContour *ptr; - return Data_Make_Struct(klass, CvContour, mark_root_object, unresist_object, ptr); + return Data_Make_Struct(klass, CvContour, mark_root_object, unregister_object, ptr); } VALUE @@ -103,7 +103,7 @@ rb_initialize(int argc, VALUE *argv, VALUE self) catch (cv::Exception& e) { raise_cverror(e); } - resist_root_object((CvSeq*)contour, storage); + register_root_object((CvSeq*)contour, storage); return self; } diff --git a/ext/opencv/cvseq.cpp b/ext/opencv/cvseq.cpp index d982a7b..914bbc8 100644 --- a/ext/opencv/cvseq.cpp +++ b/ext/opencv/cvseq.cpp @@ -69,7 +69,7 @@ unregister_elem_class(void *ptr) { if (ptr) { st_delete(seqblock_klass_table, (st_data_t*)&ptr, NULL); - unresist_object(ptr); + unregister_object(ptr); } } @@ -177,7 +177,7 @@ rb_initialize(int argc, VALUE *argv, VALUE self) } DATA_PTR(self) = seq; register_elem_class(seq, klass); - resist_root_object(seq, storage_value); + register_root_object(seq, storage_value); return self; } @@ -589,7 +589,7 @@ rb_remove(VALUE self, VALUE index) VALUE new_sequence(VALUE klass, CvSeq *seq, VALUE element_klass, VALUE storage) { - resist_root_object(seq, storage); + register_root_object(seq, storage); if (!NIL_P(element_klass)) register_elem_class(seq, element_klass); return Data_Wrap_Struct(klass, mark_root_object, unregister_elem_class, seq); diff --git a/ext/opencv/opencv.cpp b/ext/opencv/opencv.cpp index 173a406..bf04d38 100644 --- a/ext/opencv/opencv.cpp +++ b/ext/opencv/opencv.cpp @@ -76,10 +76,10 @@ lookup_root_object(void *ptr) } /* - * Resist root object. + * Register root object. */ void -resist_root_object(void *ptr, VALUE root) +register_root_object(void *ptr, VALUE root) { st_insert(root_table, (st_data_t)ptr, (st_data_t)root); } @@ -88,7 +88,7 @@ resist_root_object(void *ptr, VALUE root) * Delete mark symbol from hashtable only, not free memory. */ void -unresist_object(void *ptr) +unregister_object(void *ptr) { st_delete(root_table, (st_data_t*)&ptr, 0); } @@ -100,7 +100,7 @@ void free_object(void *ptr) { if (ptr) { - unresist_object(ptr); + unregister_object(ptr); cvFree(&ptr); } } @@ -112,7 +112,7 @@ void release_object(void *ptr) { if (ptr) { - unresist_object(ptr); + unregister_object(ptr); cvRelease(&ptr); } } @@ -124,7 +124,7 @@ void release_iplconvkernel_object(void *ptr) { if (ptr) { - unresist_object(ptr); + unregister_object(ptr); cvReleaseStructuringElement((IplConvKernel**)(&ptr)); } } @@ -256,145 +256,145 @@ define_ruby_module() VALUE inversion_method = rb_hash_new(); /* {:lu, :svd, :svd_sym(:svd_symmetric)}: Inversion method */ rb_define_const(rb_module, "INVERSION_METHOD", inversion_method); - RESIST_CVMETHOD(inversion_method, "lu", CV_LU); - RESIST_CVMETHOD(inversion_method, "svd", CV_SVD); - RESIST_CVMETHOD(inversion_method, "svd_sym", CV_SVD_SYM); - RESIST_CVMETHOD(inversion_method, "svd_symmetric", CV_SVD_SYM); + REGISTER_CVMETHOD(inversion_method, "lu", CV_LU); + REGISTER_CVMETHOD(inversion_method, "svd", CV_SVD); + REGISTER_CVMETHOD(inversion_method, "svd_sym", CV_SVD_SYM); + REGISTER_CVMETHOD(inversion_method, "svd_symmetric", CV_SVD_SYM); VALUE dxt_flag = rb_hash_new(); /* {:forward, :inverse, :scale, :rows}: DFT and DCT flags */ rb_define_const(rb_module, "DXT_FLAG", dxt_flag); - RESIST_CVMETHOD(dxt_flag, "forward", CV_DXT_FORWARD); - RESIST_CVMETHOD(dxt_flag, "inverse", CV_DXT_INVERSE); - RESIST_CVMETHOD(dxt_flag, "scale", CV_DXT_SCALE); - RESIST_CVMETHOD(dxt_flag, "rows", CV_DXT_ROWS); + REGISTER_CVMETHOD(dxt_flag, "forward", CV_DXT_FORWARD); + REGISTER_CVMETHOD(dxt_flag, "inverse", CV_DXT_INVERSE); + REGISTER_CVMETHOD(dxt_flag, "scale", CV_DXT_SCALE); + REGISTER_CVMETHOD(dxt_flag, "rows", CV_DXT_ROWS); VALUE interpolation_method = rb_hash_new(); /* {:nn, :linear, :area, :cubic}: Interpolation method */ rb_define_const(rb_module, "INTERPOLATION_METHOD", interpolation_method); - RESIST_CVMETHOD(interpolation_method, "nn", CV_INTER_NN); - RESIST_CVMETHOD(interpolation_method, "linear", CV_INTER_LINEAR); - RESIST_CVMETHOD(interpolation_method, "area", CV_INTER_AREA); - RESIST_CVMETHOD(interpolation_method, "cubic", CV_INTER_CUBIC); + REGISTER_CVMETHOD(interpolation_method, "nn", CV_INTER_NN); + REGISTER_CVMETHOD(interpolation_method, "linear", CV_INTER_LINEAR); + REGISTER_CVMETHOD(interpolation_method, "area", CV_INTER_AREA); + REGISTER_CVMETHOD(interpolation_method, "cubic", CV_INTER_CUBIC); VALUE warp_flag = rb_hash_new(); /* {:fill_outliers, :inverse_map}: Warp affine optional flags */ rb_define_const(rb_module, "WARP_FLAG", warp_flag); - RESIST_CVMETHOD(warp_flag, "fill_outliers", CV_WARP_FILL_OUTLIERS); - RESIST_CVMETHOD(warp_flag, "inverse_map", CV_WARP_INVERSE_MAP); + REGISTER_CVMETHOD(warp_flag, "fill_outliers", CV_WARP_FILL_OUTLIERS); + REGISTER_CVMETHOD(warp_flag, "inverse_map", CV_WARP_INVERSE_MAP); VALUE homography_calc_method = rb_hash_new(); /* {:all, :ransac, :lmeds}: Methods used to computed homography matrix */ rb_define_const(rb_module, "HOMOGRAPHY_CALC_METHOD", homography_calc_method); - RESIST_CVMETHOD(homography_calc_method, "all", 0); - RESIST_CVMETHOD(homography_calc_method, "ransac", CV_RANSAC); - RESIST_CVMETHOD(homography_calc_method, "lmeds", CV_LMEDS); + REGISTER_CVMETHOD(homography_calc_method, "all", 0); + REGISTER_CVMETHOD(homography_calc_method, "ransac", CV_RANSAC); + REGISTER_CVMETHOD(homography_calc_method, "lmeds", CV_LMEDS); VALUE depth = rb_hash_new(); /* {:cv8u, :cv8s, :cv16u, :cv16s, :cv32s, :cv32f, :cv64f}: Depth of each pixel. */ rb_define_const(rb_module, "DEPTH", depth); - RESIST_CVMETHOD(depth, "cv8u", CV_8U); - RESIST_CVMETHOD(depth, "cv8s", CV_8S); - RESIST_CVMETHOD(depth, "cv16u", CV_16U); - RESIST_CVMETHOD(depth, "cv16s", CV_16S); - RESIST_CVMETHOD(depth, "cv32s", CV_32S); - RESIST_CVMETHOD(depth, "cv32f", CV_32F); - RESIST_CVMETHOD(depth, "cv64f", CV_64F); + REGISTER_CVMETHOD(depth, "cv8u", CV_8U); + REGISTER_CVMETHOD(depth, "cv8s", CV_8S); + REGISTER_CVMETHOD(depth, "cv16u", CV_16U); + REGISTER_CVMETHOD(depth, "cv16s", CV_16S); + REGISTER_CVMETHOD(depth, "cv32s", CV_32S); + REGISTER_CVMETHOD(depth, "cv32f", CV_32F); + REGISTER_CVMETHOD(depth, "cv64f", CV_64F); VALUE connectivity = rb_hash_new(); /* {:aa(:anti_alias)}: Determined by the closeness of pixel values */ rb_define_const(rb_module, "CONNECTIVITY", connectivity); - RESIST_CVMETHOD(connectivity, "aa", CV_AA); - RESIST_CVMETHOD(connectivity, "anti_alias", CV_AA); + REGISTER_CVMETHOD(connectivity, "aa", CV_AA); + REGISTER_CVMETHOD(connectivity, "anti_alias", CV_AA); VALUE structuring_element_shape = rb_hash_new(); /* {:rect, :cross, :ellipse, :custom}: Shape of the structuring elements */ rb_define_const(rb_module, "STRUCTURING_ELEMENT_SHAPE", structuring_element_shape); - RESIST_CVMETHOD(structuring_element_shape, "rect", CV_SHAPE_RECT); - RESIST_CVMETHOD(structuring_element_shape, "cross", CV_SHAPE_CROSS); - RESIST_CVMETHOD(structuring_element_shape, "ellipse", CV_SHAPE_ELLIPSE); - RESIST_CVMETHOD(structuring_element_shape, "custom", CV_SHAPE_CUSTOM); + REGISTER_CVMETHOD(structuring_element_shape, "rect", CV_SHAPE_RECT); + REGISTER_CVMETHOD(structuring_element_shape, "cross", CV_SHAPE_CROSS); + REGISTER_CVMETHOD(structuring_element_shape, "ellipse", CV_SHAPE_ELLIPSE); + REGISTER_CVMETHOD(structuring_element_shape, "custom", CV_SHAPE_CUSTOM); VALUE retrieval_mode = rb_hash_new(); /* {:external, :list, :ccomp, :tree}: Retrieval mode */ rb_define_const(rb_module, "RETRIEVAL_MODE", retrieval_mode); - RESIST_CVMETHOD(retrieval_mode, "external", CV_RETR_EXTERNAL); - RESIST_CVMETHOD(retrieval_mode, "list", CV_RETR_LIST); - RESIST_CVMETHOD(retrieval_mode, "ccomp", CV_RETR_CCOMP); - RESIST_CVMETHOD(retrieval_mode, "tree", CV_RETR_TREE); + REGISTER_CVMETHOD(retrieval_mode, "external", CV_RETR_EXTERNAL); + REGISTER_CVMETHOD(retrieval_mode, "list", CV_RETR_LIST); + REGISTER_CVMETHOD(retrieval_mode, "ccomp", CV_RETR_CCOMP); + REGISTER_CVMETHOD(retrieval_mode, "tree", CV_RETR_TREE); VALUE approx_chain_method = rb_hash_new(); /* {:code, :approx_none, :approx_simple, :apporx_tc89_11, :approx_tc89_kcos}: Approximation method */ rb_define_const(rb_module, "APPROX_CHAIN_METHOD", approx_chain_method); - RESIST_CVMETHOD(approx_chain_method, "code", CV_CHAIN_CODE); - RESIST_CVMETHOD(approx_chain_method, "approx_none", CV_CHAIN_APPROX_NONE); - RESIST_CVMETHOD(approx_chain_method, "approx_simple", CV_CHAIN_APPROX_SIMPLE); - RESIST_CVMETHOD(approx_chain_method, "approx_tc89_l1", CV_CHAIN_APPROX_TC89_L1); - RESIST_CVMETHOD(approx_chain_method, "approx_tc89_kcos", CV_CHAIN_APPROX_TC89_KCOS); + REGISTER_CVMETHOD(approx_chain_method, "code", CV_CHAIN_CODE); + REGISTER_CVMETHOD(approx_chain_method, "approx_none", CV_CHAIN_APPROX_NONE); + REGISTER_CVMETHOD(approx_chain_method, "approx_simple", CV_CHAIN_APPROX_SIMPLE); + REGISTER_CVMETHOD(approx_chain_method, "approx_tc89_l1", CV_CHAIN_APPROX_TC89_L1); + REGISTER_CVMETHOD(approx_chain_method, "approx_tc89_kcos", CV_CHAIN_APPROX_TC89_KCOS); VALUE approx_poly_method = rb_hash_new(); /* {:dp}: Approximation method (polygon) */ rb_define_const(rb_module, "APPROX_POLY_METHOD", approx_poly_method); - RESIST_CVMETHOD(approx_poly_method, "dp", CV_POLY_APPROX_DP); + REGISTER_CVMETHOD(approx_poly_method, "dp", CV_POLY_APPROX_DP); VALUE match_template_method = rb_hash_new(); /* {:sqdiff, :sqdiff_normed, :ccorr, :ccorr_normed, :ccoeff, :ccoeff_normed}: Match template method */ rb_define_const(rb_module, "MATCH_TEMPLATE_METHOD", match_template_method); - RESIST_CVMETHOD(match_template_method, "sqdiff", CV_TM_SQDIFF); - RESIST_CVMETHOD(match_template_method, "sqdiff_normed", CV_TM_SQDIFF_NORMED); - RESIST_CVMETHOD(match_template_method, "ccorr", CV_TM_CCORR); - RESIST_CVMETHOD(match_template_method, "ccorr_normed", CV_TM_CCORR_NORMED); - RESIST_CVMETHOD(match_template_method, "ccoeff", CV_TM_CCOEFF); - RESIST_CVMETHOD(match_template_method, "ccoeff_normed", CV_TM_CCOEFF_NORMED); + REGISTER_CVMETHOD(match_template_method, "sqdiff", CV_TM_SQDIFF); + REGISTER_CVMETHOD(match_template_method, "sqdiff_normed", CV_TM_SQDIFF_NORMED); + REGISTER_CVMETHOD(match_template_method, "ccorr", CV_TM_CCORR); + REGISTER_CVMETHOD(match_template_method, "ccorr_normed", CV_TM_CCORR_NORMED); + REGISTER_CVMETHOD(match_template_method, "ccoeff", CV_TM_CCOEFF); + REGISTER_CVMETHOD(match_template_method, "ccoeff_normed", CV_TM_CCOEFF_NORMED); VALUE morphological_operation = rb_hash_new(); /* {:open, :close, :gradient, :tophat, :blackhat}: Types of morphological operations */ rb_define_const(rb_module, "MORPHOLOGICAL_OPERATION", morphological_operation); - RESIST_CVMETHOD(morphological_operation, "open", CV_MOP_OPEN); - RESIST_CVMETHOD(morphological_operation, "close", CV_MOP_CLOSE); - RESIST_CVMETHOD(morphological_operation, "gradient", CV_MOP_GRADIENT); - RESIST_CVMETHOD(morphological_operation, "tophat", CV_MOP_TOPHAT); - RESIST_CVMETHOD(morphological_operation, "blackhat", CV_MOP_BLACKHAT); + REGISTER_CVMETHOD(morphological_operation, "open", CV_MOP_OPEN); + REGISTER_CVMETHOD(morphological_operation, "close", CV_MOP_CLOSE); + REGISTER_CVMETHOD(morphological_operation, "gradient", CV_MOP_GRADIENT); + REGISTER_CVMETHOD(morphological_operation, "tophat", CV_MOP_TOPHAT); + REGISTER_CVMETHOD(morphological_operation, "blackhat", CV_MOP_BLACKHAT); VALUE smoothing_type = rb_hash_new(); /* {:blur_no_scale, :blur, :gaussian, :median, :bilateral}: Types of smoothing */ rb_define_const(rb_module, "SMOOTHING_TYPE", smoothing_type); - RESIST_CVMETHOD(smoothing_type, "blur_no_scale", CV_BLUR_NO_SCALE); - RESIST_CVMETHOD(smoothing_type, "blur", CV_BLUR); - RESIST_CVMETHOD(smoothing_type, "gaussian", CV_GAUSSIAN); - RESIST_CVMETHOD(smoothing_type, "median", CV_MEDIAN); - RESIST_CVMETHOD(smoothing_type, "bilateral", CV_BILATERAL); + REGISTER_CVMETHOD(smoothing_type, "blur_no_scale", CV_BLUR_NO_SCALE); + REGISTER_CVMETHOD(smoothing_type, "blur", CV_BLUR); + REGISTER_CVMETHOD(smoothing_type, "gaussian", CV_GAUSSIAN); + REGISTER_CVMETHOD(smoothing_type, "median", CV_MEDIAN); + REGISTER_CVMETHOD(smoothing_type, "bilateral", CV_BILATERAL); VALUE threshold_type = rb_hash_new(); /* {:binary, :binary_inv, :trunc, :tozero, :tozero_inv, :otsu} : Thresholding types */ rb_define_const(rb_module, "THRESHOLD_TYPE", threshold_type); - RESIST_CVMETHOD(threshold_type, "binary", CV_THRESH_BINARY); - RESIST_CVMETHOD(threshold_type, "binary_inv", CV_THRESH_BINARY_INV); - RESIST_CVMETHOD(threshold_type, "trunc", CV_THRESH_TRUNC); - RESIST_CVMETHOD(threshold_type, "tozero", CV_THRESH_TOZERO); - RESIST_CVMETHOD(threshold_type, "tozero_inv", CV_THRESH_TOZERO_INV); - RESIST_CVMETHOD(threshold_type, "otsu", CV_THRESH_OTSU); + REGISTER_CVMETHOD(threshold_type, "binary", CV_THRESH_BINARY); + REGISTER_CVMETHOD(threshold_type, "binary_inv", CV_THRESH_BINARY_INV); + REGISTER_CVMETHOD(threshold_type, "trunc", CV_THRESH_TRUNC); + REGISTER_CVMETHOD(threshold_type, "tozero", CV_THRESH_TOZERO); + REGISTER_CVMETHOD(threshold_type, "tozero_inv", CV_THRESH_TOZERO_INV); + REGISTER_CVMETHOD(threshold_type, "otsu", CV_THRESH_OTSU); VALUE hough_transform_method = rb_hash_new(); /* {:standard, :probabilistic, :multi_scale} : Hough transform method */ rb_define_const(rb_module, "HOUGH_TRANSFORM_METHOD", hough_transform_method); - RESIST_CVMETHOD(hough_transform_method, "standard", CV_HOUGH_STANDARD); - RESIST_CVMETHOD(hough_transform_method, "probabilistic", CV_HOUGH_PROBABILISTIC); - RESIST_CVMETHOD(hough_transform_method, "multi_scale", CV_HOUGH_MULTI_SCALE); - RESIST_CVMETHOD(hough_transform_method, "gradient", CV_HOUGH_GRADIENT); + REGISTER_CVMETHOD(hough_transform_method, "standard", CV_HOUGH_STANDARD); + REGISTER_CVMETHOD(hough_transform_method, "probabilistic", CV_HOUGH_PROBABILISTIC); + REGISTER_CVMETHOD(hough_transform_method, "multi_scale", CV_HOUGH_MULTI_SCALE); + REGISTER_CVMETHOD(hough_transform_method, "gradient", CV_HOUGH_GRADIENT); VALUE inpaint_method = rb_hash_new(); /* {:ns, :telea} : Inpaint method */ rb_define_const(rb_module, "INPAINT_METHOD", inpaint_method); - RESIST_CVMETHOD(inpaint_method, "ns", CV_INPAINT_NS); - RESIST_CVMETHOD(inpaint_method, "telea", CV_INPAINT_TELEA); + REGISTER_CVMETHOD(inpaint_method, "ns", CV_INPAINT_NS); + REGISTER_CVMETHOD(inpaint_method, "telea", CV_INPAINT_TELEA); VALUE comparison_method = rb_hash_new(); /* Comparison method */ rb_define_const(rb_module, "COMPARISON_METHOD", comparison_method); - RESIST_CVMETHOD(comparison_method, "i1", CV_CONTOURS_MATCH_I1); - RESIST_CVMETHOD(comparison_method, "i2", CV_CONTOURS_MATCH_I2); - RESIST_CVMETHOD(comparison_method, "i3", CV_CONTOURS_MATCH_I3); + REGISTER_CVMETHOD(comparison_method, "i1", CV_CONTOURS_MATCH_I1); + REGISTER_CVMETHOD(comparison_method, "i2", CV_CONTOURS_MATCH_I2); + REGISTER_CVMETHOD(comparison_method, "i3", CV_CONTOURS_MATCH_I3); /* color convert methods */ rb_define_module_function(rb_module, "BGR2BGRA", RUBY_METHOD_FUNC(rb_BGR2BGRA), 1); diff --git a/ext/opencv/opencv.h b/ext/opencv/opencv.h index 098762c..54fffd9 100644 --- a/ext/opencv/opencv.h +++ b/ext/opencv/opencv.h @@ -10,7 +10,7 @@ #ifndef RUBY_OPENCV_H #define RUBY_OPENCV_H -#define __NAMESPACE_BEGIN_OPENCV namespace mOpenCV{ +#define __NAMESPACE_BEGIN_OPENCV namespace mOpenCV { #define __NAMESPACE_END_OPENCV } /* include headers */ @@ -31,7 +31,7 @@ #define ANYARGS () #endif -extern "C"{ +extern "C" { #ifdef HAVE_RUBY_ST_H #include #else @@ -148,7 +148,7 @@ extern "C"{ #define IF_DEPTH(val, ifnone) NIL_P(val) ? ifnone : NUM2INT(val) -#define RESIST_CVMETHOD(hash, str, value) rb_hash_aset(hash, ID2SYM(rb_intern(str)), INT2FIX(value)) +#define REGISTER_CVMETHOD(hash, str, value) rb_hash_aset(hash, ID2SYM(rb_intern(str)), INT2FIX(value)) #define LOOKUP_CVMETHOD(hash, key_as_cstr) (rb_hash_lookup(hash, ID2SYM(rb_intern(key_as_cstr)))) #define maxint(a,b) ({int _a = (a), _b = (b); _a > _b ? _a : _b; }) @@ -188,8 +188,8 @@ __NAMESPACE_BEGIN_OPENCV void mark_root_object(void *ptr); VALUE lookup_root_object(void *ptr); -void resist_root_object(void *ptr, VALUE root); -void unresist_object(void *ptr); +void register_root_object(void *ptr, VALUE root); +void unregister_object(void *ptr); void free_object(void *ptr); void release_object(void *ptr); void release_iplconvkernel_object(void *ptr); @@ -227,15 +227,15 @@ GENERIC_OBJECT(VALUE klass, void *ptr) inline VALUE DEPEND_OBJECT(VALUE klass, void *ptr, VALUE root) { - resist_root_object(ptr, root); + register_root_object(ptr, root); return Data_Wrap_Struct(klass, mark_root_object, free_object, ptr); } inline VALUE REFER_OBJECT(VALUE klass, void *ptr, VALUE root) { - resist_root_object(ptr, root); - return Data_Wrap_Struct(klass, mark_root_object, unresist_object, ptr); + register_root_object(ptr, root); + return Data_Wrap_Struct(klass, mark_root_object, unregister_object, ptr); } inline VALUE