Items with no label
3335 Discussions

why all the pos3d values are zero while posUVZ values are not zero and how to fix it?

MJala
Novice
1,783 Views

In the following snippet, when I print the posUVZ values, they are non-zero but after I pass them to ProjectDepthToCamera(wxhDepth, posUVZ, pos3D) all the pos3D values happen to be zero. Any though on why is this happening and how to fix it?

/*** 

Reads the depth data from the sensor and fills in the matrix

 

***/

 

void SR300Camera::fillInZCoords()

 

{

 

 

PXCImage::ImageData depthImage;

 

PXCImage *depthMap = sample->depth;

 

depthMap...
0 Kudos
1 Solution
idata
Employee
403 Views

Hi MonaJalal,

 

 

Have you checked the Projection Sample in the SDK? https://software.intel.com/sites/landingpage/realsense/camera-sdk/v2016r3/documentation/html/index.html?sample_projection_cpp.html. I was checking the source code and it uses the function ProjectDepthToCamera, so I recommend you to check that sample and use it as a reference for your code.

 

 

Have a nice day.

 

 

Regards,

 

Leonardo R.

View solution in original post

0 Kudos
7 Replies
idata
Employee
403 Views

Hi MonaJalal,

 

 

Thanks for reaching out.

 

 

I will investigate more about this, and I will let you know as soon as I have helpful information.

 

 

Have a nice day.

 

 

Regards,

 

Leonardo R.
0 Kudos
idata
Employee
404 Views

Hi MonaJalal,

 

 

Have you checked the Projection Sample in the SDK? https://software.intel.com/sites/landingpage/realsense/camera-sdk/v2016r3/documentation/html/index.html?sample_projection_cpp.html. I was checking the source code and it uses the function ProjectDepthToCamera, so I recommend you to check that sample and use it as a reference for your code.

 

 

Have a nice day.

 

 

Regards,

 

Leonardo R.
0 Kudos
MJala
Novice
403 Views

As you see above I have used the same function. Here's the same question I asked in Stackoverflow with better indentation http://stackoverflow.com/questions/43991565/all-the-pos3d-values-are-zero-while-posuvz-values-are-not-zero c++ - all the pos3d values are zero while posUVZ values are not zero - Stack Overflow

0 Kudos
idata
Employee
403 Views

Hi MonaJalal,

 

 

I have checked your code, but I didn't find any errors. Normally in these cases we bring the tools and samples to help the customer with their custom codes, that's the reason that I have provided you the sample code, to help you to check how the function is used and try to adapt it to your code to make sure that it will work.

 

 

Having said this, I want to test your code under the same conditions that you are using it, so could you please provide the solution to test it? Please include any detail that you consider helpful.

 

 

I can't assure you that I'm going to find the problem and/or fix it, but I will try my best to help you with this.

 

 

I will be waiting for your reply.

 

 

Regards,

 

Leonardo R.
0 Kudos
MJala
Novice
403 Views

Hi Leonardo,

Here's the complete solution

https://drive.google.com/open?id=0B7j2NoupYo5gd2dvT3o3c2xsY2c QueryVertices_allZero.zip - Google Drive

But basically only this file (SR300Camera.cpp) has problem:

# define NOMINMAX

 

# define _WINSOCKAPI_

# include "SR300Camera.h"

 

# include "RealSense/SenseManager.h"

 

# include "RealSense/SampleReader.h"

 

# include "util_render.h"

 

# include "Visualizer.h"

 

# include "RealSense/Session.h"

 

# include

 

# include

/***

 

Private constructor for the SR300 Camera depth sensor

 

***/

 

using namespace std;

 

//using namespace Intel::RealSense;

PXCSenseManager *pp = PXCSenseManager::CreateInstance();

 

PXCCapture::Device *device;

 

PXCCaptureManager *cm;

const int depth_fps = 30;

 

const int depth_width = 640;

 

const int depth_height = 480;

 

cv::Size bufferSize;

 

const PXCCapture::Sample *sample;

 

//std::vector xyzBuffer;

 

std::vector xyzBuffer;

 

SR300Camera::SR300Camera(bool use_live_sensor)

 

{

CONFIDENCE_THRESHHOLD = (60.0f / 255.0f*500.0f);

 

X_DIMENSION = depth_width;

 

Y_DIMENSION = depth_height;

int num_pixels = X_DIMENSION * Y_DIMENSION;

 

PXCPoint3DF32* vertices = new PXCPoint3DF32[num_pixels];

if (!use_live_sensor) {

 

return;

 

}

int res;

 

std::cout << "Trying to open SR300 camera\n";</strong>if (!pp) {  wprintf_s(L"Unable to create the SenseManager\n");  }cm = pp->QueryCaptureManager();  //Status sts= STATUS_NO_ERROR;  Status sts = STATUS_DATA_UNAVAILABLE; //mona is this the correct initialization?  UtilRender renderc(L"Color"), renderd(L"Depth"), renderi(L"IR"), renderr(L"Right"), renderl(L"Left");do {  bool revert = false;  pp->EnableStream(PXCCapture::StreamType::STREAM_TYPE_DEPTH,  X_DIMENSION, Y_DIMENSION, depth_fps);  revert = true;  sts = pp->Init();  if (sts < Status::STATUS_NO_ERROR) { if (revert) { pp->Close();  pp->EnableStream(PXCCapture::STREAM_TYPE_DEPTH);  sts = pp->Init();  if (sts < Status::STATUS_NO_ERROR) {  pp->Close();  //pp->EnableStream(Capture::STREAM_TYPE_COLOR);  sts = pp->Init();  }  }  if (sts < Status::STATUS_NO_ERROR) {  wprintf_s(L"Failed to locate any video stream(s)\n");  pp->Release();  }  } device = pp->QueryCaptureManager()->QueryDevice(); device->ResetProperties(PXCCapture::STREAM_TYPE_ANY); for (int nframes = 0; ; nframes++) {  sts = pp->AcquireFrame(false); if (sts < Status::STATUS_NO_ERROR) {  if (sts == Status::STATUS_STREAM_CONFIG_CHANGED) {  wprintf_s(L"Stream configuration was changed, re-initilizing\n");  pp->Close();  }  break;  } sample = pp->QuerySample(); if (sample) {  if (sample->depth && !renderd.RenderFrame(sample->depth)) break;  PXCImage::ImageData depthImage;  PXCImage *depthMap = sample->depth;  //depthMap->AcquireAccess(Image::ACCESS_READ, &depthImage);  depthMap->AcquireAccess(PXCImage::ACCESS_WRITE, &depthImage); //mona is this the correct flag?  PXCImage::ImageInfo imgInfo = depthMap->QueryInfo();  int depth_stride = depthImage.pitches[0] / sizeof(pxcU16);  PXCProjection * projection = device->CreateProjection();  cout << "projection is: " << projection;</strong>  cout << "devi...
0 Kudos
idata
Employee
403 Views

Hi MonaJalal,

 

 

Thanks for the code.

 

 

I am going to test your code, just to make sure, are you using the SDK R2 or the SDK R3?

 

 

I appreciate your patience.

 

 

Regards,

 

Leonardo R.
0 Kudos
idata
Employee
403 Views

Hi MonaJalal,

I tried my best to find the issue in your code, but unfortunately I was not able to find it. As I mentioned before, the best recommendation that I can give you is to use the SDK sample https://software.intel.com/sites/landingpage/realsense/camera-sdk/v2016r3/documentation/html/index.html%3Fsample_projection_cpp.html https://software.intel.com/sites/landingpage/realsense/camera-sdk/v2016r3/documentation/html/index.html?sample_projection_cpp.html, just consider that the function ProjectDepthToCamera(wxhDepth, posUVZ, pos3D) uses a large amount of pixels and a lot of them are zero.

I really appreciate your patience.

Regards,

 

Leonardo R.
0 Kudos
Reply