Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

visual studio 2013 with c++ do not show Depth image

Hi, I am a new user in Opencv. I wrote a simple code that is:

// emmb.cpp : Defines the entry point for the console application.

//

include "stdafx.h"

include <kinect.h>

include <iostream>

include <opencv2\core.hpp>

include <opencv2\video.hpp>

include <opencv2\highgui.hpp>

typedef unsigned short unit16; using namespace cv; using namespace std; template <class t=""> void SafeRelease(T *ppT) { if (ppT) { (*ppT)->Release(); *ppT = NULL; } };

int _tmain(int argc, _TCHAR* argv[]) { IKinectSensor* pSensor; HRESULT hResult = S_OK; hResult = GetDefaultKinectSensor(&pSensor); if (FAILED(hResult)){ std::cout << "Error : GetDefaultKinectSensor" << std::endl; return -1; } hResult = pSensor->Open(); if (FAILED(hResult)){ std::cout << "Error : IKinectSensor::Open()" << std::endl; return -1; } IDepthFrameSource* pSource; hResult = pSensor->get_DepthFrameSource(&pSource); if (FAILED(hResult)){ std::cout << "Error : IKinectSensor::get_FrameSource()" << std::endl; return -1; } IDepthFrameReader* pDepthReader; hResult = pSource->OpenReader(&pDepthReader); if (SUCCEEDED(hResult)){ std::cout << "Error : IFrameSource::OpenReader()" << std::endl; return -1; } int l = 0; int Width = 512; // ...... 1 int Height = 424; cv::Mat BufferMat(Height, Width, CV_16UC1); // ...... 3 cv::Mat DepthMat(Height, Width, CV_8UC1); // ...... 3 cv::namedWindow("ebi");

while (l<1){
    // Frame

    IDepthFrame* pDepthFrame = nullptr;
    hResult = pDepthReader->AcquireLatestFrame(&pDepthFrame);
    if (SUCCEEDED(hResult)){
        unsigned int bufferSize = 512 * 424 * sizeof(unsigned short);
        unsigned short* pBuffer = nullptr;
        hResult = pDepthFrame->AccessUnderlyingBuffer(&bufferSize, reinterpret_cast<UINT16**>(&BufferMat.data));
        if (SUCCEEDED(hResult)){
            /* Processing*/
            BufferMat.convertTo(DepthMat, CV_8U, -255.0f / 8000.0f, 255.0f);  
        }

    }


    SafeRelease(&pDepthFrame);
    cv::imshow("Depth", DepthMat);
    cv::waitKey(0);
    if (cv::waitKey(30) == VK_ESCAPE){
        break;
    }



    l++;
}
cin.get();
return 0;

}

But the output in debugging is:

'emmb.exe' (Win32): Loaded 'C:\Users\Ebi\Documents\Visual Studio 2013\Projects\emmb\Release\emmb.exe'. Symbols loaded.

'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\Kinect20.dll'. Cannot find or open the PDB file. 'emmb.exe' (Win32): Loaded 'C:\opencv\build\x86\vc12\bin\opencv_core2413d.dll'. Cannot find or open the PDB file. 'emmb.exe' (Win32): Loaded 'C:\opencv\build\x86\vc12\bin\opencv_highgui2413d.dll'. Cannot find or open the PDB file. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\mfplat.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvfw32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\avifil32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\avicap32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmm.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\comctl32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msacm32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmmbase.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\devobj.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\RTWorkQ.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\avrt.dll'. Symbols loaded. The thread 0x9bc has exited with code -1 (0xffffffff). The program '[4700] emmb.exe' has exited with code -1 (0xffffffff).

And no image is not showed , how can fix it. And sorry for my English......:):):)

click to hide/show revision 2
No.2 Revision

updated 2016-11-23 05:51:44 -0600

berak gravatar image

visual studio 2013 with c++ do not show Depth image

Hi, I am a new user in Opencv. I wrote a simple code that is:

