Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Calculate surface normals from depth image using neighboring pixels cross product

$
0
0
As the title says I want to calculate the surface normals of a given depth image by using the cross product of neighboring pixels. However, I do not really understand the procedure. Does anyone have any experience? Lets say that we have the following image: ![image description](/upfiles/14520928396087819.png) what are the steps to follow? --------------------------- **Update:** I am trying to translate the following pseudocode from [this answer](http://stackoverflow.com/a/34644939/1476932) to opencv. dzdx=(z(x+1,y)-z(x-1,y))/2.0; dzdy=(z(x,y+1)-z(x,y-1))/2.0; direction=(-dxdz,-dydz,1.0) magnitude=sqrt(direction.x**2 + direction.y**2 + direction.z**2) normal=direction/magnitude where z(x,y) is my depth image. However, the output of the following does not seem correct to me: for(int x = 0; x < depth.rows; ++x) { for(int y = 0; y < depth.cols; ++y) { double dzdx = (depth.at(y+1, x) - depth.at(y-1, x)) / 2.0; double dzdy = (depth.at(y, x+1) - depth.at(y, x-1)) / 2.0; Vec3d d = (dzdx, dzdy, 1.0); Vec3d n = normalize(d); } }

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>