Right Level
This commit is contained in:
parent
1393dfa99d
commit
ae77800ba8
81
src/Test.cpp
81
src/Test.cpp
@ -21,8 +21,8 @@ typedef struct {
|
||||
} StereoData;
|
||||
|
||||
#define WINDOW_START 0
|
||||
#define WINDOW_SIZE 220
|
||||
#define MATCH_SIZE 4
|
||||
#define WINDOW_SIZE 78
|
||||
#define MATCH_SIZE 3
|
||||
#define ERROR_LEVEL 1
|
||||
|
||||
int getPixelValue(Mat* data, int x, int y)
|
||||
@ -75,81 +75,52 @@ int getPixelColor(int cursor)
|
||||
return (val * val * val) * 255.0;
|
||||
}
|
||||
|
||||
void putPixel(StereoData ¶ms, int x, int y, int cursor)
|
||||
void putPixel(Mat* mat, int x, int y, int cursor)
|
||||
{
|
||||
uchar* data;
|
||||
|
||||
|
||||
data = params.stereo->ptr(y, x);
|
||||
data = mat->ptr(y, x);
|
||||
data[0] = getPixelColor(cursor);
|
||||
}
|
||||
|
||||
|
||||
void calcDepthMapMy2(StereoData ¶ms) {
|
||||
int x, y, cursor, cursor2, matched, closest;
|
||||
int minErrorValue, tmp, d;
|
||||
int x, y, cursor, cursor2, closest;
|
||||
int minErrorValue, tmp, minLevel = 0, tmpSmoothed;
|
||||
int rightLevel = 0, matched;
|
||||
|
||||
for (y = 0; y < params.stereo->rows; y++) {
|
||||
cursor = 0; cursor2 = 0;
|
||||
cursor = 0; cursor2 = 0;rightLevel=0;
|
||||
for (x = 0; x < params.stereo->cols; x++) {
|
||||
closest = 999; minErrorValue = 999;matched=0;
|
||||
for (int i = 0; i < WINDOW_SIZE; i++) {
|
||||
tmp = match(params, x, y, i);
|
||||
tmpSmoothed = tmp;
|
||||
|
||||
closest = 999;minErrorValue = 999; d = 999;
|
||||
|
||||
for (int i = WINDOW_START; i < WINDOW_SIZE; i++) {
|
||||
tmp = match(params, x, y, i) / 1;
|
||||
if (tmp < minErrorValue) {
|
||||
minErrorValue = tmp;
|
||||
closest = i;
|
||||
d = abs(cursor - i);
|
||||
}
|
||||
|
||||
if (tmp == minErrorValue) {
|
||||
matched = 1;
|
||||
} else if (tmp == minErrorValue) {
|
||||
if (abs(cursor - i) < abs(cursor - closest)) {
|
||||
closest = i ;
|
||||
d = abs(cursor - i);
|
||||
matched++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closest != 999) {
|
||||
//if (cursor != closest) {
|
||||
if (matched) {
|
||||
cursor = closest;
|
||||
putPixel(params, x + cursor + 1, y, cursor);
|
||||
//}
|
||||
putPixel(params.stereo, x, y, cursor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*closest = 999;minErrorValue = 999; d = 999;
|
||||
/*
|
||||
closest = 999;minErrorValue = 999;
|
||||
|
||||
for (int i = WINDOW_START; i < WINDOW_SIZE; i++) {
|
||||
tmp = rmatch(params, params.stereo->cols - x, y, i) / 50;
|
||||
if (tmp < minErrorValue) {
|
||||
minErrorValue = tmp;
|
||||
closest = i;
|
||||
}
|
||||
|
||||
if (tmp == minErrorValue) {
|
||||
if (abs(cursor2 - i) < abs(cursor2 - closest)) {
|
||||
closest = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (closest != 999) {
|
||||
//if (cursor2 != closest) {
|
||||
cursor2 = closest;
|
||||
putPixel(params, params.stereo->cols - x, y, cursor2);
|
||||
//}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*closest = 999;minErrorValue = 999;
|
||||
for (int i = WINDOW_START; i < WINDOW_SIZE; i++) {
|
||||
tmp = rmatch(params, params.stereo->cols - x - 1, y, i) / ERROR_LEVEL;
|
||||
tmp = rmatch(params, params.stereo->cols - x, y, i) ;
|
||||
if (tmp < minErrorValue) {
|
||||
minErrorValue = tmp;
|
||||
closest = i;
|
||||
@ -163,14 +134,11 @@ void calcDepthMapMy2(StereoData ¶ms) {
|
||||
}
|
||||
|
||||
if (closest != 999) {
|
||||
if (cursor2 != closest) {
|
||||
cursor2 = closest;
|
||||
}
|
||||
|
||||
tmp = getPixelValue(params.stereo, params.stereo->cols - x - 1, y);
|
||||
if (!tmp || tmp > cursor2) {
|
||||
putPixel(params, params.stereo->cols - x - 1, y, cursor2);
|
||||
putPixel(params.stereo, params.stereo->cols - x - cursor2, y, cursor2);
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,8 +146,8 @@ void calcDepthMapMy2(StereoData ¶ms) {
|
||||
int main(int argc, char** argv) {
|
||||
StereoData params;
|
||||
|
||||
Mat left = imread("left7.png", 1);
|
||||
Mat right = imread("right7.png", 1);
|
||||
Mat left = imread("left2.png", 1);
|
||||
Mat right = imread("right2.png", 1);
|
||||
|
||||
cvtColor(left, left, CV_BGR2GRAY);
|
||||
cvtColor(right, right, CV_BGR2GRAY);
|
||||
@ -196,6 +164,7 @@ int main(int argc, char** argv) {
|
||||
calcDepthMapMy2(params);
|
||||
|
||||
imshow("Display Image Dyn Progr", stereo);
|
||||
//imshow("Display Image Dyn Progr1", visited);
|
||||
waitKey();
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user