mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
uniformed code format
This commit is contained in:
parent
2ac67221f9
commit
42c6f5cc37
30 changed files with 144 additions and 141 deletions
|
@ -7,7 +7,7 @@
|
|||
Copyright (C) 2005 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#include"curve.h"
|
||||
#include "curve.h"
|
||||
/*
|
||||
* Document-class: OpenCV::Curve
|
||||
*
|
||||
|
@ -27,7 +27,7 @@ rb_module()
|
|||
void
|
||||
define_ruby_module()
|
||||
{
|
||||
if(module)
|
||||
if (module)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#ifndef RUBY_OPENCV_CVSEQ_CURVE_H
|
||||
#define RUBY_OPENCV_CVSEQ_CURVE_H
|
||||
|
||||
#include"opencv.h"
|
||||
#include "opencv.h"
|
||||
|
||||
#define __NAMESPACE_BEGIN_CURVE namespace mCurve{
|
||||
#define __NAMESPACE_BEGIN_CURVE namespace mCurve {
|
||||
#define __NAMESPACE_END_CURVE }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
|
|
|
@ -32,7 +32,7 @@ rb_class()
|
|||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if(rb_klass)
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#ifndef RUBY_OPENCV_CVBOX2D_H
|
||||
#define RUBY_OPENCV_CVBOX2D_H
|
||||
|
||||
#include"opencv.h"
|
||||
#include "opencv.h"
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVBOX2D namespace cCvBox2D{
|
||||
#define __NAMESPACE_BEGIN_CVBOX2D namespace cCvBox2D {
|
||||
#define __NAMESPACE_END_CVBOX2D }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
|
|
|
@ -26,7 +26,7 @@ rb_class()
|
|||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if(rb_klass)
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#ifndef RUBY_OPENCV_CVHAARCLASSIFIERCASCADE_H
|
||||
#define RUBY_OPENCV_CVHAARCLASSIFIERCASCADE_H
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVHAARCLASSIFERCASCADE namespace cCvHaarClassifierCascade{
|
||||
#define __NAMESPACE_BEGIN_CVHAARCLASSIFERCASCADE namespace cCvHaarClassifierCascade {
|
||||
#define __NAMESPACE_END_CVHAARCLASSIFERCASCADE }
|
||||
|
||||
#include"opencv.h"
|
||||
#include "opencv.h"
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVHAARCLASSIFERCASCADE
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* CvMat is basic 2D matrix class in OpenCV.
|
||||
*
|
||||
* C structure is here.
|
||||
* typedef struct CvMat{
|
||||
* typedef struct CvMat {
|
||||
* int type;
|
||||
* int step;
|
||||
* int *refcount;
|
||||
|
@ -460,7 +460,7 @@ rb_method_missing(int argc, VALUE *argv, VALUE self)
|
|||
rb_scan_args(argc, argv, "1*", &name, &args);
|
||||
if (RARRAY_LEN(args) != 0)
|
||||
return rb_call_super(argc, argv);
|
||||
if(rb_reg_match(rb_reg_new(to_str, strlen(to_str), 0), rb_funcall(name, rb_intern("to_s"), 0)) == Qnil)
|
||||
if (rb_reg_match(rb_reg_new(to_str, strlen(to_str), 0), rb_funcall(name, rb_intern("to_s"), 0)) == Qnil)
|
||||
return rb_call_super(argc, argv);
|
||||
str[0] = rb_str_new2("%s2%s");
|
||||
str[1] = rb_color_model(self);
|
||||
|
@ -1017,7 +1017,7 @@ rb_get_cols(VALUE self, VALUE args)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* each_row{|row| ... } -> self
|
||||
* each_row {|row| ... } -> self
|
||||
*
|
||||
* Calls block once for each row in self, passing that element as a parameter.
|
||||
*
|
||||
|
@ -3591,7 +3591,7 @@ rb_good_features_to_track(int argc, VALUE *argv, VALUE self)
|
|||
rb_scan_args(argc, argv, "21", &quality_level, &min_distance, &good_features_to_track_option);
|
||||
good_features_to_track_option = GOOD_FEATURES_TO_TRACK_OPTION(good_features_to_track_option);
|
||||
int np = GF_MAX(good_features_to_track_option);
|
||||
if(np <= 0)
|
||||
if (np <= 0)
|
||||
rb_raise(rb_eArgError, "option :max should be positive value.");
|
||||
|
||||
CvMat *self_ptr = CVMAT(self);
|
||||
|
|
|
@ -27,7 +27,7 @@ rb_class()
|
|||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if(rb_klass)
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
Copyright (C) 2005 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#include"cvpoint2d32f.h"
|
||||
#include "cvpoint2d32f.h"
|
||||
/*
|
||||
* Document-class: OpenCV::CvPoint2D32f
|
||||
*
|
||||
|
@ -34,7 +34,7 @@ rb_class()
|
|||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if(rb_klass)
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#ifndef RUBY_OPENCV_CVPOINT2D32F_H
|
||||
#define RUBY_OPENCV_CVPOINT2D32F_H
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVPOINT2D32F namespace cCvPoint2D32f{
|
||||
#define __NAMESPACE_BEGIN_CVPOINT2D32F namespace cCvPoint2D32f {
|
||||
#define __NAMESPACE_END_CVPOINT2D32F }
|
||||
|
||||
#include"opencv.h"
|
||||
#include "opencv.h"
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVPOINT2D32F
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
Copyright (C) 2005-2008 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#include"cvpoint3d32f.h"
|
||||
#include "cvpoint3d32f.h"
|
||||
/*
|
||||
* Document-class: OpenCV::CvPoint3D32f
|
||||
*
|
||||
|
@ -15,7 +15,7 @@
|
|||
* X and Y takes the value of the Float. see also CvPoint
|
||||
*
|
||||
* C structure is here, very simple.
|
||||
* typdef struct CvPoint3D32f{
|
||||
* typdef struct CvPoint3D32f {
|
||||
* float x;
|
||||
* float y;
|
||||
* float z;
|
||||
|
@ -35,7 +35,7 @@ rb_class()
|
|||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if(rb_klass)
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#ifndef RUBY_OPENCV_CVPOINT3D32F_H
|
||||
#define RUBY_OPENCV_CVPOINT3D32F_H
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVPOINT3D32F namespace cCvPoint3D32f{
|
||||
#define __NAMESPACE_BEGIN_CVPOINT3D32F namespace cCvPoint3D32f {
|
||||
#define __NAMESPACE_END_CVPOINT3D32F }
|
||||
|
||||
#include"opencv.h"
|
||||
#include "opencv.h"
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVPOINT3D32F
|
||||
|
@ -56,7 +56,7 @@ VALUE_TO_CVPOINT3D32F(VALUE object)
|
|||
NUM2DBL(rb_funcall(object, rb_intern("y"), 0)),
|
||||
NUM2DBL(rb_funcall(object, rb_intern("z"), 0)));
|
||||
}
|
||||
else{
|
||||
else {
|
||||
raise_compatible_typeerror(object, cCvPoint3D32f::rb_class());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ rb_class()
|
|||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if(rb_klass)
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#ifndef RUBY_OPENCV_CVRECT_H
|
||||
#define RUBY_OPENCV_CVRECT_H
|
||||
|
||||
#include"opencv.h"
|
||||
#include "opencv.h"
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVRECT namespace cCvRect{
|
||||
#define __NAMESPACE_BEGIN_CVRECT namespace cCvRect {
|
||||
#define __NAMESPACE_END_CVRECT }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
|
|
|
@ -469,7 +469,7 @@ VALUE
|
|||
rb_shift(VALUE self)
|
||||
{
|
||||
CvSeq *seq = CVSEQ(self);
|
||||
if(seq->total == 0)
|
||||
if (seq->total == 0)
|
||||
return Qnil;
|
||||
|
||||
VALUE object = Qnil;
|
||||
|
|
|
@ -27,7 +27,7 @@ rb_class()
|
|||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if(rb_klass)
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -34,7 +34,7 @@ rb_class()
|
|||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if(rb_klass)
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#ifndef RUBY_OPENCV_CVSIZE_H
|
||||
#define RUBY_OPENCV_CVSIZE_H
|
||||
|
||||
#include"opencv.h"
|
||||
#include "opencv.h"
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVSIZE namespace cCvSize{
|
||||
#define __NAMESPACE_BEGIN_CVSIZE namespace cCvSize {
|
||||
#define __NAMESPACE_END_CVSIZE }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
* X and Y takes the value of the Float.
|
||||
*
|
||||
* C structure is here, very simple.
|
||||
* typdef struct CvSize2D32f{
|
||||
* typdef struct CvSize2D32f {
|
||||
* float width;
|
||||
* float height;
|
||||
* }CvSize2D32f;
|
||||
* } CvSize2D32f;
|
||||
*/
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_CVSIZE2D32F
|
||||
|
@ -34,7 +34,7 @@ rb_class()
|
|||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if(rb_klass)
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -33,7 +33,7 @@ rb_class()
|
|||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if(rb_klass)
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -38,7 +38,7 @@ rb_class()
|
|||
void
|
||||
define_ruby_class()
|
||||
{
|
||||
if(rb_klass)
|
||||
if (rb_klass)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
Copyright (C) 2005-2006 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#include"cvtermcriteria.h"
|
||||
#include "cvtermcriteria.h"
|
||||
/*
|
||||
* Document-class: OpenCV::CvTermCriteria
|
||||
*
|
||||
|
@ -150,7 +150,7 @@ VALUE
|
|||
rb_eps(VALUE self)
|
||||
{
|
||||
CvTermCriteria *ptr = CVTERMCRITERIA(self);
|
||||
if(ptr->type & CV_TERMCRIT_EPS)
|
||||
if (ptr->type & CV_TERMCRIT_EPS)
|
||||
return rb_float_new(ptr->epsilon);
|
||||
else
|
||||
return Qnil;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "opencv.h"
|
||||
|
||||
#define __NAMESPACE_BEGIN_CVTERMCRITERIA namespace cCvTermCriteria{
|
||||
#define __NAMESPACE_BEGIN_CVTERMCRITERIA namespace cCvTermCriteria {
|
||||
#define __NAMESPACE_END_CVTERMCRITERIA }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
|
|
|
@ -28,7 +28,7 @@ rb_module_GUI()
|
|||
void
|
||||
define_ruby_module()
|
||||
{
|
||||
if(rb_module)
|
||||
if (rb_module)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
|
|
@ -272,25 +272,29 @@ rb_smoothness(int argc, VALUE *argv, VALUE self)
|
|||
double outLowDensity, outHighDensity;
|
||||
if (TYPE(lowFreqRatio) == T_NIL) {
|
||||
f_lowFreqRatio = 10 / 128.0f;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Check_Type(lowFreqRatio, T_FLOAT);
|
||||
f_lowFreqRatio = NUM2DBL(lowFreqRatio);
|
||||
}
|
||||
if (TYPE(blankDensity) == T_NIL) {
|
||||
f_blankDensity = 1.2f;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Check_Type(blankDensity, T_FLOAT);
|
||||
f_blankDensity = NUM2DBL(blankDensity);
|
||||
}
|
||||
if (TYPE(messyDensity) == T_NIL) {
|
||||
f_messyDensity = 0.151f;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Check_Type(messyDensity, T_FLOAT);
|
||||
f_messyDensity = NUM2DBL(messyDensity);
|
||||
}
|
||||
if (TYPE(highFreqRatio) == T_NIL) {
|
||||
f_highFreqRatio = 5 / 128.0f;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Check_Type(highFreqRatio, T_FLOAT);
|
||||
f_highFreqRatio = NUM2DBL(highFreqRatio);
|
||||
}
|
||||
|
@ -300,30 +304,31 @@ rb_smoothness(int argc, VALUE *argv, VALUE self)
|
|||
|
||||
// the image is required to be in depth of 64
|
||||
if (IPLIMAGE(self)->depth == 64) {
|
||||
p64DepthImage = NULL;
|
||||
pFourierImage = create_fourier_image(IPLIMAGE(self));
|
||||
} else {
|
||||
p64DepthImage = rb_cvCreateImage(cvGetSize(IPLIMAGE(self)), IPL_DEPTH_64F, 1);
|
||||
cvConvertScale(CVARR(self), p64DepthImage, 1.0, 0.0);
|
||||
pFourierImage = create_fourier_image(p64DepthImage);
|
||||
p64DepthImage = NULL;
|
||||
pFourierImage = create_fourier_image(IPLIMAGE(self));
|
||||
}
|
||||
else {
|
||||
p64DepthImage = rb_cvCreateImage(cvGetSize(IPLIMAGE(self)), IPL_DEPTH_64F, 1);
|
||||
cvConvertScale(CVARR(self), p64DepthImage, 1.0, 0.0);
|
||||
pFourierImage = create_fourier_image(p64DepthImage);
|
||||
}
|
||||
|
||||
Smoothness result = compute_smoothness(pFourierImage, f_lowFreqRatio, f_blankDensity, f_messyDensity, f_highFreqRatio, outLowDensity, outHighDensity);
|
||||
Smoothness result = compute_smoothness(pFourierImage, f_lowFreqRatio, f_blankDensity, f_messyDnsity,
|
||||
f_highFreqRatio, outLowDensity, outHighDensity);
|
||||
|
||||
cvReleaseImage(&pFourierImage);
|
||||
if (p64DepthImage != NULL)
|
||||
cvReleaseImage(&p64DepthImage);
|
||||
cvReleaseImage(&p64DepthImage);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
case SMOOTH:
|
||||
return rb_ary_new3(3, ID2SYM(rb_intern("smooth")), rb_float_new(outLowDensity), rb_float_new(outHighDensity));
|
||||
case MESSY:
|
||||
return rb_ary_new3(3, ID2SYM(rb_intern("messy")), rb_float_new(outLowDensity), rb_float_new(outHighDensity));
|
||||
case BLANK:
|
||||
return rb_ary_new3(3, ID2SYM(rb_intern("blank")), rb_float_new(outLowDensity), rb_float_new(outHighDensity));
|
||||
default:
|
||||
return rb_ary_new3(3, NULL, rb_float_new(outLowDensity), rb_float_new(outHighDensity));
|
||||
switch(result) {
|
||||
case SMOOTH:
|
||||
return rb_ary_new3(3, ID2SYM(rb_intern("smooth")), rb_float_new(outLowDensity), rb_float_new(outHighDensity));
|
||||
case MESSY:
|
||||
return rb_ary_new3(3, ID2SYM(rb_intern("messy")), rb_float_new(outLowDensity), rb_float_new(outHighDensity));
|
||||
case BLANK:
|
||||
return rb_ary_new3(3, ID2SYM(rb_intern("blank")), rb_float_new(outLowDensity), rb_float_new(outHighDensity));
|
||||
default:
|
||||
return rb_ary_new3(3, NULL, rb_float_new(outLowDensity), rb_float_new(outHighDensity));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,7 +338,9 @@ rb_smoothness(int argc, VALUE *argv, VALUE self)
|
|||
* else -> good;
|
||||
*/
|
||||
Smoothness
|
||||
compute_smoothness(const IplImage *pFourierImage, const double lowFreqRatio, const double blankDensity, const double messyDensity, const double highFreqRatio, double &outLowDensity, double &outHighDensity)
|
||||
compute_smoothness(const IplImage *pFourierImage, const double lowFreqRatio, const double blankDensity,
|
||||
const double messyDensity, const double highFreqRatio, double &outLowDensity
|
||||
double &outHighDensity)
|
||||
{
|
||||
int low, high;
|
||||
IplImage *filteredFourierImage;
|
||||
|
@ -341,8 +348,9 @@ compute_smoothness(const IplImage *pFourierImage, const double lowFreqRatio, con
|
|||
double sum, den, totalArea;
|
||||
CvScalar scalar;
|
||||
|
||||
if(! (pFourierImage->nChannels == 1 && pFourierImage->depth == 64) ) {
|
||||
cvError( CV_StsUnmatchedSizes, "compute_smoothness", "input image must contain only 1 channel and a depth of 64", __FILE__, __LINE__ );
|
||||
if (!(pFourierImage->nChannels == 1 && pFourierImage->depth == 64) ) {
|
||||
cvError(CV_StsUnmatchedSizes, "compute_smoothness", "input image must contain only 1 channel and a depth of 64",
|
||||
__FILE__, __LINE__ );
|
||||
}
|
||||
|
||||
high_pass_range(pFourierImage, lowFreqRatio, low, high );
|
||||
|
@ -354,12 +362,11 @@ compute_smoothness(const IplImage *pFourierImage, const double lowFreqRatio, con
|
|||
cvReleaseImage(&filteredFourierImage);
|
||||
outLowDensity = den = totalIntensity / totalArea;
|
||||
|
||||
if(den <= blankDensity)
|
||||
{
|
||||
if (den <= blankDensity) {
|
||||
return BLANK;
|
||||
}
|
||||
|
||||
low = (int) (high * (1.0 - highFreqRatio));
|
||||
low = (int)(high * (1.0 - highFreqRatio));
|
||||
|
||||
filteredFourierImage = create_frequency_filtered_image(pFourierImage, low, high);
|
||||
scalar = cvSum(filteredFourierImage);
|
||||
|
@ -367,8 +374,7 @@ compute_smoothness(const IplImage *pFourierImage, const double lowFreqRatio, con
|
|||
cvReleaseImage(&filteredFourierImage);
|
||||
outHighDensity = den = totalIntensity / totalArea;
|
||||
|
||||
if(den >= messyDensity)
|
||||
{
|
||||
if (den >= messyDensity) {
|
||||
return MESSY;
|
||||
}
|
||||
|
||||
|
@ -393,37 +399,39 @@ cvShiftDFT(CvArr *src_arr, CvArr *dst_arr )
|
|||
CvSize dst_size = cvGetSize(dst_arr);
|
||||
int cx, cy;
|
||||
|
||||
if(dst_size.width != size.width ||
|
||||
dst_size.height != size.height){
|
||||
cvError( CV_StsUnmatchedSizes, "cvShiftDFT", "Source and Destination arrays must have equal sizes", __FILE__, __LINE__ );
|
||||
if (dst_size.width != size.width ||
|
||||
dst_size.height != size.height) {
|
||||
cvError( CV_StsUnmatchedSizes, "cvShiftDFT", "Source and Destination arrays must have equal sizes",
|
||||
__FILE__, __LINE__ );
|
||||
}
|
||||
|
||||
if(src_arr==dst_arr){
|
||||
tmp = rb_cvCreateMat(size.height/2, size.width/2, cvGetElemType(src_arr));
|
||||
if (src_arr == dst_arr) {
|
||||
tmp = rb_cvCreateMat(size.height / 2, size.width / 2, cvGetElemType(src_arr));
|
||||
}
|
||||
|
||||
cx = size.width/2;
|
||||
cy = size.height/2; // image center
|
||||
cx = size.width / 2;
|
||||
cy = size.height / 2; // image center
|
||||
|
||||
q1 = cvGetSubRect( src_arr, &q1stub, cvRect(0,0,cx, cy) );
|
||||
q2 = cvGetSubRect( src_arr, &q2stub, cvRect(cx,0,cx,cy) );
|
||||
q3 = cvGetSubRect( src_arr, &q3stub, cvRect(cx,cy,cx,cy) );
|
||||
q4 = cvGetSubRect( src_arr, &q4stub, cvRect(0,cy,cx,cy) );
|
||||
d1 = cvGetSubRect( src_arr, &d1stub, cvRect(0,0,cx,cy) );
|
||||
d2 = cvGetSubRect( src_arr, &d2stub, cvRect(cx,0,cx,cy) );
|
||||
d3 = cvGetSubRect( src_arr, &d3stub, cvRect(cx,cy,cx,cy) );
|
||||
d4 = cvGetSubRect( src_arr, &d4stub, cvRect(0,cy,cx,cy) );
|
||||
q1 = cvGetSubRect(src_arr, &q1stub, cvRect(0,0,cx, cy));
|
||||
q2 = cvGetSubRect(src_arr, &q2stub, cvRect(cx,0,cx,cy));
|
||||
q3 = cvGetSubRect(src_arr, &q3stub, cvRect(cx,cy,cx,cy));
|
||||
q4 = cvGetSubRect(src_arr, &q4stub, cvRect(0,cy,cx,cy));
|
||||
d1 = cvGetSubRect(src_arr, &d1stub, cvRect(0,0,cx,cy));
|
||||
d2 = cvGetSubRect(src_arr, &d2stub, cvRect(cx,0,cx,cy));
|
||||
d3 = cvGetSubRect(src_arr, &d3stub, cvRect(cx,cy,cx,cy));
|
||||
d4 = cvGetSubRect(src_arr, &d4stub, cvRect(0,cy,cx,cy));
|
||||
|
||||
if(src_arr!=dst_arr){
|
||||
if( !CV_ARE_TYPES_EQ( q1, d1 )){
|
||||
cvError( CV_StsUnmatchedFormats, "cvShiftDFT", "Source and Destination arrays must have the same format", __FILE__, __LINE__ );
|
||||
if (src_arr != dst_arr) {
|
||||
if (!CV_ARE_TYPES_EQ(q1, d1)) {
|
||||
cvError(CV_StsUnmatchedFormats, "cvShiftDFT", "Source and Destination arrays must have the same format",
|
||||
__FILE__, __LINE__ );
|
||||
}
|
||||
cvCopy(q3, d1, 0);
|
||||
cvCopy(q4, d2, 0);
|
||||
cvCopy(q1, d3, 0);
|
||||
cvCopy(q2, d4, 0);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
cvCopy(q3, tmp, 0);
|
||||
cvCopy(q1, q3, 0);
|
||||
cvCopy(tmp, q1, 0);
|
||||
|
@ -432,16 +440,14 @@ cvShiftDFT(CvArr *src_arr, CvArr *dst_arr )
|
|||
cvCopy(tmp, q2, 0);
|
||||
}
|
||||
|
||||
if (tmp != NULL)
|
||||
{
|
||||
cvReleaseMat(&tmp);
|
||||
if (tmp != NULL) {
|
||||
cvReleaseMat(&tmp);
|
||||
}
|
||||
}
|
||||
|
||||
IplImage*
|
||||
create_fourier_image(const IplImage *im)
|
||||
{
|
||||
|
||||
IplImage *realInput;
|
||||
IplImage *imaginaryInput;
|
||||
IplImage *complexInput;
|
||||
|
@ -450,51 +456,50 @@ create_fourier_image(const IplImage *im)
|
|||
IplImage *image_Re;
|
||||
IplImage *image_Im;
|
||||
|
||||
realInput = rb_cvCreateImage( cvGetSize(im), IPL_DEPTH_64F, 1);
|
||||
imaginaryInput = rb_cvCreateImage( cvGetSize(im), IPL_DEPTH_64F, 1);
|
||||
complexInput = rb_cvCreateImage( cvGetSize(im), IPL_DEPTH_64F, 2);
|
||||
realInput = rb_cvCreateImage(cvGetSize(im), IPL_DEPTH_64F, 1);
|
||||
imaginaryInput = rb_cvCreateImage(cvGetSize(im), IPL_DEPTH_64F, 1);
|
||||
complexInput = rb_cvCreateImage(cvGetSize(im), IPL_DEPTH_64F, 2);
|
||||
|
||||
cvScale(im, realInput, 1.0, 0.0);
|
||||
cvZero(imaginaryInput);
|
||||
cvMerge(realInput, imaginaryInput, NULL, NULL, complexInput);
|
||||
|
||||
dft_M = cvGetOptimalDFTSize( im->height - 1 );
|
||||
dft_N = cvGetOptimalDFTSize( im->width - 1 );
|
||||
dft_M = cvGetOptimalDFTSize(im->height - 1);
|
||||
dft_N = cvGetOptimalDFTSize(im->width - 1);
|
||||
|
||||
dft_A = rb_cvCreateMat( dft_M, dft_N, CV_64FC2 );
|
||||
image_Re = rb_cvCreateImage( cvSize(dft_N, dft_M), IPL_DEPTH_64F, 1);
|
||||
image_Im = rb_cvCreateImage( cvSize(dft_N, dft_M), IPL_DEPTH_64F, 1);
|
||||
dft_A = rb_cvCreateMat(dft_M, dft_N, CV_64FC2);
|
||||
image_Re = rb_cvCreateImage(cvSize(dft_N, dft_M), IPL_DEPTH_64F, 1);
|
||||
image_Im = rb_cvCreateImage(cvSize(dft_N, dft_M), IPL_DEPTH_64F, 1);
|
||||
|
||||
// copy A to dft_A and pad dft_A with zeros
|
||||
cvGetSubRect( dft_A, &tmp, cvRect(0,0, im->width, im->height));
|
||||
cvCopy( complexInput, &tmp, NULL );
|
||||
if( dft_A->cols > im->width )
|
||||
{
|
||||
cvGetSubRect( dft_A, &tmp, cvRect(im->width,0, dft_A->cols - im->width, im->height));
|
||||
cvZero( &tmp );
|
||||
cvGetSubRect(dft_A, &tmp, cvRect(0,0, im->width, im->height));
|
||||
cvCopy(complexInput, &tmp, NULL);
|
||||
if (dft_A->cols > im->width) {
|
||||
cvGetSubRect(dft_A, &tmp, cvRect(im->width,0, dft_A->cols - im->width, im->height));
|
||||
cvZero(&tmp);
|
||||
}
|
||||
|
||||
// no need to pad bottom part of dft_A with zeros because of
|
||||
// use nonzero_rows parameter in cvDFT() call below
|
||||
|
||||
cvDFT( dft_A, dft_A, CV_DXT_FORWARD, complexInput->height );
|
||||
cvDFT(dft_A, dft_A, CV_DXT_FORWARD, complexInput->height);
|
||||
|
||||
// Split Fourier in real and imaginary parts
|
||||
cvSplit( dft_A, image_Re, image_Im, 0, 0 );
|
||||
cvSplit(dft_A, image_Re, image_Im, 0, 0);
|
||||
|
||||
// Compute the magnitude of the spectrum Mag = sqrt(Re^2 + Im^2)
|
||||
cvPow( image_Re, image_Re, 2.0);
|
||||
cvPow( image_Im, image_Im, 2.0);
|
||||
cvAdd( image_Re, image_Im, image_Re, NULL);
|
||||
cvPow( image_Re, image_Re, 0.5 );
|
||||
cvPow(image_Re, image_Re, 2.0);
|
||||
cvPow(image_Im, image_Im, 2.0);
|
||||
cvAdd(image_Re, image_Im, image_Re, NULL);
|
||||
cvPow(image_Re, image_Re, 0.5);
|
||||
|
||||
// Compute log(1 + Mag)
|
||||
cvAddS( image_Re, cvScalarAll(1.0), image_Re, NULL ); // 1 + Mag
|
||||
cvLog( image_Re, image_Re ); // log(1 + Mag)
|
||||
cvAddS(image_Re, cvScalarAll(1.0), image_Re, NULL); // 1 + Mag
|
||||
cvLog(image_Re, image_Re); // log(1 + Mag)
|
||||
|
||||
// Rearrange the quadrants of Fourier image so that the origin is at
|
||||
// the image center
|
||||
cvShiftDFT( image_Re, image_Re );
|
||||
cvShiftDFT(image_Re, image_Re);
|
||||
|
||||
cvReleaseImage(&realInput);
|
||||
cvReleaseImage(&imaginaryInput);
|
||||
|
@ -504,7 +509,6 @@ create_fourier_image(const IplImage *im)
|
|||
cvReleaseMat(&dft_A);
|
||||
|
||||
return image_Re;
|
||||
|
||||
}
|
||||
|
||||
IplImage*
|
||||
|
@ -520,18 +524,18 @@ create_frequency_filtered_image(const IplImage *pImage, int low, int high)
|
|||
box.size.width = high;
|
||||
box.size.height = high;
|
||||
|
||||
IplImage *pFilterMask = rb_cvCreateImage( cvGetSize(pImage), IPL_DEPTH_64F, 1 );
|
||||
IplImage *pFiltered = rb_cvCreateImage( cvGetSize(pImage), IPL_DEPTH_64F, 1 );
|
||||
IplImage *pFilterMask = rb_cvCreateImage(cvGetSize(pImage), IPL_DEPTH_64F, 1);
|
||||
IplImage *pFiltered = rb_cvCreateImage(cvGetSize(pImage), IPL_DEPTH_64F, 1);
|
||||
|
||||
cvZero(pFilterMask);
|
||||
cvZero(pFiltered);
|
||||
|
||||
if(high > 0)
|
||||
if (high > 0)
|
||||
cvEllipseBox(pFilterMask, box, cvScalar(255, 255, 255, 255), CV_FILLED, 8, 0);
|
||||
|
||||
box.size.width = low;
|
||||
box.size.height = low;
|
||||
if(low > 0)
|
||||
if (low > 0)
|
||||
cvEllipseBox(pFilterMask, box, cvScalar(0, 0, 0, 0), CV_FILLED, 8, 0);
|
||||
|
||||
cvAnd(pImage, pFilterMask, pFiltered, NULL);
|
||||
|
@ -544,17 +548,15 @@ create_frequency_filtered_image(const IplImage *pImage, int low, int high)
|
|||
void
|
||||
high_pass_range(const IplImage *pImage, float lostPercentage, int &outLow, int &outHigh)
|
||||
{
|
||||
if(lostPercentage > 1.0f)
|
||||
{
|
||||
if (lostPercentage > 1.0f) {
|
||||
lostPercentage = 1;
|
||||
}
|
||||
else if(lostPercentage < 0.0f )
|
||||
{
|
||||
else if (lostPercentage < 0.0f) {
|
||||
lostPercentage = 0;
|
||||
}
|
||||
|
||||
outHigh = (int) MIN( pImage->width, pImage->height );
|
||||
outLow = (int) (lostPercentage * outHigh);
|
||||
outHigh = (int)MIN(pImage->width, pImage->height);
|
||||
outLow = (int)(lostPercentage * outHigh);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
Copyright (C) 2005-2006 Masakazu Yonekura
|
||||
|
||||
************************************************************/
|
||||
#define __NAMESPACE_BEGIN_MOUSEEVENT namespace cMouseEvent{
|
||||
#define __NAMESPACE_BEGIN_MOUSEEVENT namespace cMouseEvent {
|
||||
#define __NAMESPACE_END_MOUSEEVENT }
|
||||
|
||||
#ifndef RUBY_OPENCV_GUI_MOUSEEVENT_H
|
||||
#define RUBY_OPENCV_GUI_MOUSEEVENT_H
|
||||
|
||||
#include"opencv.h"
|
||||
#include "opencv.h"
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_GUI
|
||||
|
|
|
@ -26,7 +26,7 @@ rb_module()
|
|||
void
|
||||
define_ruby_module()
|
||||
{
|
||||
if(module)
|
||||
if (module)
|
||||
return;
|
||||
/*
|
||||
* opencv = rb_define_module("OpenCV");
|
||||
|
@ -50,10 +50,10 @@ VALUE
|
|||
rb_extend_object(VALUE self, VALUE object)
|
||||
{
|
||||
CvSeq *seq = 0;
|
||||
if(!rb_obj_is_kind_of(object, cCvSeq::rb_class()))
|
||||
if (!rb_obj_is_kind_of(object, cCvSeq::rb_class()))
|
||||
rb_raise(rb_eTypeError, "object is not %s.\n", rb_class2name(cCvSeq::rb_class()));
|
||||
|
||||
if(!CV_IS_SEQ(seq))
|
||||
if (!CV_IS_SEQ(seq))
|
||||
rb_raise(rb_eTypeError, "object is not sequence.");
|
||||
return rb_call_super(1, &object);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#define __NAMESPACE_BEGIN_POINT_SET namespace mPointSet {
|
||||
#define __NAMESPACE_END_POINT_SET }
|
||||
|
||||
#include"opencv.h"
|
||||
#include "opencv.h"
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
__NAMESPACE_BEGIN_POINT_SET
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
#ifndef RUBY_OPENCV_GUI_TRACKBAR_H
|
||||
#define RUBY_OPENCV_GUI_TRACKBAR_H
|
||||
|
||||
#include"opencv.h"
|
||||
#include "opencv.h"
|
||||
|
||||
#define __NAMESPACE_BEGIN_TRACKBAR namespace cTrackbar{
|
||||
#define __NAMESPACE_BEGIN_TRACKBAR namespace cTrackbar {
|
||||
#define __NAMESPACE_END_TRACKBAR }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
|
@ -47,7 +47,8 @@ VALUE rb_set_value(VALUE self, VALUE val);
|
|||
__NAMESPACE_END_TRACKBAR
|
||||
|
||||
|
||||
inline Trackbar *TRACKBAR(VALUE object) {
|
||||
inline Trackbar*
|
||||
TRACKBAR(VALUE object) {
|
||||
Trackbar *ptr;
|
||||
Data_Get_Struct(object, Trackbar, ptr);
|
||||
return ptr;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#define RUBY_OPENCV_GUI_WINDOW_H
|
||||
|
||||
#include "opencv.h"
|
||||
#define __NAMESPACE_BEGIN_WINDOW namespace cWindow{
|
||||
#define __NAMESPACE_BEGIN_WINDOW namespace cWindow {
|
||||
#define __NAMESPACE_END_WINDOW }
|
||||
|
||||
__NAMESPACE_BEGIN_OPENCV
|
||||
|
|
Loading…
Reference in a new issue