aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcathook <b01902109@csie.ntu.edu.tw>2014-06-24 14:23:04 +0800
committercathook <b01902109@csie.ntu.edu.tw>2014-06-24 14:23:04 +0800
commit0667012e725099e13045ebf4f2f2bee5bd049edc (patch)
tree62dd8fb100d493323f24f6e54cf403f2c8ad18c4
parenta9955a1a51df2b268da4d28f9ad10dbaf9815634 (diff)
downloadmeow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar
meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.gz
meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.bz2
meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.lz
meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.xz
meow-0667012e725099e13045ebf4f2f2bee5bd049edc.tar.zst
meow-0667012e725099e13045ebf4f2f2bee5bd049edc.zip
add test code "feature"
-rw-r--r--meowpp.test/.gitignore1
-rw-r--r--meowpp.test/inc/autostitch.h3
-rw-r--r--meowpp.test/inc/features__.h25
-rw-r--r--meowpp.test/src/autostitch_RansacCheck.cpp2
-rw-r--r--meowpp.test/src/features.cpp204
-rw-r--r--meowpp.test/src/features_Harris.cpp85
-rw-r--r--meowpp.test/src/rot_bundle.cpp6
-rw-r--r--meowpp/Self.h3
-rw-r--r--meowpp/gra/BundleAdjustment_LM.h24
-rw-r--r--meowpp/gra/Camera.h17
-rw-r--r--meowpp/gra/Eye.h10
-rw-r--r--meowpp/gra/FeaturePoint.h14
-rw-r--r--meowpp/gra/FeaturePointsDetector_Harris.h11
-rw-r--r--meowpp/gra/IdentityPoints.h55
-rw-r--r--meowpp/gra/Photo.h4
-rw-r--r--meowpp/gra/ViewPort.h2
-rw-r--r--meowpp/gra/WatchBall.h30
-rw-r--r--meowpp/math/Vector.h4
18 files changed, 408 insertions, 92 deletions
diff --git a/meowpp.test/.gitignore b/meowpp.test/.gitignore
index 474b8fa..79ca24c 100644
--- a/meowpp.test/.gitignore
+++ b/meowpp.test/.gitignore
@@ -2,3 +2,4 @@ obj/*
bin/*
dep/*
test_data
+test_data/*
diff --git a/meowpp.test/inc/autostitch.h b/meowpp.test/inc/autostitch.h
index 68df9c9..11039bd 100644
--- a/meowpp.test/inc/autostitch.h
+++ b/meowpp.test/inc/autostitch.h
@@ -29,8 +29,7 @@ class MyFeaturePointsDetector: public meow::ObjBase {
public:
virtual meow::Usage usage() const = 0;
virtual bool usage(meow::Usage const& usg) = 0;
- virtual FeaturePoints detect(meow::Bitmap<meow::RGBf_Space> const& bmp)
- = 0;
+ virtual FeaturePoints detect(meow::Bitmap<meow::RGBf_Space> const& bmp) = 0;
};
class MyK_Match {
diff --git a/meowpp.test/inc/features__.h b/meowpp.test/inc/features__.h
new file mode 100644
index 0000000..85c136b
--- /dev/null
+++ b/meowpp.test/inc/features__.h
@@ -0,0 +1,25 @@
+#ifndef features_H__
+#define features_H__
+
+#include "meowpp/Usage.h"
+#include "meowpp/oo/ObjBase.h"
+#include "meowpp/gra/FeaturePoint.h"
+#include "meowpp/gra/Bitmap.h"
+#include "meowpp/colors/RGB_Space.h"
+
+#include <vector>
+
+typedef std::vector<meow::FeaturePoint<double, double> > FeaturePoints;
+
+class FeaturePointsDetectors: public meow::ObjBase {
+public:
+ virtual ~FeaturePointsDetectors() { }
+ virtual std::string description() const = 0;
+ virtual meow::Usage usage( ) const = 0;
+ virtual bool usage(meow::Usage const& usg) = 0;
+ virtual FeaturePoints detect(meow::Bitmap<meow::RGBf_Space> const& bmp) = 0;
+};
+
+static int const kFPSD_ID = 123;
+
+#endif // features_H__
diff --git a/meowpp.test/src/autostitch_RansacCheck.cpp b/meowpp.test/src/autostitch_RansacCheck.cpp
index e728958..1516d1a 100644
--- a/meowpp.test/src/autostitch_RansacCheck.cpp
+++ b/meowpp.test/src/autostitch_RansacCheck.cpp
@@ -77,7 +77,7 @@ Vector<double> MyRansacCheck::vCalc(std::vector<FeaturePointIndexPair> const& __
for (size_t j = i + 1; j < 8u; j++) {
sum += x(j) * m(i, j);
}
- x.entry(i, (m(i, 8) - sum) / m(i, i));
+ x.scalar(i, (m(i, 8) - sum) / m(i, i));
}
return x;
}
diff --git a/meowpp.test/src/features.cpp b/meowpp.test/src/features.cpp
index 382dffa..9547216 100644
--- a/meowpp.test/src/features.cpp
+++ b/meowpp.test/src/features.cpp
@@ -1,11 +1,33 @@
#include <cstdio>
+#include "features__.h"
+
#include "meowpp/Usage.h"
+#include "meowpp/colors/RGB_Space.h"
+#include "meowpp/geo/Vectors.h"
+#include "meowpp/gra/Bitmap.h"
+#include "meowpp/oo/ObjBase.h"
+#include "meowpp/oo/ObjSelector.h"
+
+#include <opencv/cv.h>
+#include <opencv/highgui.h>
+
+extern "C"{
+#include <sys/types.h>
+#include <dirent.h>
+}
+
+#include <vector>
+#include <algorithm>
+#include <string>
using namespace meow;
Usage usg("features");
+std::vector<std::string> names;
+std::vector<std::vector<FeaturePoint<double, double> > > fps;
+
int setup(int argc, char** argv) {
usg.optionAdd("h" , "Display this help document");
usg.optionAdd("help", "Display this help document");
@@ -17,12 +39,192 @@ int setup(int argc, char** argv) {
false);
usg.optionAdd("o",
"Output images with denoting feature points",
+ "filename",
+ "",
+ false);
+ usg.optionAdd("f",
+ "Output text file name",
+ "filename",
+ "<<input image name>>.txt",
+ false);
+ usg.optionAdd("d",
+ "Specify which feature detect algorithm to use",
+ "name",
+ "",
+ true);
+ std::vector<std::string> algo_list(ObjSelector<kFPSD_ID>::names());
+ for (size_t i = 0, I = algo_list.size(); i < I; ++i) {
+ FeaturePointsDetectors const* f;
+ f = (FeaturePointsDetectors const*)ObjSelector<kFPSD_ID>::get(algo_list[i]);
+ usg.optionValueAcceptAdd("d", algo_list[i], f->description());
+ usg.import(f->usage());
+ }
+ std::string err;
+ bool ret = usg.arguments(argc, argv, &err);
+ if (usg.hasOptionSetup("h") || usg.hasOptionSetup("help")) {
+ fprintf(stderr, "%s\n", usg.usage().c_str());
+ return 0;
+ }
+ if (ret == false) {
+ fprintf(stderr, "%s\n", err.c_str());
+ return -1;
+ }
+ return 1;
+}
+
+int getName() {
+ if (usg.hasOptionSetup("i") == false) {
+ names = usg.procArgs();
+ }
+ else {
+ std::string base = usg.optionValue("i", 0);
+ if (base.length() == 0 || base[base.length() - 1] != '/') {
+ base += "/";
+ }
+ DIR* dir = opendir(base.c_str());
+ if (!dir) {
+ fprintf(stderr, "can't open dir '%s'\n", base.c_str());
+ return -1;
+ }
+ for (dirent* ent; (ent = readdir(dir)) != NULL; ) {
+ if (!cstringEndWith(ent->d_name, 4, ".jpeg", ".jpg", ".JPG", ".JPEG")) {
+ continue;
+ }
+ names.push_back(base + std::string(ent->d_name));
+ }
+ }
+ return 1;
+}
+
+Bitmap<RGBf_Space> readOne(std::string name) {
+ Bitmap<RGBf_Space> ret;
+ messagePrintf(1, "Loading image...");
+ cv::Mat img = cv::imread(name, CV_LOAD_IMAGE_COLOR);
+ if (img.data) {
+ size_t height = img.size().height;
+ size_t width = img.size().width ;
+ ret.size(height, width, RGBf_Space(0));
+ for (size_t y = 0; y < height; ++y) {
+ for (size_t x = 0; x < width; ++x) {
+ Vector3D<int> v;
+ for (size_t i = 0; i < 3; ++i)
+ v.scalar(i, img.at<cv::Vec3b>(y, x)[2 - i]);
+ RGBf_Space p;
+ colorTransformate(RGBi_Space(v), &p);
+ ret.pixel(y, x, p);
+ }
+ }
+ }
+ messagePrintf(-1, (ret.size() > 0 ? "ok" : "fail"));
+ return ret;
+}
+
+int features() {
+ std::string n(usg.optionValue("d", 0));
+ FeaturePointsDetectors* fpd((FeaturePointsDetectors*)
+ ObjSelector<kFPSD_ID>::create(n));
+ if (fpd->usage(usg) == false) {
+ fprintf(stderr, "\nArgument setup error for '%s'\n", n.c_str());
+ return -1;
+ }
+ for (size_t i = 0, I = names.size(); i < I; ++i) {
+ messagePrintf(1, "Finding feature points of '%s'", names[i].c_str());
+ Bitmap<RGBf_Space> bmp(readOne(names[i]));
+ if (bmp.size() == 0) {
+ messagePrintf(-1, "fail");
+ continue;
+ }
+ messagePrintf(0, "Height x Width = %lux%lu", bmp.height(), bmp.width());
+ fps.push_back(fpd->detect(bmp));
+ messagePrintf(-1, "ok");
+ }
+ delete fpd;
+ return 1;
+}
+
+int writeOne(FILE* f, size_t i) {
+ if (fprintf(f, "%d\n", (int)fps[i].size()) < 1) return -1;
+ for (size_t j = 0, J = fps[i].size(); j < J; ++j) {
+ if (fps[i][j].write(f, false, 0) == false) return -1;
+ }
+ return 1;
+}
+
+int writeText() {
+ for (size_t i = 0, I = fps.size(); i < I; ++i) {
+ std::string name2;
+ if (usg.hasOptionSetup("f")) { name2 = usg.optionValue("f", i); }
+ else { name2 = names[i] + ".txt"; }
+ messagePrintf(1, "Write text file to '%s'", name2.c_str());
+ FILE* f = fopen(name2.c_str(), "w");
+ if (f == NULL) {
+ messagePrintf(-1, "fail to open file!, ignore");
+ continue;
+ }
+ if (writeOne(f, i) < 0) {
+ messagePrintf(-1, "write fail");
+ fclose(f);
+ continue;
+ }
+ fclose(f);
+ messagePrintf(-1, "ok");
+ }
+ return 1;
+}
+
+int writeBmpOne(std::string name, Bitmap<RGBf_Space> const& bmp) {
+ size_t height = bmp.height();
+ size_t width = bmp.width ();
+ cv::Mat img(height, width, CV_8UC3);
+ for (size_t y = 0; y < height; y++) {
+ for (size_t x = 0; x < width; x++) {
+ RGBi_Space tmp;
+ colorTransformate(bmp.pixel(y, x), &tmp);
+ for (size_t i = 0; i < 3; ++i)
+ img.at<cv::Vec3b>(y, x)[i] = tmp.rgb(2 - i);
+ }
+ }
+ if (imwrite(name, img) == false) {
+ return -1;
+ }
+ return 1;
+}
+
+int writeBmp() {
+ if (usg.hasOptionSetup("o") == false)
+ return 1;
+ for (size_t i = 0, I = names.size(); i < I; ++i) {
+ std::string name2;
+ name2 = stringPrintf("%s%lu.jpg", usg.optionValue("o", 0).c_str(), i);
+ messagePrintf(1, "Write img file to '%s'", name2.c_str());
+ Bitmap<RGBf_Space> bmp(readOne(names[i]));
+ bool succ;
+ if ((succ = (bmp.size() > 0))) {
+ int wh = std::min(bmp.height(), bmp.width()) / 16;
+ for (size_t j = 0, J = fps[i].size(); j < J; ++j) {
+ int x0 = fps[i][j].position()(0);
+ int y0 = fps[i][j].position()(1);
+ for (int dx = -wh; dx <= wh; ++dx)
+ if (0 <= x0 + dx && x0 + dx < (int)bmp.width())
+ bmp.pixel(y0, x0 + dx, RGBf_Space(Vector3D<double>(1.0, 0.0, 0.0)));
+ for (int dy = -wh; dy <= wh; ++dy)
+ if (0 <= y0 + dy && y0 + dy < (int)bmp.height())
+ bmp.pixel(y0 + dy, x0, RGBf_Space(Vector3D<double>(1.0, 0.0, 0.0)));
+ }
+ succ = (writeBmpOne(name2, bmp) > 0);
+ }
+ messagePrintf(0, "ok");
+ }
return 1;
}
int main(int argc, char** argv) {
int ret;
- if ((ret = setup(argc, argv)) <= 0) return -1;
+ if ((ret = setup(argc, argv)) <= 0) return ret;
+ if ((ret = getName()) <= 0) return ret;
+ if ((ret = features()) <= 0) return ret;
+ if ((ret = writeText()) <= 0) return ret;
+ if ((ret = writeBmp()) <= 0) return ret;
return 0;
}
diff --git a/meowpp.test/src/features_Harris.cpp b/meowpp.test/src/features_Harris.cpp
new file mode 100644
index 0000000..f3c2c10
--- /dev/null
+++ b/meowpp.test/src/features_Harris.cpp
@@ -0,0 +1,85 @@
+#include "features__.h"
+
+#include "meowpp/oo/ObjBase.h"
+#include "meowpp/oo/ObjSelector.h"
+#include "meowpp/geo/Vectors.h"
+#include "meowpp/gra/FeaturePointsDetector_Harris.h"
+
+using namespace meow;
+
+class Harris: public FeaturePointsDetectors {
+ private:
+ FeaturePointsDetector_Harris<RGBf_Space> detector_;
+ public:
+ std::string description() const {
+ return "Harris-Corner-Detect";
+ }
+
+ Usage usage() const {
+ Usage ret;
+ ret.optionAdd("harris-k",
+ "Specify the constant K of 'R = detM - KtraceM'",
+ "<floating point>",
+ stringPrintf("%.10f", detector_.paramK()),
+ false);
+ ret.optionAdd("harris-r",
+ "Specify the threshold of R to determind whether is "
+ "featuer point or not",
+ "<floating point>",
+ stringPrintf("%.10f", detector_.paramR()),
+ false);
+ ret.optionAdd("harris-w",
+ "Specify the sigma of the gaussian blur",
+ "<floating point>",
+ stringPrintf("%.10f", detector_.paramW()),
+ false);
+ ret.optionAdd("harris-n",
+ "Specify the sigma of the gaussian blur to de-noise",
+ "<floating point>",
+ stringPrintf("%.10f", detector_.paramN()),
+ false);
+ ret.optionAdd("harris-g",
+ "Specify sigma of the gaussian blur to generate feature",
+ "<floating point>",
+ stringPrintf("%.10f", detector_.paramG()),
+ false);
+ ret.optionAdd("harris-l",
+ ".........",
+ "<floating point>",
+ stringPrintf("%.10f", detector_.paramL()),
+ false);
+ ret.optionAdd("harris-b",
+ "Description size",
+ "<number>",
+ stringPrintf("%lu", detector_.paramB()),
+ false);
+ return ret;
+ }
+
+ bool usage(meow::Usage const& usg) {
+ double K = atof(usg.optionValue("harris-k", 0).c_str());
+ double R = atof(usg.optionValue("harris-r", 0).c_str());
+ double W = atof(usg.optionValue("harris-w", 0).c_str());
+ double N = atof(usg.optionValue("harris-n", 0).c_str());
+ double L = atof(usg.optionValue("harris-l", 0).c_str());
+ double G = atof(usg.optionValue("harris-g", 0).c_str());
+ size_t B = atoi(usg.optionValue("harris-b", 0).c_str());
+ detector_.paramK(K);
+ detector_.paramR(R);
+ detector_.paramW(W);
+ detector_.paramN(N);
+ detector_.paramL(L);
+ detector_.paramG(G);
+ detector_.paramB(B);
+ return true;
+ }
+
+ FeaturePoints detect(Bitmap<RGBf_Space> const& bmp) {
+ return detector_.detect(bmp);
+ }
+
+ std::string type() const { return std::string("Harris"); }
+ ObjBase* create() const { return new Harris(); }
+};
+
+static meow::ObjSelector<kFPSD_ID> __(new Harris(), true);
diff --git a/meowpp.test/src/rot_bundle.cpp b/meowpp.test/src/rot_bundle.cpp
index d626e8e..38ffce8 100644
--- a/meowpp.test/src/rot_bundle.cpp
+++ b/meowpp.test/src/rot_bundle.cpp
@@ -122,8 +122,8 @@ bool read() {
fprintf(stderr, "format error!\n");
exit(-1);
}
- v.entry(0, x - center[i].x());
- v.entry(1, -(y - center[i].y()));
+ v.scalar(0, x - center[i].x());
+ v.scalar(1, -(y - center[i].y()));
fpsv[i].push_back(v);
fps_id[i].push_back(id_max++);
}
@@ -160,7 +160,7 @@ bool read() {
for (size_t j = 0, J = fps_id[i].size(); j < J; ++j) {
int id = st.root(fps_id[i][j]);
s += stringPrintf("%d ", id);
- eyes[i].cameraGet().fixedPoints2DGet().identityPointAdd(id, fpsv[i][j]);
+ eyes[i].cameraGet().fixedPoints2DGet().pointAdd(id, fpsv[i][j]);
}
messagePrintf(0, "%s", s.c_str());
}
diff --git a/meowpp/Self.h b/meowpp/Self.h
index 6518c79..94db352 100644
--- a/meowpp/Self.h
+++ b/meowpp/Self.h
@@ -2,6 +2,7 @@
#define Self_h__
#include <cstdlib>
+#include <algorithm>
namespace meow {
@@ -166,7 +167,7 @@ private:
--(pointer_->counter_);
Kernel* dupl = new Kernel(this, *pointer_->data_);
if (pointer_->master_ == this || pointer_->master_ == NULL) {
- std::swap(pointer_->pointer_, dupl->pointer_);
+ std::swap(pointer_->data_, dupl->data_);
pointer_->master_ = NULL;
}
pointer_ = dupl;
diff --git a/meowpp/gra/BundleAdjustment_LM.h b/meowpp/gra/BundleAdjustment_LM.h
index 15eaac5..a93a6ef 100644
--- a/meowpp/gra/BundleAdjustment_LM.h
+++ b/meowpp/gra/BundleAdjustment_LM.h
@@ -44,18 +44,18 @@ private:
if (flag == false) {
Vector<double> v(4, 0.0);
int i = (*pho_).size() - 1, n = 0;
- v.entry(n++, (*pho_)[i].focal());
- v.entry(n++, (*rot_)[i].theta(0));
- v.entry(n++, (*rot_)[i].theta(1));
- v.entry(n++, (*rot_)[i].theta(2));
+ v.scalar(n++, (*pho_)[i].focal());
+ v.scalar(n++, (*rot_)[i].theta(0));
+ v.scalar(n++, (*rot_)[i].theta(1));
+ v.scalar(n++, (*rot_)[i].theta(2));
return v;
}
Vector<double> v((*rot_).size() * 4, 0.0);
for (size_t n = 0, i = 0, I = (*rot_).size(); i < I; ++i) {
- v.entry(n++, (*pho_)[i].focal());
- v.entry(n++, (*rot_)[i].theta(0));
- v.entry(n++, (*rot_)[i].theta(1));
- v.entry(n++, (*rot_)[i].theta(2));
+ v.scalar(n++, (*pho_)[i].focal());
+ v.scalar(n++, (*rot_)[i].theta(0));
+ v.scalar(n++, (*rot_)[i].theta(1));
+ v.scalar(n++, (*rot_)[i].theta(2));
}
return v;
}
@@ -90,8 +90,8 @@ private:
)
)
);
- ret.entry(n * 2 , tr(0, 0));
- ret.entry(n * 2 + 1, tr(1, 0));
+ ret.scalar(n * 2 , tr(0, 0));
+ ret.scalar(n * 2 + 1, tr(1, 0));
}
//*
//for (size_t i = 0; i < ret.dimension(); i++) {
@@ -216,8 +216,8 @@ public:
std::vector<FPS_K> beg(N), end(N);
FPS_K it1, it2;
for (size_t i = 0; i < N; ++i) {
- beg[i] = (*seq)[i].eye->camera().fixedPoints2D().identityPoints().begin();
- end[i] = (*seq)[i].eye->camera().fixedPoints2D().identityPoints().end ();
+ beg[i] = (*seq)[i].eye->camera().fixedPoints2D().points().begin();
+ end[i] = (*seq)[i].eye->camera().fixedPoints2D().points().end ();
}
std::vector<std::vector<std::vector<MatchPair> > > all_pairs(N);
for (size_t i = 0; i < N; ++i) {
diff --git a/meowpp/gra/Camera.h b/meowpp/gra/Camera.h
index 174b196..8682ad1 100644
--- a/meowpp/gra/Camera.h
+++ b/meowpp/gra/Camera.h
@@ -32,9 +32,11 @@ private:
Myself() {
fixed2D_.dimension(2);
}
+
Myself(Myself const& v):
photo_(v.photo_), rot_(v.rot_), fixed2D_(v.fixed2D_) {
}
+
~Myself() {
}
};
@@ -78,7 +80,7 @@ public:
/*!
* @brief 取得 photo
*/
- Photo<Pixel> const& photo() const {
+ Photo<Pixel> photo() const {
return self->photo_;
}
@@ -92,7 +94,7 @@ public:
/*!
* @brief 設定 photo
*/
- Photo<Pixel> const& photo(Photo<Pixel> const& pho) {
+ Photo<Pixel> photo(Photo<Pixel> const& pho) {
self()->photo_.copyFrom(pho);
return photo();
}
@@ -100,7 +102,7 @@ public:
/*!
* @brief 取得rotation
*/
- Rotation3D<double> const& rotation() const {
+ Rotation3D<double> rotation() const {
return self->rot_;
}
@@ -114,7 +116,7 @@ public:
/*!
* @brief 設定rotation
*/
- Rotation3D<double> const& rotation(Rotation3D<double> const& rot) {
+ Rotation3D<double> rotation(Rotation3D<double> const& rot) {
self()->rot_.copyFrom(rot);
return rotation();
}
@@ -122,7 +124,7 @@ public:
/*!
* @brief 取得所有FixedPoint
*/
- FixedPoints2D const& fixedPoints2D() const {
+ FixedPoints2D fixedPoints2D() const {
return self->fixed2D_;
}
@@ -136,7 +138,7 @@ public:
/*!
* @brief 設定FixedPoint
*/
- FixedPoints2D const& fixedPoints2D(FixedPoints2D const& fps2d) const {
+ FixedPoints2D fixedPoints2D(FixedPoints2D const& fps2d) const {
if (fps2d.dimension() == 2) {
self()->fixed2D_.copyFrom(fps2d);
}
@@ -243,8 +245,7 @@ public:
* @return \c char \c const\c * 形式的typename
*/
char const* ctype() const{
- static char const* ptr = typeid(*this).name();
- return ptr;
+ return typeid(*this).name();
}
/*! @brief 回傳class的type
diff --git a/meowpp/gra/Eye.h b/meowpp/gra/Eye.h
index 0d62892..cff5ccd 100644
--- a/meowpp/gra/Eye.h
+++ b/meowpp/gra/Eye.h
@@ -57,7 +57,7 @@ public:
return *this;
}
- Camera<Pixel> const& camera() const {
+ Camera<Pixel> camera() const {
return self->cam_;
}
@@ -65,12 +65,12 @@ public:
return self()->cam_;
}
- Camera<Pixel> const& camera(Camera<Pixel> const& c) {
+ Camera<Pixel> camera(Camera<Pixel> const& c) {
self()->cam_.copyFrom(c);
return camera();
}
- Vector3D<double> const& offset() const {
+ Vector3D<double> offset() const {
return self->ofs_;
}
@@ -78,7 +78,7 @@ public:
return self()->ofs_;
}
- Vector3D<double> const& offset(Vector3D<double> const& ofs) {
+ Vector3D<double> offset(Vector3D<double> const& ofs) {
self()->ofs_ = ofs;
return offset();
}
@@ -149,7 +149,7 @@ public:
* @return this
*/
ObjBase* copyFrom(ObjBase const* b) {
- return &(copyFrom(*(Eye*)b));
+ return &(copyFrom(*(Eye const*)b));
}
/*! @brief 回傳class的type
diff --git a/meowpp/gra/FeaturePoint.h b/meowpp/gra/FeaturePoint.h
index c3ab8f3..b2cbd37 100644
--- a/meowpp/gra/FeaturePoint.h
+++ b/meowpp/gra/FeaturePoint.h
@@ -70,7 +70,7 @@ public:
/*!
* @brief 回傳position
*/
- Vector<Scalar> const& position() const {
+ Vector<Scalar> position() const {
return pos_;
}
@@ -84,7 +84,7 @@ public:
/*!
* @brief 回傳description
*/
- Vector<Description> const& description() const {
+ Vector<Description> description() const {
return des_;
}
@@ -98,7 +98,7 @@ public:
/*!
* @brief 修改position
*/
- Vector<Scalar> const& position(Vector<Scalar> const& p) const {
+ Vector<Scalar> position(Vector<Scalar> const& p) const {
pos_.copyFrom(p);
return position();
}
@@ -106,7 +106,7 @@ public:
/*!
* @brief 修改description
*/
- Vector<Description> const& description(Vector<Description> const& d) {
+ Vector<Description> description(Vector<Description> const& d) {
des_.copyFrom(d);
return description();
}
@@ -129,7 +129,7 @@ public:
* @brief 修改position的第i個scalar
*/
Scalar position(size_t i, Scalar const& s) {
- pos_.entry(i, s);
+ pos_.scalar(i, s);
return position(i);
}
@@ -137,7 +137,7 @@ public:
* @brief 修改description的第i個Description
*/
Description description(size_t i, Description const& d) {
- des_.entry(i, d);
+ des_.scalar(i, d);
return description(i);
}
@@ -217,7 +217,7 @@ public:
}
ObjBase* copyFrom(ObjBase const& b) {
- return &(copyFrom(*(FeaturePoint*)b));
+ return &(copyFrom(*(FeaturePoint const*)b));
}
char const* ctype() const {
diff --git a/meowpp/gra/FeaturePointsDetector_Harris.h b/meowpp/gra/FeaturePointsDetector_Harris.h
index e7c6b91..8f0f8fe 100644
--- a/meowpp/gra/FeaturePointsDetector_Harris.h
+++ b/meowpp/gra/FeaturePointsDetector_Harris.h
@@ -16,7 +16,7 @@
namespace meow {
/*!
- * @brief Harris corner detect
+ * @brief Harris-Corner-Detect algorithm for finding feature points.
*
* @author cat_leopard
*/
@@ -190,10 +190,12 @@ public:
Ixx.gaussianed(self->sizeW_, self->sizeW_);
Iyy.gaussianed(self->sizeW_, self->sizeW_);
Ixy.gaussianed(self->sizeW_, self->sizeW_);
+ input_gx.clear();
+ input_gy.clear();
// filter too flat or on edge
- Bitmap<double> R(input.height(), input.width(), 0.0);
- Bitmap<bool> good(input.height(), input.width(), false);
+ Bitmap<double> R(input.height(), input.width(), 0.0);
+ Bitmap<bool> good(input.height(), input.width(), false);
ssize_t b = self->boundB_;
for (ssize_t y = b, Y = -b + input.height(); y < Y; y++) {
for (ssize_t x = b, X = -b + input.width(); x < X; x++) {
@@ -204,6 +206,9 @@ public:
good.pixel(y, x, (r >= self->thresholdR_));
}
}
+ Ixx.clear();
+ Iyy.clear();
+ Ixy.clear();
// find union neighbor
DisjointSet dsj(input.size());
diff --git a/meowpp/gra/IdentityPoints.h b/meowpp/gra/IdentityPoints.h
index 1646bf7..edac56e 100644
--- a/meowpp/gra/IdentityPoints.h
+++ b/meowpp/gra/IdentityPoints.h
@@ -29,11 +29,12 @@ private:
IdentityPointsMap points_;
size_t dimension_;
- Myself() {
- dimension_ = 1;
+ Myself(): dimension_(1) {
}
+
Myself(Myself const& m): points_(m.points_), dimension_(m.dimension_) {
}
+
~Myself() {
}
};
@@ -134,77 +135,77 @@ public:
/*!
* @brief 取得所有identity points
*/
- IdentityPointsMap const& identityPoints() const {
- return self->points_;
+ IdentityPointsMap const& points() const {
+ return self()->points_;
}
/*!
* @brief 設定所有identity points
*/
- IdentityPointsMap const& identityPoints(IdentityPointsMap const& points) {
+ IdentityPointsMap const& points(IdentityPointsMap const& points) {
clear();
- return identityPointsAdd(points);
+ return pointsAdd(points);
}
/*!
* @brief 加入identity Points
*/
- IdentityPointsMap const& identityPointsAdd(IdentityPointsMap const& points) {
+ IdentityPointsMap const& pointsAdd(IdentityPointsMap const& points) {
for (IdentityPointsMapIterK it = points.begin(); it != points.end(); ++it) {
- identityPointAdd(it.first, it.second);
+ pointAdd(it.first, it.second);
}
- return identityPoints();
+ return points();
}
/*!
* @brief 移除identity Points
*/
- IdentityPointsMap const& identityPointsDel(std::set<ID> const& ids) {
+ IdentityPointsMap const& pointsDel(std::set<ID> const& ids) {
for (typename std::set<ID>::const_iterator
it = ids.begin(); it != ids.end(); ++it) {
- identityPointDel(*it);
+ pointDel(*it);
}
- return identityPoints();
+ return points();
}
/*!
* @brief 取得一個identity point
*/
- Vector<Scalar> identityPoint(ID const& id) const {
+ Vector<Scalar> point(ID const& id) const {
return (exist(id) ? self->points_.find(id)->second : Vector<Scalar>());
}
/*!
* @brief 修改一個identity point
*/
- Vector<Scalar> identityPoint(ID const& id, Vector<Scalar> const& b) {
+ Vector<Scalar> point(ID const& id, Vector<Scalar> const& b) {
if (b.dimension() == self->dimension_ && exist(id)) {
self()->points_[id].copyFrom(b);
}
- return identityPoint(id);
+ return point(id);
}
/*!
* @brief 新增一個identity point
*/
- Vector<Scalar> identityPointAdd(ID const& id, Vector<Scalar> const& b) {
+ Vector<Scalar> pointAdd(ID const& id, Vector<Scalar> const& b) {
if (b.dimension() == self->dimension_ && !exist(id)) {
self()->points_[id].copyFrom(b);
}
- return identityPoint(id);
+ return point(id);
}
/*!
* @brief 刪除一個identity point
*/
- void identityPointDel(ID const& id) {
+ void pointDel(ID const& id) {
self()->points_.erase(id);
}
/*!
* @brief 取得一個identity point, non-constant reference
*/
- Vector<Scalar>& identityPointGet(ID const& id) {
+ Vector<Scalar>& pointGet(ID const& id) {
return self()->points_[id];
}
@@ -225,8 +226,7 @@ public:
if (fwrite(&(dim = dimension()), sizeof(dim), 1, f) < 1) return false;
if (fwrite(&(ct = size()), sizeof(ct), 1, f) < 1) return false;
for (IdentityPointsMapIterK
- it = identityPoints().begin(), ed = identityPoints().end();
- it != ed; ++it) {
+ it = points().begin(), ed = points().end(); it != ed; ++it) {
double tmp;
if (fwrite(&(tmp = it->first), sizeof(tmp), 1, f) < 1) return false;
for (long i = 0; i < dim; ++i) {
@@ -238,8 +238,7 @@ public:
else {
if (fprintf(f, "%ld %lu\n", dimension(), size()) < 1) return false;
for (IdentityPointsMapIterK
- it = identityPoints().begin(), ed = identityPoints().end();
- it != ed; ++it) {
+ it = points().begin(), ed = points().end(); it != ed; ++it) {
if (fprintf(f, "%f ", (double)it->first) < 1) return false;
for (long i = 0, I = dimension(); i < I; ++i) {
if (fprintf(f, "%f ", (double)it->second(i)) < 1) return false;
@@ -266,9 +265,9 @@ public:
if (fread(&id, sizeof(id), 1, f) < 1) return false;
for (size_t j = 0, J = dim; j < J; ++j) {
if (fread(&tt, sizeof(tt), 1, f) < 1) return false;
- tmp.entry(j, tt);
+ tmp.scalar(j, tt);
}
- identityPointAdd((ID)id, tmp);
+ pointAdd((ID)id, tmp);
}
}
else {
@@ -280,9 +279,9 @@ public:
if (fscanf(f, "%lf", &id) < 1) return false;
for (int j = 0, J = dim; j < J; ++j) {
if (fscanf(f, "%lf", &tt) < 1) return false;
- tmp.entry(j, tt);
+ tmp.scalar(j, tt);
}
- identityPointAdd((ID)id, tmp);
+ pointAdd((ID)id, tmp);
}
}
return true;
@@ -326,6 +325,6 @@ public:
}
};
-}
+} // meow
#endif // gra_IdentityPoints_H__
diff --git a/meowpp/gra/Photo.h b/meowpp/gra/Photo.h
index 78063ec..1545608 100644
--- a/meowpp/gra/Photo.h
+++ b/meowpp/gra/Photo.h
@@ -178,7 +178,7 @@ public:
/*!
* @brief 回傳\c bitmap
*/
- Bitmap<Pixel> const& bitmap() const {
+ Bitmap<Pixel> bitmap() const {
return self->bmp_;
}
@@ -195,7 +195,7 @@ public:
* @param [in] bmp 新的 bitmap
* @return 新的 \c bitmap
*/
- Bitmap<Pixel> const& bitmap(Bitmap<Pixel> const& bmp) {
+ Bitmap<Pixel> bitmap(Bitmap<Pixel> const& bmp) {
self()->bmp_.copyFrom(bmp);
return bitmap();
}
diff --git a/meowpp/gra/ViewPort.h b/meowpp/gra/ViewPort.h
index 16d8ae1..81ad8f3 100644
--- a/meowpp/gra/ViewPort.h
+++ b/meowpp/gra/ViewPort.h
@@ -13,7 +13,7 @@ class ViewPort: public ObjBase {
};
-}
+} // meow
#endif // gra_ViewPort_H__
diff --git a/meowpp/gra/WatchBall.h b/meowpp/gra/WatchBall.h
index 8bccf7f..8bc99d0 100644
--- a/meowpp/gra/WatchBall.h
+++ b/meowpp/gra/WatchBall.h
@@ -29,12 +29,11 @@ private:
Myself() {
}
- ~Myself() {
+
+ Myself(Myself const& b): cameras_(b.cameras_), offset_(b.offset_) {
}
- Myself& copyFrom(Myself const& b) {
- cameras_ = b.cameras_;
- offset_ = b. offset_;
- return *this;
+
+ ~Myself() {
}
};
@@ -84,7 +83,7 @@ public:
/*!
* @brief 取得 cameras
*/
- Cameras const& cameras() const {
+ Cameras cameras() const {
return self->cameras_;
}
@@ -98,7 +97,7 @@ public:
/*!
* @brief 設定 camera
*/
- Cameras const& cameras(Cameras const& c) {
+ Cameras cameras(Cameras const& c) {
self()->cameras_ = c;
return cameras();
}
@@ -106,21 +105,21 @@ public:
/*!
* @brief 取得第i個camera
*/
- Camera<Pixel> const& camera(size_t i) const {
+ Camera<Pixel> camera(size_t i) const {
return cameras()[i];
}
/*!
* @brief 取得第i個camera (non-constant reference)
*/
- Camera<Pixel>& camera(size_t i) {
+ Camera<Pixel>& cameraGet(size_t i) {
return cameras()[i];
}
/*!
* @brief 設定第i個camera
*/
- Camera<Pixel> const& camera(size_t i, Camera<Pixel> const& c) {
+ Camera<Pixel> camera(size_t i, Camera<Pixel> const& c) {
cameras()[i] = c;
return camera(i);
}
@@ -128,21 +127,21 @@ public:
/*!
* @brief 取得offset
*/
- Vector3D<double> const& offset() const {
+ Vector3D<double> offset() const {
return self->offset_;
}
/*!
* @brief 取得offset (non-constant reference)
*/
- Vector3D<double>& offset() {
+ Vector3D<double>& offsetGet() {
return self()->offset_;
}
/*!
* @brief 設定offset
*/
- Vector3D<double> const& offset(Vector3D<double> const& ofs) {
+ Vector3D<double> offset(Vector3D<double> const& ofs) {
self()->offset_ = ofs;
return offset();
}
@@ -228,7 +227,7 @@ public:
* @return this
*/
ObjBase* copyFrom(ObjBase const* b) {
- return &(copyFrom(*(WatchBall*)b));
+ return &(copyFrom(*(WatchBall const*)b));
}
/*! @brief 回傳class的type
@@ -236,8 +235,7 @@ public:
* @return \c char \c const\c * 形式的typename
*/
char const* ctype() const{
- static char const* ptr = typeid(*this).name();
- return ptr;
+ return typeid(*this).name();
}
/*! @brief 回傳class的type
diff --git a/meowpp/math/Vector.h b/meowpp/math/Vector.h
index 4dd95a5..f72b043 100644
--- a/meowpp/math/Vector.h
+++ b/meowpp/math/Vector.h
@@ -134,7 +134,7 @@ public:
*/
Scalar scalar(size_t i, Scalar const& s) {
matrix_.entry(i, 0, s);
- return entry(i);
+ return scalar(i);
}
//! @brief return \a i -th scalar with non-constant type
@@ -223,7 +223,7 @@ public:
//! @brief same as entry(i)
Scalar operator()(size_t i) const {
- return entry(i);
+ return scalar(i);
}
//! @brief same as positive()