How can I take multiple Images with Kinect RGB and Infrared Camera

2 visualizzazioni (ultimi 30 giorni)
Hey Everyone, Fingers crossed someone can help! I am calibrating my kinect by means of taking an Infrared image and RGB image, I create objects for each videoinputs as so;
RGB = videoinput('kinect',1,'RGB_640x480');
IR = videoinput('kinect',1,'Infrared_640x480');
And save them into a cell matrix (because eventually I will have numerous kinects connected)
RGB_cams{1,1}= RGB;
RGB_cams{1,2}= IR;
I want to basically go through and take an RGB image then take an Infrared image seconds later so that the checkerboard is in the same position for each pair of images. I am using; (p.s. don't worry about 'l' and 'i' variables they are just numbering systems I am using)
% RGB image capture
image = getsnapshot(RGB_cams{1,1});
filename = sprintf('Calib_RGB2Depth/%d_%d.jpg',l,i);
imwrite(image,filename);
RGB_images{i,l} = image;
% Infrared Image capture
imageIR = getsnapshot(RGB_cams{l,2});
filename = sprintf('Calib_RGB2Depth/%dIR_%d.tiff',l,i);
imwrite(imageIR,filename);
This is looped N amount of times (N = 20 usually), sometimes it will take 16 pairs of images before an error sometimes it takes 4 pairs of images and errors, either way I have tried everything I could find i.e. pauses, clearing everything (including deleting saved videoinputs using delete(imaqfind)),using triggering instead of getsnapshot. However, I still get the error shown below;
Error using imaqdevice/getsnapshot (line 66)
Could not connect to the image acquisition device. Device may be in use.
There is nuthing physically running when I get this error aka no previews, I delete all videoinputs and clear everything and sometimes it still persists.Please tell me someone has had this issue before? How can I just take one image in RGB then in Infrared format??? Any help would be amazing!! Thanks in advance

Risposta accettata

Martin Schätz
Martin Schätz il 18 Ott 2015
Hi, I did try what was possible to do with your code, and i dont have any problems getting snapshots fo depth and then color repeatedly. But i suspect that the error is that here:
% Infrared Image capture
imageIR = getsnapshot(RGB_cams{l,2});
you have l instead of 1, so you don't ge to the right obejct for depth sensor.
Different approach to get data is like this:
clear all, close all, clc
% Extremly critical to reset imaq, kinect has problems very often and this
% helps. Sometimes is necessary to restart whole MatLab
imaqreset;
% Check if Kinect is connected
imaqhwinfo
% Create object for each of sensor
color = videoinput('kinect', 1);
depth = videoinput('kinect', 2);
% Get info for trigger settings
configColor = triggerinfo(color);
% Set triggers to manual so it is possible to work with them
triggerconfig([color depth],'manual');
% Set Frames per trigger. Bigger number means more frames when triggered.
color.FramesPerTrigger = 1;
depth.FramesPerTrigger = 1;
%%color
% Start the color sensor
% start logging of acquired data.
start(color);
figure
for i=1:60
% Trigger the sensor
trigger(color);
% Retrieve the acquired data and display them
[colorFrameData,colorTimeData,colorMetaData] = getdata(color);
imshow(colorFrameData)
end
% Stop
stop(color);
%%depth
% Start the color and depth device. This begins acquisition, but does not
% start logging of acquired data.
start(depth);
figure
for i=1:60
% Trigger the devices to start logging of data.
trigger(depth);
% Retrieve the acquired data
[depthFrameData,depthTimeData,depthMetaData] = getdata(depth);
imagesc(depthFrameData)
end
% Stop
stop(depth);
You can just start both at once, trigger both and then just colect it when you want it.

Più risposte (1)

Isam abdullah
Isam abdullah il 23 Mag 2016
I think you can't get the Infrared and RGB color both at the same time to up till now I have found. If there is a way to do this, please tell me too here.
  1 Commento
greatwallet
greatwallet il 5 Ago 2020
Actually on no accounts will you be able to get infrared and RGB images simultaneously. The reason behind this is that an infrared stream is captured as a part of a color image format, according to link.

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by