summaryrefslogtreecommitdiff
path: root/naive_steerer.cpp
diff options
context:
space:
mode:
authorFlorian Jung <florian.a.jung@web.de>2012-12-03 23:24:27 +0100
committerFlorian Jung <florian.a.jung@web.de>2012-12-03 23:24:27 +0100
commit8775126ba9391d6e9eca61d5746dcf80cafa19f2 (patch)
tree33c4b3b1b1ec4173a0431af98dc57ba39903611d /naive_steerer.cpp
parent6175f64926b52b4d35379d4cc872b7c4cee7dd98 (diff)
lenk- und strassenerkennungskram in klassen ausgelagert. funzt.
Diffstat (limited to 'naive_steerer.cpp')
-rw-r--r--naive_steerer.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/naive_steerer.cpp b/naive_steerer.cpp
new file mode 100644
index 0000000..9844664
--- /dev/null
+++ b/naive_steerer.cpp
@@ -0,0 +1,53 @@
+#include "naive_steerer.h"
+#include "util.h"
+
+using namespace std;
+
+NaiveSteerer::NaiveSteerer(int chx, int chy)
+{
+ set_crosshair(chx,chy);
+}
+
+void NaiveSteerer::set_crosshair(int chx, int chy)
+{
+ crosshair_x=chx;
+ crosshair_y=chy;
+}
+
+void NaiveSteerer::process_image(const Mat& img)
+{
+ int left_sum=0, right_sum=0;
+ for (int row = 0; row<img.rows; row++)
+ {
+ const uchar* data=img.ptr<uchar>(row);
+
+ for (int col=0; col<img.cols;col++)
+ {
+ if (*data)
+ {
+ if (row<=crosshair_y)
+ {
+ if (col < crosshair_x)
+ left_sum++;
+ else
+ right_sum++;
+ }
+ }
+
+ data+=img.step[1];
+ }
+ }
+
+ steer = -4* flopow( (((float)left_sum / (left_sum+right_sum))-0.5 )*2.0 , 1.6);
+}
+
+double NaiveSteerer::get_steer_data()
+{
+ return steer;
+}
+
+double NaiveSteerer::get_confidence()
+{
+ //return confidence;
+ return 1.0; // TODO
+}