Items with no label
3335 Discussions

Problems getting depth distance in mm

idata
Employee
1,699 Views

Hi, i´m trying to get the depth distance of each pixel of a frame from a recorded video with a R200, but the result that i´m getting is allways 0.0000

Here is my code:

void readFrame(pxcCHAR *file, bool record) {

PXCSenseManager* sm = PXCSenseManager::CreateInstance();

// Set file playback name

sm->QueryCaptureManager()->SetFileName(file, false);

// Enable stream and Initialize

sm->EnableStream(PXCCapture::STREAM_TYPE_COLOR, 640, 480, 0);

sm->EnableStream(PXCCapture::STREAM_TYPE_DEPTH, 0, 0, 0);

sm->Init();

// Set realtime=false and pause=true

sm->QueryCaptureManager()->SetRealtime(false);

sm->QueryCaptureManager()->SetPause(true);

// Streaming loop

for (int i = 0; i < 4; i++) {//I just take 4 frames

// Set to work on every frame of data

sm->QueryCaptureManager()->SetFrameByIndex(i);

sm->FlushFrame();

// Ready for the frame to be ready

pxcStatus sts = sm->AcquireFrame(true);

if (sts < PXC_STATUS_NO_ERROR) break;

// Retrieve the sample and work on it. The image is in sample->color.

PXCCapture::Sample* sample = sm->QuerySample();

//------------------------------------------------------------------------------------

PXCImage::ImageData data;

PXCImage::PixelFormat format;

format= PXCImage::PIXEL_FORMAT_DEPTH_RAW;

float c=sample->depth->AcquireAccess(PXCImage::ACCESS_READ, format, &data);

int width = sample->depth->QueryInfo().width;

int height = sample->depth->QueryInfo().height;

if (!format)

format = sample->depth->QueryInfo().format;

printf("%d %d\n",width,height);

printf("%f\n", c);

//---------------------------------------------------------------------------------------------------------------------

for (int i = 0; i < 500000000; i++) {}

printf("Finish\n\n");

// Resume processing the next frame

sm->ReleaseFrame();

}

// Clean up

sm->Release();

}

I think that doing

float c=sample->depth->AcquireAccess(PXCImage::ACCESS_READ, format, &data);

it´s not the correct way to obtain the depth distance in mm of each pixel of the frame, but i don´t know how to obtain it and print it then.

Any ideas of how to accomplish it?

Thanks!!

0 Kudos
6 Replies
idata
Employee
451 Views

Hi Migueel,

Thanks for your interest in the Intel® Realsense™ Platform.

I'm sorry to hear that you can't get the depth distance from each pixel of the R200. I would encourage to follow this guide https://software.intel.com/en-us/articles/realsense-depth-data RealSense - Getting started with the Depth Data provided by Intel® RealSense™ Technology | Intel® Software , where it explains how to process the depth data provided by the R200.

Please let me know if this helps, we hope you have a nice weekend!

Best Regards,

 

-Jose P.
0 Kudos
idata
Employee
451 Views

Hi Jose,

i look the page that you have post me, but they barely talk of getting the depth distance of each pixel...

Do you know other post where more accurate information about getting depth distance from an image is given?

Thank you very much!

0 Kudos
idata
Employee
451 Views

Hi Migueel,

Have you looked into the SDK documentation https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?exportdata_pxcimage.html Intel® RealSense™ SDK 2016 R2 Documentation ? In there you will find interesting functions and sample codes that might be useful to you.

I did some digging and found this sample https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?sample_measurement_ep_cpp.html Intel® RealSense™ SDK 2016 R2 Documentation where they measure two points in an image, maybe you can use this sample as a reference.

Hope this helps, have a nice day!

Best Regards,

 

-Jose P.
0 Kudos
idata
Employee
451 Views

Yes Jose, i have look into the SDK documentation, but i didn´t found a function that could provide me the information i was looking for.

In the sample you post me the mesaured the distance between two points of an image, but i was looking for the distance from the camera and an point recorded.

Do you know any function that could accomplish that?

Thank you Jose,

Miguel.

0 Kudos
jb455
Valued Contributor II
451 Views

data.planes[0] contains a pointer to an array containing the depth values for each pixel. I'm not sure of the C++ syntax but in C# it goes like this:

unsafe

{

ushort* depthPtr = (ushort*)dData.planes[0].ToPointer();

for(int y = 0; y < depth.info.height; y++)

{

for(int x = 0; x

{

var depthValue = depthPtr[y + x * depth.info.width];

}

}

}

0 Kudos
idata
Employee
451 Views

Hi guys,

jb455 thanks for your input!

Migueel, I apologize, I thought you wanted to measure the distance between two pixels. Reading throughout this thread https://software.intel.com/en-us/forums/realsense/topic/606174 How to measure distance using F200 real sense camera , it seems that the QueryVertices() https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?queryvertices_pxcprojection.html Intel® RealSense™ SDK 2016 R2 Documentation calculates the vertices depth image and this vertices return the world coordinates in millimeters. Maybe you could use this function in your code in order to obtain the distance from the camera and a recorded point.

Hope this helps, have a nice day!

Best Regards,

 

-Jose P.
0 Kudos
Reply