// emmb.cpp : Defines the entry point for the console application.

//

include "stdafx.h"

include <kinect.h>

include <iostream>

include <opencv2\core.hpp>

include <opencv2\video.hpp>

include <opencv2\highgui.hpp>

// #include "stdafx.h" #include <Kinect.h> #include <iostream> #include <opencv2\core.hpp> #include <opencv2\video.hpp> #include <opencv2\highgui.hpp> typedef unsigned short unit16; using namespace cv; using namespace std; template <class t=""> T> void SafeRelease(T *ppT) **ppT) { if (ppT) (*ppT) { (*ppT)->Release(); *ppT = NULL; } };

}; int _tmain(int argc, _TCHAR* argv[]) { IKinectSensor* pSensor; HRESULT hResult = S_OK; hResult = GetDefaultKinectSensor(&pSensor); if (FAILED(hResult)){ std::cout << "Error : GetDefaultKinectSensor" << std::endl; return -1; } hResult = pSensor->Open(); if (FAILED(hResult)){ std::cout << "Error : IKinectSensor::Open()" << std::endl; return -1; } IDepthFrameSource* pSource; hResult = pSensor->get_DepthFrameSource(&pSource); if (FAILED(hResult)){ std::cout << "Error : IKinectSensor::get_FrameSource()" << std::endl; return -1; } IDepthFrameReader* pDepthReader; hResult = pSource->OpenReader(&pDepthReader); if (SUCCEEDED(hResult)){ std::cout << "Error : IFrameSource::OpenReader()" << std::endl; return -1; } int l = 0; int Width = 512; // ...... 1 int Height = 424; cv::Mat BufferMat(Height, Width, CV_16UC1); // ...... 3 cv::Mat DepthMat(Height, Width, CV_8UC1); // ...... 3 cv::namedWindow("ebi");

cv::namedWindow("ebi");

    while (l<1){
     // Frame

     IDepthFrame* pDepthFrame = nullptr;
     hResult = pDepthReader->AcquireLatestFrame(&pDepthFrame);
     if (SUCCEEDED(hResult)){
         unsigned int bufferSize = 512 * 424 * sizeof(unsigned short);
         unsigned short* pBuffer = nullptr;
         hResult = pDepthFrame->AccessUnderlyingBuffer(&bufferSize, reinterpret_cast<UINT16**>(&BufferMat.data));
         if (SUCCEEDED(hResult)){
             /* Processing*/
             BufferMat.convertTo(DepthMat, CV_8U, -255.0f / 8000.0f, 255.0f);  
         }

     }


     SafeRelease(&pDepthFrame);
     cv::imshow("Depth", DepthMat);
     cv::waitKey(0);
     if (cv::waitKey(30) == VK_ESCAPE){
         break;
     }



     l++;
 }
 cin.get();
 return 0;

}

}

But the output in debugging is:

 'emmb.exe' (Win32): Loaded 'C:\Users\Ebi\Documents\Visual Studio 2013\Projects\emmb\Release\emmb.exe'. Symbols loaded.

'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\Kinect20.dll'. Cannot find or open the PDB file. 'emmb.exe' (Win32): Loaded 'C:\opencv\build\x86\vc12\bin\opencv_core2413d.dll'. Cannot find or open the PDB file. 'emmb.exe' (Win32): Loaded 'C:\opencv\build\x86\vc12\bin\opencv_highgui2413d.dll'. Cannot find or open the PDB file. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\mfplat.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvfw32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\avifil32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\avicap32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmm.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\comctl32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msacm32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winmmbase.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\devobj.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\RTWorkQ.dll'. Symbols loaded. 'emmb.exe' (Win32): Loaded 'C:\Windows\SysWOW64\avrt.dll'. Symbols loaded. The thread 0x9bc has exited with code -1 (0xffffffff). The program '[4700] emmb.exe' has exited with code -1 (0xffffffff).

(0xffffffff).

And no image is not showed , how can fix it. And sorry for my English......:):):)