diff --git a/ext/opencv/cvbox2d.cpp b/ext/opencv/cvbox2d.cpp index 84e52d2..c0ffbc1 100644 --- a/ext/opencv/cvbox2d.cpp +++ b/ext/opencv/cvbox2d.cpp @@ -69,16 +69,17 @@ VALUE rb_initialize(int argc, VALUE *argv, VALUE self) { VALUE center, size, angle; + CvBox2D* self_ptr = CVBOX2D(self); rb_scan_args(argc, argv, "03", ¢er, &size, &angle); - if (!NIL_P(center)) - CVBOX2D(self)->center = VALUE_TO_CVPOINT2D32F(center); - - if (!NIL_P(size)) - CVBOX2D(self)->size = VALUE_TO_CVSIZE2D32F(size); - if (!NIL_P(size)) - CVBOX2D(self)->angle = NUM2DBL(angle); - + if (!NIL_P(center)) { + self_ptr->center = VALUE_TO_CVPOINT2D32F(center); + } + if (!NIL_P(size)) { + self_ptr->size = VALUE_TO_CVSIZE2D32F(size); + self_ptr->angle = NUM2DBL(angle); + } + return self; } @@ -172,8 +173,9 @@ rb_points(VALUE self) raise_cverror(e); } VALUE points = rb_ary_new2(n); - for (int i = 0; i < n; ++i) - rb_ary_store(points, i, cCvPoint2D32f::new_object(p[i])); + for (int i = 0; i < n; ++i) { + rb_ary_store(points, i, cCvPoint2D32f::new_object(p[i])); + } return points; } diff --git a/ext/opencv/cvbox2d.h b/ext/opencv/cvbox2d.h index 95a1861..38da887 100644 --- a/ext/opencv/cvbox2d.h +++ b/ext/opencv/cvbox2d.h @@ -53,6 +53,7 @@ VALUE_TO_CVBOX2D(VALUE object){ else { raise_typeerror(object, cCvBox2D::rb_class()); } + throw "Should never reach here"; } __NAMESPACE_END_OPENCV diff --git a/ext/opencv/cvfeaturetree.cpp b/ext/opencv/cvfeaturetree.cpp index 498470a..316da98 100644 --- a/ext/opencv/cvfeaturetree.cpp +++ b/ext/opencv/cvfeaturetree.cpp @@ -87,6 +87,7 @@ rb_initialize(VALUE self, VALUE desc) raise_cverror(e); } self_ptr->desc = desc; + return self; } /* diff --git a/ext/opencv/cvpoint.h b/ext/opencv/cvpoint.h index 36ad12c..e11ca45 100644 --- a/ext/opencv/cvpoint.h +++ b/ext/opencv/cvpoint.h @@ -47,7 +47,8 @@ CVPOINT(VALUE object){ } inline CvPoint -VALUE_TO_CVPOINT(VALUE object){ +VALUE_TO_CVPOINT(VALUE object) +{ if (cCvPoint::rb_compatible_q(cCvPoint::rb_class(), object)) { return cvPoint(NUM2INT(rb_funcall(object, rb_intern("x"), 0)), NUM2INT(rb_funcall(object, rb_intern("y"), 0))); @@ -55,6 +56,7 @@ VALUE_TO_CVPOINT(VALUE object){ else { raise_compatible_typeerror(object, cCvPoint::rb_class()); } + throw "Should never reach here"; } __NAMESPACE_END_OPENCV diff --git a/ext/opencv/cvpoint2d32f.h b/ext/opencv/cvpoint2d32f.h index 020af23..00ad613 100644 --- a/ext/opencv/cvpoint2d32f.h +++ b/ext/opencv/cvpoint2d32f.h @@ -56,6 +56,7 @@ VALUE_TO_CVPOINT2D32F(VALUE object) else { raise_compatible_typeerror(object, cCvPoint2D32f::rb_class()); } + throw "Should never reach here"; } __NAMESPACE_END_OPENCV diff --git a/ext/opencv/cvpoint3d32f.h b/ext/opencv/cvpoint3d32f.h index f8e47fa..d80c64a 100644 --- a/ext/opencv/cvpoint3d32f.h +++ b/ext/opencv/cvpoint3d32f.h @@ -59,6 +59,7 @@ VALUE_TO_CVPOINT3D32F(VALUE object) else { raise_compatible_typeerror(object, cCvPoint3D32f::rb_class()); } + throw "Should never reach here"; } __NAMESPACE_END_OPENCV diff --git a/ext/opencv/cvrect.h b/ext/opencv/cvrect.h index 43f4997..01f6a6c 100644 --- a/ext/opencv/cvrect.h +++ b/ext/opencv/cvrect.h @@ -71,6 +71,7 @@ VALUE_TO_CVRECT(VALUE object) else { raise_compatible_typeerror(object, cCvRect::rb_class()); } + throw "Should never reach here"; } __NAMESPACE_END_OPENCV diff --git a/ext/opencv/cvscalar.h b/ext/opencv/cvscalar.h index 1530eb9..42638d1 100644 --- a/ext/opencv/cvscalar.h +++ b/ext/opencv/cvscalar.h @@ -51,15 +51,19 @@ inline CvScalar VALUE_TO_CVSCALAR(VALUE object) { ID aref_id; - if (FIXNUM_P(object)) + if (FIXNUM_P(object)) { return cvScalarAll(FIX2INT(object)); - else if (rb_respond_to(object, (aref_id = rb_intern("[]")))) + } + else if (rb_respond_to(object, (aref_id = rb_intern("[]")))) { return cvScalar(NUM2DBL(rb_funcall(object, aref_id, 1, INT2FIX(0))), NUM2DBL(rb_funcall(object, aref_id, 1, INT2FIX(1))), NUM2DBL(rb_funcall(object, aref_id, 1, INT2FIX(2))), NUM2DBL(rb_funcall(object, aref_id, 1, INT2FIX(3)))); - else + } + else { raise_compatible_typeerror(object, cCvScalar::rb_class()); + } + throw "Should never reach here"; } __NAMESPACE_END_OPENCV diff --git a/ext/opencv/cvsize.h b/ext/opencv/cvsize.h index fd30027..69fe820 100644 --- a/ext/opencv/cvsize.h +++ b/ext/opencv/cvsize.h @@ -57,6 +57,7 @@ VALUE_TO_CVSIZE(VALUE object) else { raise_compatible_typeerror(object, cCvSize::rb_class()); } + throw "Should never reach here"; } __NAMESPACE_END_OPENCV diff --git a/ext/opencv/cvsize2d32f.h b/ext/opencv/cvsize2d32f.h index dc46ec1..679e282 100644 --- a/ext/opencv/cvsize2d32f.h +++ b/ext/opencv/cvsize2d32f.h @@ -56,6 +56,7 @@ VALUE_TO_CVSIZE2D32F(VALUE object) else { raise_compatible_typeerror(object, cCvSize2D32f::rb_class()); } + throw "Should never reach here"; } __NAMESPACE_END_OPENCV diff --git a/ext/opencv/cvslice.h b/ext/opencv/cvslice.h index 9b86b3d..5f89d97 100644 --- a/ext/opencv/cvslice.h +++ b/ext/opencv/cvslice.h @@ -53,6 +53,7 @@ VALUE_TO_CVSLICE(VALUE object) else { raise_compatible_typeerror(object, cCvSlice::rb_class()); } + throw "Should never reach here"; } __NAMESPACE_END_OPENCV diff --git a/ext/opencv/iplimage.cpp b/ext/opencv/iplimage.cpp index f89fa7b..acbecb6 100644 --- a/ext/opencv/iplimage.cpp +++ b/ext/opencv/iplimage.cpp @@ -358,7 +358,7 @@ compute_smoothness(const IplImage *pFourierImage, const double lowFreqRatio, con filteredFourierImage = create_frequency_filtered_image(pFourierImage, low, high); scalar = cvSum(filteredFourierImage); - totalIntensity = scalar.val[0]; + totalIntensity = (int)scalar.val[0]; cvReleaseImage(&filteredFourierImage); outLowDensity = den = totalIntensity / totalArea; @@ -370,7 +370,7 @@ compute_smoothness(const IplImage *pFourierImage, const double lowFreqRatio, con filteredFourierImage = create_frequency_filtered_image(pFourierImage, low, high); scalar = cvSum(filteredFourierImage); - totalIntensity = scalar.val[0]; + totalIntensity = (int)scalar.val[0]; cvReleaseImage(&filteredFourierImage); outHighDensity = den = totalIntensity / totalArea; @@ -516,13 +516,13 @@ create_frequency_filtered_image(const IplImage *pImage, int low, int high) { CvPoint2D32f center; - center.x = pImage->width / 2; - center.y = pImage->height / 2; + center.x = (float)(pImage->width / 2); + center.y = (float)(pImage->height / 2); CvBox2D box; box.center = center; - box.size.width = high; - box.size.height = high; + box.size.width = (float)high; + box.size.height = (float)high; IplImage *pFilterMask = rb_cvCreateImage(cvGetSize(pImage), IPL_DEPTH_64F, 1); IplImage *pFiltered = rb_cvCreateImage(cvGetSize(pImage), IPL_DEPTH_64F, 1); @@ -533,8 +533,8 @@ create_frequency_filtered_image(const IplImage *pImage, int low, int high) if (high > 0) cvEllipseBox(pFilterMask, box, cvScalar(255, 255, 255, 255), CV_FILLED, 8, 0); - box.size.width = low; - box.size.height = low; + box.size.width = (float)low; + box.size.height = (float)low; if (low > 0) cvEllipseBox(pFilterMask, box, cvScalar(0, 0, 0, 0), CV_FILLED, 8, 0); diff --git a/extconf.rb b/extconf.rb index 8c6260f..67c1f83 100755 --- a/extconf.rb +++ b/extconf.rb @@ -41,7 +41,7 @@ when /mswin32/ opencv_libraries.map! {|lib| lib + OPENCV_VERSION_SUFFIX } have_library("msvcrt") opencv_libraries.each{|lib| - raise "lib#{lib} not found." unless have_library(lib) + raise "#{lib}.lib not found." unless have_library(lib) } $CFLAGS << ' /EHsc' else