本帖最后由 荒草 于 2014-5-23 18:30 编辑
楼主最近在看《Stixels estimation without depth map computation》这篇论文。对于其中2.2节的Ground plane estimation一直没看懂,有哪位大神能帮忙看看么?顺便解释一下。我的理解是: 假如图片的大小为m×n, 视差范围为d: 0~15. 那么Cost Volume应该是m×n×16的三维矩阵。论文里讲到通过计算v-disparity来estimate ground plane。按照我对之前对v-disparity的理解的话,对于视差范围为0~15,就应该会求出16个v-disparity啊?这怎么来估计ground plane啊?与我之前实现的根据视差图来求v-disparity,进而估计ground plane不同啊。一直比较困惑。顺便共享一个由视差图来计算V-disparity图,进而计算ground plane的程序吧。主程序:其中d为已经计算好的视差图。- maxdisp = double(max(max(d)));
- thr = 5;
- [vdisp, udisp] = u_v_disparity(d, thr);
- threshold = 1;
- [floorline, startPoint, endPoint, lines] = detectLine(vdisp, threshold);
- for j = 1: size(floorline,2)
- for i = 1: size(d, 2)
- if abs(d(floorline(2,j),i) - floorline(1,j)) < 3
- d(floorline(2,j),i) = 0;
- end
- end
- end
- figure,imshow(cat(3,d,d,d)*5);
- %%
- max_val = max(max(d));
- sum_total = zeros(max_val, 1);
- for i = 1: size(d,1)
- for j = 1: size(d,2)
- if d(i,j) ~= 0
- sum_total(d(i,j)) = sum_total(d(i,j)) + 1;
- end
- end
- end
- %%
- range = find(sum_total > 500);
- %%
- result1 = img_left;
- result2 = img_left;
- result3 = img_left;
- % SE = strel('disk', 1);
- for i = 1: length(range)
- D = d;
- mark_idx = d == range(i);
- D(~mark_idx) = 0;
- % D = imopen(D, SE);
- CC = bwconncomp(D);
- STATS = regionprops(CC, 'BoundingBox', 'Area', 'PixelIdxList');
- for j = 1: length(STATS)
- if STATS(j).BoundingBox(4) > 9 && STATS(j).Area > 100
- % rectangle('Position', STATS(j).BoundingBox,...
- % 'EdgeColor', 'r',...
- % 'LineWidth', 2);
- result1(STATS(j).PixelIdxList) = 255;
- result2(STATS(j).PixelIdxList) = 0;
- result3(STATS(j).PixelIdxList) = 0;
- end
- end
- end
- result = cat(3, result1, result2, result3);
- figure,imshow(result);
复制代码 求V-disparity的程序:- function [vdisp, udisp] = u_v_disparity(disp, threshold)
- maxdisp = max(max(disp));
- vdisp = zeros(size(disp,1), maxdisp+1);
- udisp = zeros(maxdisp+1, size(disp,2));
- for i = 1: size(disp,2)
- for j = 1: size(disp,1)
- if disp(j,i) > threshold
- vdisp(j,disp(j,i)) = vdisp(j,disp(j,i)) + 1;
- udisp(disp(j,i),i) = udisp(disp(j,i),i) + 1;
- end
- end
- end
- end
复制代码 检测直线的程序(这里偷了懒,直接用hough变换检测,用RANSAC检测,鲁棒性更好些):- function [floorline, startPoint, endPoint, lines] = detectLine(vdisp, threhold)
- vdisp(vdisp < threhold ) = 0;
- vdisp = uint8(vdisp);
- level = graythresh(vdisp);
- v_BW = im2bw(vdisp, level);
- [H,T,R] = hough(v_BW);
- P = houghpeaks(H, 1, 'threshold',ceil(0.1*max(H(:))));
- % Find lines
- lines = houghlines(v_BW, T, R, P, 'FillGap', 5500, 'MinLength', 30);
- startPoint = lines.point1;
- endPoint = lines.point2;
- line_param = cross([startPoint 1], [endPoint, 1]);
- line_param = line_param/line_param(2);
- % points = lineToBorderPoints(line_param, size(vdisp));
- % startPoint = [points(1) points(2)];
- % endPoint = [points(3) points(4)];
- length = endPoint(2) - startPoint(2);
- x = linspace(startPoint(1), endPoint(1), length);
- y = -line_param(3) - line_param(1)*x;
- floorline(1,:) = floor(x);
- floorline(2,:) = floor(y);
- % for k = 1:length(lines)
- % xy = [lines(k).point1; lines(k).point2];
- % plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
- %
- % % Plot beginnings and ends of lines
- % plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
- % plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
- % end
- end
复制代码 这是运行结果:
左右两幅图像:
视差图:
V-disparity以及直线检测,直线对应的就是路面
提取出的路面:
障碍物检测:
其中左右两幅图像以及视差图的计算来源于The KITTI Vision Benchmark Suite
|