From e4350d0413dc26786072face6fd2e0a345eb6309 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Wed, 3 Feb 2016 01:40:08 +0100 Subject: stuff? dunno --- detect_road_borders.cpp | 5 +++-- joystick.cpp | 2 +- mariokart.cpp | 32 +++++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/detect_road_borders.cpp b/detect_road_borders.cpp index d3ab3f7..7e4868d 100644 --- a/detect_road_borders.cpp +++ b/detect_road_borders.cpp @@ -23,6 +23,7 @@ #include #include #include +#include using namespace std; using namespace cv; @@ -580,7 +581,7 @@ int find_steering_point(Mat orig_img, Point origin_point, int** contour_map, Mat vector > contours; vector hierarchy; - findContours(img, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_NONE, Point(0, 0)); + findContours(img, contours, hierarchy, RETR_TREE, CHAIN_APPROX_NONE, Point(0, 0)); int low_y, low_idx, high_y, first_nonbottom_idx; vector& contour = prepare_and_get_contour(img.cols, img.rows, contours, hierarchy, @@ -660,7 +661,7 @@ int main(int argc, char* argv[]) continue; } - cvtColor(frame, tmp, CV_RGB2GRAY); + cvtColor(frame, tmp, COLOR_RGB2GRAY); threshold(tmp, thres, 132, 255, THRESH_BINARY); dilate(thres,tmp,Mat()); erode(tmp,thres,Mat()); diff --git a/joystick.cpp b/joystick.cpp index 6729023..ad06bda 100644 --- a/joystick.cpp +++ b/joystick.cpp @@ -41,7 +41,7 @@ using namespace std; -#define THROTTLE_CNT_MAX 10 +#define THROTTLE_CNT_MAX 6 #ifdef JOYSTICK_PATCHEDINPUTPLUGIN static char* pack(const BUTTONS* buttons, char* buf) diff --git a/mariokart.cpp b/mariokart.cpp index 414a9cd..284f570 100644 --- a/mariokart.cpp +++ b/mariokart.cpp @@ -63,6 +63,8 @@ using namespace cv; #define HIST_SMOOTH 7 //#define NO_BRIGHTNESS // will man nicht, nur zu demonstrationszwecken +#define ADJUST_BRIGHTNESS +#define ADJUST_BRIGHTNESS_EXP 3 #define ERODE_RADIUS_2D 4 @@ -188,6 +190,13 @@ void* thread1_func(void*) } } +float mypow(float base, float exp) +{ + if (base >= 0) + return pow(base,exp); + else + return -pow(-base,exp); +} int main(int argc, char* argv[]) { @@ -262,6 +271,11 @@ joystick.reset(); XorgGrabber capture("Mupen64Plus OpenGL Video"); #endif + uchar mypow_lut[256]; + for (int i=0; i<256; i++) + mypow_lut[i] = mypow(((((float)i)-128.)/128.), ADJUST_BRIGHTNESS_EXP)*128.+128.; + + Mat transform; bool first=true; @@ -277,7 +291,7 @@ joystick.reset(); namedWindow("edit"); setMouseCallback("edit", mouse_callback, NULL); - joystick.throttle(0.5); + joystick.throttle(2./6); VideoWriter img_writer, thres_writer, thres2_writer; @@ -354,6 +368,22 @@ joystick.reset(); } #endif + #ifdef ADJUST_BRIGHTNESS + Mat hsv; + cvtColor(img, hsv, CV_BGR2HSV); + for (int y=0; y(y) + 2; + for (int x = 0; x< hsv.cols; x++) + { + *data= mypow_lut[*data]; + data+=3; + } + } + + cvtColor(hsv, img, CV_HSV2BGR); + #endif + road_thresholder->process_image(img); Mat img_thres = road_thresholder->get_road(); -- cgit v1.2.1