重要的是我希望创建深度图 [英] important i hope for create depth map

查看:73
本文介绍了重要的是我希望创建深度图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有人问候后
要从立体镜图像生成深度图,有两个摄像头
左一右一
用于获得左右图像
之后,我想生成深度图
我将使用该项目来帮助盲人,因为获得深度后我会产生声音
希望有人帮助我

我使用了两种方法,但是两种方法都无法达到最佳效果
我的代码
我有两个灰度图像
这样,ibel使sobel边缘向右成像大于149的点
imake与左侧图像(点)最匹配
放入"newim"位图



//////////////////////////////
公共无效的matchpixel()
{
位图p1 =新位图(pictureBox3.Image);

//sumI = 0;

for(j = 0; j< 270; j ++)
{
cleardeep();
对于(i = 0; i< 270; i ++)
{

if(p1.GetPixel(i,j).R> = 149)
{

disparity(i,j);


}


其他
{



颜色newColor = Color.FromArgb(0,0,0);
newim.SetPixel(i,j,newColor);


}

}



}




pictureBox4.Image = newim;
}


私人空白视差(int i1,int j1)
{
int S = 0;
int PL = 0;
int X = 0;
int Xmatch = 0;
int deex = 0;



int endlimi = 0;

int limiti = 0;
int o = 0;
int disttvalue = 0;
if((i1> = 10)&&(i1< = 269))
{
limiti = Math.Abs​​(i1-10);
endlimi = i1;
}
否则(i1> 0)
{
limiti = 0;
endlimi = i1;
}
其他
{
limiti = 0;
endlimi = 1;
}
最小= 9000;
for(o = limiti; o< endlimi; o ++)
{
disttvalue = Math.Abs​​(i1-o);
PL = Math.Abs​​(image_s2.GetPixel(i1,j1).R-image_s1.GetPixel(o,j1).R);

如果((PL< min)&&(disttvalue< == 10))
{
最小值= PL;
Xmatch = o;
S = distt;
deex = i1;


}

PL = 0;
disttvalue = 0;
}
最小= 9000;
布尔C =假;
for(int h = 0; h< 270; h ++)
{

如果(deep [h] == Xmatch)
{
bool swith = check(h,i1,Xs,j1);

如果(swith == true)
{

disp2(h,j1,Xmatch);
deep [i1] = Xs;
setcolor(i1,j1,S);
C = true;

}

if(swith == false)
{
disp2(i1,j1,Xmatch);
C = true;
}

}


}
如果(C == false)
{
setcolor(i1,j1,S);
deep [i1] = Xs;
}



}
private void cleardeep()
{
for(int h = 0; h< 270; h ++)
{
deep [h] = 0;
}
}
私人布尔检查(int x1,int x2,int Xsimilirity,int Y)
{
int Score1 = image_s2.GetPixel(x1,Y).R-image_s1.GetPixel(Xsimilirity,Y).R;
int Score2 = image_s2.GetPixel(x2,Y).R-image_s1.GetPixel(Xsimilirity,Y).R;
如果(得分1>得分2)
{
返回true;
}
其他
{
返回false;
}
}
私有无效setcolor(int x,int y,int d)
{
//int d =(y * 12)/(de + 1);
如果((d> = 0)&&(d< = 1))
{
d = 30;

}
否则((d> 1)&&(d< = 2))
{
d = 70;

}
否则((d> 2)&&(d< = 3))
{
d = 80;

}
否则((d> 3)&&(d< = 4))
{
d = 100;

}
否则((d> 4)&&(d< = 5))
{
d = 110;

}
否则((d> 5)&&(d< = 6))
{
d = 120;
}
否则((d> 6)&&(d< = 7))
{
d = 130;
}
否则((d> 7)&&(d< = 8))
{
d = 140;
}
否则((d> 8)&&(d< = 9))
{
d = 255;
}
否则((d> 9)&&(d< = 10))
{
d = 149;
}


如果(d> 255)
{
d = 255;
}


如果(d< = 0)
{
d = 0;
}
颜色newColor = Color.FromArgb(d,d,d);
newim.SetPixel(x,y,newColor);

}
私有void disp2(int x,int y,int simi)
{
int limh = 0;
int endlimh = 0;
int o = 0;
int dist = 0;
int deex1 = 0;
int deepscore1 = 0;
int P = 0;
最小= 9000;
if((x> = 10)&&(x< = 269))
{
limh = Math.Abs​​(x-10);
endlimh = x;
}
否则((x> 0)&&(x< = 9))
{
limh = 0;
endlimh = x;
}
其他
{
limh = 0;
endlimh = 1;
}

for(o = limh; o< endlimh; o ++)
{

P = Math.Abs​​(image_s2.GetPixel(x,y).R-image_s1.GetPixel(o,y).R);

如果((P< min)&&(o!= simi))
{
如果(dist< = 10)
{
最小值= P;
dist = Math.Abs​​(x-o);
deepscore1 = o;
}
}

P = 0;

}
setcolor(x,y,dist);
deep [x] = deepscore1;
}

