Hello.
As a part of a research project, I am trying to estimate the position of a marker with specific color with kinect. In the first part, markers position and color are determined by clicking on the marker and after that, in each frame I search the color image to find the markers position in the color frame (in pixels) and update the position. After that I use the mapColorPoints2Camera to determine the world coordinates of the marker.
But the code continuously generates Inf value for all three coordinates.
I have tried to check a fix point (for example 100, 100) and used the mapColorPoints2Camera function and it worked well. But as I changed the value in a loop (for example to check the coordinates on a line) the code generates inf value again.
I'm using MatlabR2016b, VS 2015 and MS Windows 10.
Here is my code:
addpath('Mex');
clear all
close all
k2 = Kin2('color','depth');
% images sizes
d_width = 512; d_height = 424; outOfRange = 4000;
c_width = 1920; c_height = 1080;
% Color image is to big, let's scale it down
COL_SCALE = 0.5;
% Create matrices for the images
depth = zeros(d_height,d_width,'uint16');
color = zeros(c_heightCOL_SCALE,c_widthCOL_SCALE,3,'uint8');
% Loop until pressing 'q' on any figure
k=[];
count = 0;
while true
% Get frames from Kinect and save them on underlying buffer
validData = k2.updateData;
% Before processing the data, we need to make sure that a valid
% frame was acquired.
if validData
% Copy data to Matlab matrices
depth = k2.getDepth;
color = k2.getColor;
% update depth figure
depth8u = uint8(depth*(255/outOfRange));
depth8uc3 = repmat(depth8u,[1 1 3]);
color = imresize(color,COL_SCALE);
count = count + 1;
k2.mapColorPoints2Camera([count count])
end
if ~isempty(k)
if strcmp(k,'q'); break; end;
end
pause(0.01)
end
Hello.
As a part of a research project, I am trying to estimate the position of a marker with specific color with kinect. In the first part, markers position and color are determined by clicking on the marker and after that, in each frame I search the color image to find the markers position in the color frame (in pixels) and update the position. After that I use the mapColorPoints2Camera to determine the world coordinates of the marker.
But the code continuously generates Inf value for all three coordinates.
I have tried to check a fix point (for example 100, 100) and used the mapColorPoints2Camera function and it worked well. But as I changed the value in a loop (for example to check the coordinates on a line) the code generates inf value again.
I'm using MatlabR2016b, VS 2015 and MS Windows 10.
Here is my code:
addpath('Mex');
clear all
close all
k2 = Kin2('color','depth');
% images sizes
d_width = 512; d_height = 424; outOfRange = 4000;
c_width = 1920; c_height = 1080;
% Color image is to big, let's scale it down
COL_SCALE = 0.5;
% Create matrices for the images
depth = zeros(d_height,d_width,'uint16');
color = zeros(c_heightCOL_SCALE,c_widthCOL_SCALE,3,'uint8');
% Loop until pressing 'q' on any figure
k=[];
count = 0;
while true
% Get frames from Kinect and save them on underlying buffer
validData = k2.updateData;
end