1. for a cloud instance of the point cloud type, assign a value to the point I of the instance, and use cloud. point [I]. X and cloud. point [I]. Y and cloud. point [I]. Z assigns values to their XYZ coordinates respectively.
Cloud. Point [I]. x =
Cloud. Point [I]. Y =
Cloud. Point [I]. z =
2. opencv traverses the matrix m and uses the row pointer M. PTR <datatype> (ROW) to point to the row.
<Datatype> * Data = M. PTR <datatype> (ROW)
3. opencv takes the M element of the given index matrix, M. at <datatype> (I, j), indicating to take the elements of row I and column J.
A = M. at <datatype> (I, j)
The following is a routine:
1 // use depth data to reconstruct 3D point clouds 2 int ROW = 0, Col = 0, pointid = 0; 3 for (ROW = 0; row <depthheight; row ++) // ROW = y traverse all rows in the depth Matrix 4 {5 unsigned short * Data = depthdata. PTR <unsigned short> (ROW); 6 for (COL = 0; Col <depthwidth; Col ++) // Col = x traverse all columns of the Depth Matrix 7 {8 If (* Data> 500 & * Data <1500) // obtain the depth data in the range of m-m 9 {10 pointid ++; 11 // [x, y, z] '= depth [x, y] * inv_k * [x, y, 1] 12 cloud. points [pointid]. X = * Data * (COL * minvk. at <float> (0, 0) + 13 row * minvk. at <float> (0, 1) + minvk. at <float> (0, 2); // x14 15 cloud. points [pointid]. y = * Data * (COL * minvk. at <float> (1, 0) + 16 row * minvk. at <float> (1, 1) + minvk. at <float> (1, 2); // Y17 18 cloud. points [pointid]. z = * data; // z19} 20 else // data in other ranges has no operation 21 {22} 23 data ++; // depth Data Pointer, pointing to the next position, deep data 24} 25}
PCL point cloud data operations opencv traversal data