about read kinect depth information from matlab - matlab

I am using MATLAB 2015a
I get the snapshot of kinect depth video from Kinect with format of .fig However,when I use data cursor to get the depth information, it shows different type of number, it indeed confuse me.
[X Y]:[402 174]
index: 3201
[R G B]: [0.7843 0.7843 0.7843]
what does index specifies? does INDEX specifies the physical distance of that data cursor point from kinect camera?
Thanx !

Index is the distance to the camera plane in millimeters.
Note: If you want to do processing, you may want to try to get the depth data as an array, rather than as a .fig. If all you have is the .fig (and it's open and active), you can get the depth array as depth = get(gcf,'CData')

Related

Depth Image in Matlab

I have a depth image taken from Kinect V2 which is given below. I want to extract the pixel value x at any specific coordinate and its depth value in Matlab. I used the follwing code in Matlab but it gives me 16-bit value. However, I'm not sure is it pixel value or depth value of pixel x.
im=imread('image_depth.png');
val=im(88,116);
display(val);
Result
val= (uint16) 2977
Would someone please help me that, how to extract both pixel and depth value in Matlab?
The image name hints it is a depth map. The color map is stored usually in separate file usually in different resolution and with some offset present if not aligned already. To align RGB and Depth images see:
Align already captured rgb and depth images
and the sub-link too...
The image you provided peaks with color picker the same 0x000B0B0B color for the silhouette inside. That hints it is either not Depth map or it has too low bit-width or the SO+Brownser conversion lose precision. If any pixel inside returns the same number for you too then the depth map is unusable.
In case your peaks returns 16 bit value it hints RAW Kinect depth values. If the case see:
Kinect raw depth to distance in meters
Otherwise it could be just scaled depth so you can convert your x value to depth like:
depth = a0 + x*(a1-a0)
where <a0,a1> is the depth range of the image which should be stated somewhere in your dataset source ...
From your description, and the filename, the values at each location in your image are depth values.
If you need actual color values for each pixel, they would likely be stored in a separate image file, hopefully of the same dimension.
What you are seeing here is likely the depth values normalized to a displayable region with MATLAB or your picture viewing software.
You will need to look at the specs to see how a value like 2977 converts to the physical world (e.g. cm). Hopefully it is just a scalar value you can multiply to get that answer.

How to get depth of objects from Disparity Map?

I have a stereo camera setup and I am trying to generate a 3d reconstruction of the scene. I am able to obtain the disparity map from the images. After getting the disparity map, I am unable to understand how to get the scene. I am following this tutorial given by MATLAB. Can anyone please help me with it?
I have uploaded all my files here.
Typically, the depth value is on the Z coordinate. From this disparity map, and taking in consideration the tutorial link you provided, in order to get the objects depth, you just need to know their 3D position. Once you know the actual 3D (X,Y,Z), you just need to look at the Z coordinate.
Tutorial Section - Stitch a Sequence of Point Clouds
hScatter.ZData = ptCloudScene.Location(:,3);

Incorrect pixel value from data cursor on Matlab

When I open a Dicom image on Matlab (R2014b) and place the data cursor on a specific set of coordinates, I obtain an "index" (or pixel value) that does not match the same set of coordinates on the image's matrix (T).
>> figure, imshow(T);
See below on attached image.
Any idea why this is happening?
When using images, the data cursor tool with MATLAB's figure and its various ilk assume that X and Y are the column (horizontal) and row (vertical) coordinates respectively. In the variable inspector (the left part of your figure), these are reversed.
Be careful when using the data cursor on images. See this post by MathWorks on more details regarding interactive display of data: http://www.mathworks.com/help/matlab/creating_plots/data-cursor-displaying-data-values-interactively.html

Kinect v2 sensor Color-Depth Mapping misalignment using matlab [duplicate]

I have collected data using Kinect v2 sensor and I have a depth map together with its corresponding RGB image. I also calibrated the sensor and obtained the rotation and translation matrix between the Depth camera and RGB camera.
So I was able to reproject the depth values on the RGB image and they match. However, since the RGB image and the depth image are of different resolutions, there are a lot of holes in the resulting image.
So I am trying to move the other way, i.e. mapping the color onto the depth instead of depth to color.
So the first problem I am having is that the RGB image has 3 layers and I have to convert the RGB image to grayscale to do it and I am not getting the correct results.
Can this be done?
Has anyone tried this before?
Why can't you fit the Z-depth to the RGB?
To fit the low res image to the high- res should be easy, as long as both represent the same size of data (i.e. corners of both images are the same point)
It should be as easy as:
Z_interp=imresize(Zimg, [size(RGB,1) size(RGB,2)])
Now Z_interp should have the same amount of pixels as RGB
If you still want to do it the other way around, well, use the same approach:
RGB_interp=imresize(RGB, [size(Zimg,1) size(Zimg,2)])
The Image Acquisition Toolbox now officially supports Kinect v2 for Windows. You can get a point cloud out from Kinect using pcfromkinect function in the Computer Vision System Toolbox.

Processing Kinect Depth data in MATLAB

So I used Kinect to obtain some depth images and they are now saved. So if I want to process this depth image to get the Z value (i.e. the distance from the object to the Kinect) how should I do that?
I have been doing some research online and found out that I need to be saving the image as a 16bit depth image for the depth values to be stored instead of an 8 bit depth image which can only store up to 256 values. based on: Save Kinect depth image in Matlab?
But I still do not quite understand the image I am getting. When I use imread and uses the data cursor to look at the individual pixels, I only obtain the XY coordinates and an Index value. the index value does not seem to represent the distance in mm.
Can anyone clear this part for me please.
Thanks.
looks like your are reading an indexed image with imread()
try this:
[idx, map] = imread('yourImage');
RGB = ind2rgb(idx, map);
and see if RGB contains the correct value.