So I have the basic functionality working with the astra sdk, all samples work and I’ve run some tests with the depth stream which work perfectly.
I am now trying to create a ‘nearest point’ sample application.
Basically just print the x,y and z coordinates of the nearest point.
I can access the pointstream data and iterate over all 307.200 points included in the data.
I just can’ t seem to find a ‘nearest’ point. If I print the coordinate with the lowest Z value (which is not 0) It seems to be stable around a value of around 850 no matter how I move around.
Anyone have an idea how to create such a sample?
This is my code to print the nearest point once I have access to a pointFrame:
if (pointFrame.is_valid()) { int width = pointFrame.width(); int height = pointFrame.height(); int frameIndex = pointFrame.frame_index();
const astra::Vector3f* data = pointFrame.data();
int nearestPointZ = 9000;
const astra::Vector3f* nearestPoint = data;
for (int i = 0; i < pointFrame.length(); i++) { const astra::Vector3f* dataPoint = data + i;
if (dataPoint->z > 0 && dataPoint->z < nearestPointZ) { nearestPoint = dataPoint; } }
std::cout << "x: " << nearestPoint->x << ", y: " << nearestPoint->y << ", z: " << nearestPoint->z << std::endl; }