Skip to main content
letter
. 2020 Aug 9;20(16):4448. doi: 10.3390/s20164448
Algorithm 1 Object Measurement
 Zpicker: The lowest position of the picker from the lens in z-axis
 Dobj: The maximum depth of objects
 rows, cols: The rows and columns in the 2D pixel coordinate system
 d(rows,cols): The depth value at (rows,cols)
 Amin: The minimum area of object cross section
 C: The contour of the object
 w,h,d,ϕ: The width, height, depth and orientation of the object
 W,H: The width and height of the depth frame
 (px,py): The picked position in xy-axes on the object
 
 (1) Acquire sensor data.
 Capture a depth frame from D435
 if the depth frame is not successfully captured then
     return the error code of ’−1’
 end if
 Calculate point clouds from the depth frame
 
 (2) Extract object area.
 Separate the pixels where Zpicker−Dobj<d(r,c)<Zpicker
 Find the contours of the separated pixels whose area is larger than Amin
 if no contour is found then
     return the error code of ’−2’
 end if
 Select the largest contour as C
 if C is out of the depth frame bound then
     return the error code of ’−3’
 end if
 
 (3) Calculate d, w, h and ϕ.
 Accumulate the point clouds in C
 zavg = average of the z-axis values of the point clouds
 d = Zpicker−zavg
 Find a rotated rectangle of the minimum area enclosing C
 Calculate the scaling factor S from the point clouds
 w = width pixels of the rectangle ×S
 h = height pixels of the rectangle ×S
 ϕ = rotation of the rectangle
 
 (4) Calculate px and py.
 (cx,cy) = average of the four corner positions of the rectangle in pixels
 (dx,dy) = (cx − W/2, H/2 − cy)
 pxpy=−Scos(ϕ) −sin(ϕ)sin(ϕ)     cos(ϕ)dxdy
 
 (5) Return w, h, d, ϕ, px and py