after greeting for all
iwant to generate depth map from stereoscope image ,ihave two camera
iput one left and one right
for get left&right image
after that iwant to generate the depth map
iwill using that project for helping blind men as after iget depth iwill generate sound
ihope any one help me

i used two way but the two way not arrived to best result
my code
ihae two grayscale images
this way iget sobel edge to right image the the point that bigger than 149
imake matching best with the left image(point)
put in "newim" bitmap



////////////////////////////////
public void matchpixel()
{
Bitmap p1 = new Bitmap(pictureBox3.Image);

// sumI = 0;

for (j = 0; j < 270; j++)
{
cleardeep();
for (i = 0; i < 270; i++)
{

if (p1.GetPixel(i, j).R >= 149)
{

disparity(i, j);


}


else
{



Color newColor = Color.FromArgb(0, 0, 0);
newim.SetPixel(i,j, newColor);


}

}



}




pictureBox4.Image = newim;
}


private void disparity(int i1, int j1)
{
int S = 0;
int PL = 0;
int X=0;
int Xmatch=0;
int deex=0;



int endlimi = 0;

int limiti = 0;
int o = 0;
int disttvalue = 0;
if ((i1 >= 10) && (i1 <= 269))
{
limiti =Math.Abs( i1 - 10);
endlimi = i1;
}
else if (i1 > 0)
{
limiti = 0;
endlimi = i1;
}
else
{
limiti = 0;
endlimi = 1;
}
min = 9000;
for (o = limiti; o < endlimi; o++)
{
disttvalue = Math.Abs(i1 - o);
PL = Math.Abs(image_s2.GetPixel(i1, j1).R - image_s1.GetPixel(o, j1).R);

if ((PL < min)&&(disttvalue<=10))
{
min = PL;
Xmatch=o;
S = distt;
deex = i1;


}

PL = 0;
disttvalue = 0;
}
min = 9000;
bool C = false;
for (int h = 0; h < 270; h++)
{

if (deep[h] == Xmatch)
{
bool swith=check(h, i1, Xs, j1);

if (swith==true)
{

disp2(h, j1, Xmatch);
deep[i1] = Xs;
setcolor(i1, j1, S);
C = true;

}

if(swith==false)
{
disp2(i1, j1, Xmatch);
C = true;
}

}


}
if (C == false)
{
setcolor(i1, j1, S);
deep[i1] = Xs;
}



}
private void cleardeep()
{
for (int h = 0; h < 270; h++)
{
deep[h] = 0;
}
}
private bool check(int x1, int x2,int Xsimilirity, int Y)
{
int Score1 = image_s2.GetPixel(x1, Y).R - image_s1.GetPixel(Xsimilirity, Y).R;
int Score2 = image_s2.GetPixel(x2, Y).R - image_s1.GetPixel(Xsimilirity, Y).R;
if (Score1 > Score2)
{
return true;
}
else
{
return false;
}
}
private void setcolor(int x, int y, int d)
{
// int d = (y * 12) / (de+1);
if ((d >= 0) && (d <= 1))
{
d = 30;

}
else if ((d > 1) && (d <= 2))
{
d = 70;

}
else if ((d > 2) && (d <= 3))
{
d = 80;

}
else if ((d > 3) && (d <= 4))
{
d = 100;

}
else if ((d > 4) && (d <= 5))
{
d = 110;

}
else if ((d> 5) && (d <= 6))
{
d = 120;
}
else if ((d > 6) && (d <= 7))
{
d = 130;
}
else if ((d > 7) && (d <= 8))
{
d = 140;
}
else if ((d > 8) && (d <= 9))
{
d =255;
}
else if ((d > 9) && (d <= 10))
{
d = 149;
}


if (d > 255)
{
d = 255;
}


if (d <= 0)
{
d = 0;
}
Color newColor = Color.FromArgb(d, d, d);
newim.SetPixel(x,y, newColor);

}
private void disp2(int x,int y,int simi)
{
int limh = 0;
int endlimh = 0;
int o = 0;
int dist = 0;
int deex1 = 0;
int deepscore1 = 0;
int P = 0;
min = 9000;
if ((x>= 10) && (x <= 269))
{
limh = Math.Abs(x - 10);
endlimh= x;
}
else if ((x > 0)&&(x<=9))
{
limh= 0;
endlimh = x;
}
else
{
limh = 0;
endlimh = 1;
}

for (o = limh; o < endlimh; o++)
{

P = Math.Abs(image_s2.GetPixel(x, y).R - image_s1.GetPixel(o, y).R);

if ((P < min) && (o != simi))
{
if (dist <= 10)
{
min = P;
dist = Math.Abs(x - o);
deepscore1 = o;
}
}

P = 0;

}
setcolor(x, y, dist);
deep[x] = deepscore1;
}

推荐答案

对于没有经验的软件开发人员(看起来很像)来说,这似乎是一项艰巨的任务.我想您必须在论坛上提问之前对此主题进行一些研究. Google可能很有用[
It looks like a daunting task for a inexperienced software developer (as you appear). I suppose you''ve to do some research on the subject, before asking on the forum. Google may be useful [^].
:)


这篇关于重要的是我希望创建深度图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