NtKinect: Kinect V2 C++ Programming with OpenCV on Windows10

How to get Infrared image with Kinect V2


2016.07.20: created by
Japanese English
To Table of Contents

Prerequisite knowledge


Getting Infrared image

Infrared images can be acquired with a resolution of 512 x 424 as well as Depth images.

The obtained infrared image is represented by UINT16 for each pixel.

NtKinect

NtKinect's functions for Infrared image

type of return value function name descriptions
void setInfrared() Set infrared image to the member variable "infraredImage"
NtKinect

NtKinect's member variable for Infrared image

type variable name descriptions
cv::Mat infraredImage Infrared image.
Resolution is 512 x 4s4, and each pixel is represented by UINT16.
The coordinates of the image are the positions in the DepthSpace coordinate system.
  • infraredImage.cols --- Resolution for the horizontal direction of the image (= 512)
  • infraredImage.rows --- Resolution for the vertical direction of the image (= 424)
  • infraredImage.at<UINT16>(y , x ) --- Access the pixel in the (x , y ) coordinates of the image
  •         UINT16 infrared = rgbImage.at<UINT16>(y , x );
    

How to write program

  1. Start using the Visual Studio's project KinectV2.zip of "NtKinect: How to get RGB camera image with Kinect V2 (Fundamental Settings)"
  2. Change the contents of main.cpp.
  3. Call kinect.setInfrared() function to set the infrared image to kinect.infraredImage.

    main.cpp
    #include <iostream>
    #include <sstream>
    
    #include "NtKinect.h"
    
    using namespace std;
    
    void doJob() {
      NtKinect kinect;
      while (1) {
        kinect.setInfrared();
        cv::imshow("infrared", kinect.infraredImage);
        auto key = cv::waitKey(1);
        if (key == 'q') break;
      }
      cv::destroyAllWindows();
    }
    
    int main(int argc, char** argv) {
      try {
        doJob();
      } catch (exception &ex) {
        cout << ex.what() << endl;
        string s;
        cin >> s;
      }
      return 0;
    }
    
  4. When you run the program, Depth images are displayed. Exit with 'q' key.



  5. Please click here for the sample project KinectV2_infrared.zip
  6. Since the above zip file may not include the latest "NtKinect.h", Download the latest version from here and replace old one with it.



http://nw.tsuda.ac.jp/