本文整理汇总了C++中IDepthFrameSource::OpenReader方法的典型用法代码示例。如果您正苦于以下问题:C++ IDepthFrameSource::OpenReader方法的具体用法?C++ IDepthFrameSource::OpenReader怎么用?C++ IDepthFrameSource::OpenReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDepthFrameSource
的用法示例。
在下文中一共展示了IDepthFrameSource::OpenReader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
bool DepthStream::open()
{
if (!m_Device->isOpen()) {
ofLogWarning("ofxKinect2::DepthStream") << "No ready Kinect2 found.";
return false;
}
m_IsInvert = true;
m_NearValue = 0;
m_FarValue = 10000;
IDepthFrameSource *depthFrameSource = nullptr;
HRESULT hr = m_Device->get().kinect2->get_DepthFrameSource(&depthFrameSource);
if (SUCCEEDED(hr)) {
hr = depthFrameSource->OpenReader(&m_StreamHandle.depthFrameReader);
}
safeRelease(depthFrameSource);
if (FAILED(hr)) {
ofLogWarning("ofxKinect2::DepthStream") << "Can't open stream.";
return false;
}
return Stream::open();
}
示例2: initKinect
HRESULT capKinect::initKinect()
{
HRESULT hr;
hr = GetDefaultKinectSensor(&m_pKinect);
if (FAILED(hr)) return hr;
if (m_pKinect)
{
// initialize successed
IDepthFrameSource *pDepthFrameSource = NULL;
hr = m_pKinect->Open();
if (SUCCEEDED(hr))
{
hr = m_pKinect->get_DepthFrameSource(&pDepthFrameSource);
}
if (SUCCEEDED(hr))
{
hr = pDepthFrameSource->OpenReader(&m_pDepthReader);
}
if(pDepthFrameSource)SafeRelease(pDepthFrameSource);
}
if (!m_pKinect || FAILED(hr))
{
printf("No ready Kinect found!\n");
return E_FAIL;
}
return hr;
}
示例3: start_device
bool KinectInterface::start_device() {
HRESULT hr;
kinectSensor = nullptr;
hr = GetDefaultKinectSensor(&kinectSensor);
// initialize Kinect Sensor
if (FAILED(hr) || !kinectSensor) {
std::cout << "ERROR hr=" << hr << "; sensor=" << kinectSensor << std::endl;
return false;
}
CHECKERROR(kinectSensor->Open())
kinectSensor->get_CoordinateMapper(&mapper);
// initialize depth frame reader
//CHECKERROR(kinectSensor->OpenMultiSourceFrameReader(
// FrameSourceTypes::FrameSourceTypes_Depth | FrameSourceTypes::FrameSourceTypes_Color,
// &reader));
IDepthFrameSource* depthFrameSource = nullptr;
CHECKERROR(kinectSensor->get_DepthFrameSource(&depthFrameSource));
CHECKERROR(depthFrameSource->OpenReader(&depthFrameReader));
if (depthFrameSource) depthFrameSource->Release();
IColorFrameSource* colorFrameSource = nullptr;
CHECKERROR(kinectSensor->get_ColorFrameSource(&colorFrameSource));
CHECKERROR(colorFrameSource->OpenReader(&colorFrameReader));
if (depthFrameSource) colorFrameSource->Release();
return true;
}
示例4: ImageSourceEngine
//Hao modified it
Kinect2Engine::Kinect2Engine(const char *calibFilename) : ImageSourceEngine(calibFilename)
{
imageSize_d = Vector2i(512, 424);
imageSize_rgb = Vector2i(1920, 1080);
//imageSize_rgb = Vector2i(640, 480);
nDepthMinReliableDistance = 500;
nDepthMaxDistance = USHRT_MAX;
data = new PrivateData();
// create heap storage for color pixel data in RGBX format
m_pColorRGBX = new RGBQUAD[imageSize_rgb.x * imageSize_rgb.y];
colorAvailable = true;
HRESULT hr;
depthAvailable = true;
hr = GetDefaultKinectSensor(&data->kinectSensor);
if (FAILED(hr))
{
depthAvailable = false;
printf("Kinect2: Failed to initialise depth camera\n");
return;
}
if (data->kinectSensor)
{
IDepthFrameSource* pDepthFrameSource = NULL;
IColorFrameSource* pColorFrameSource = NULL;
hr = data->kinectSensor->Open();
if (SUCCEEDED(hr))
hr = data->kinectSensor->get_DepthFrameSource(&pDepthFrameSource);
if (SUCCEEDED(hr))
hr = pDepthFrameSource->OpenReader(&data->depthFrameReader);
if (SUCCEEDED(hr))
hr = data->kinectSensor->get_ColorFrameSource(&pColorFrameSource);
if (SUCCEEDED(hr))
hr = pColorFrameSource->OpenReader(&data->colorFrameReader);
SafeRelease(pColorFrameSource);
SafeRelease(pDepthFrameSource);
this->calib.intrinsics_d.SetFrom(366.685, 366.685, 256.52, 208.1, 640, 480);
}
if (!data->kinectSensor || FAILED(hr))
{
depthAvailable = false;
printf("Kinect2: No ready Kinect 2 sensor found\n");
return;
}
}
示例5: initDepthFrameReader
HRESULT KinectHDFaceGrabber::initDepthFrameReader()
{
IDepthFrameSource* depthFrameSource = nullptr;
HRESULT hr = m_pKinectSensor->get_DepthFrameSource(&depthFrameSource);
IFrameDescription* frameDescription = nullptr;
if (SUCCEEDED(hr)){
hr = depthFrameSource->get_FrameDescription(&frameDescription);
}
if (SUCCEEDED(hr)){
hr = frameDescription->get_Width(&m_depthWidth);
}
if (SUCCEEDED(hr)){
hr = frameDescription->get_Height(&m_depthHeight);
}
if (SUCCEEDED(hr)){
m_depthBuffer.resize(m_depthHeight * m_depthWidth);
}
SafeRelease(frameDescription);
if (SUCCEEDED(hr)){
hr = depthFrameSource->OpenReader(&m_pDepthFrameReader);
}
SafeRelease(depthFrameSource);
return hr;
}
示例6: assert
// コンストラクタ
KinectV2::KinectV2()
{
// センサを取得する
if (sensor == NULL && GetDefaultKinectSensor(&sensor) == S_OK)
{
HRESULT hr;
// センサの使用を開始する
hr = sensor->Open();
assert(hr == S_OK);
// デプスデータの読み込み設定
IDepthFrameSource *depthSource;
hr = sensor->get_DepthFrameSource(&depthSource);
assert(hr == S_OK);
hr = depthSource->OpenReader(&depthReader);
assert(hr == S_OK);
IFrameDescription *depthDescription;
hr = depthSource->get_FrameDescription(&depthDescription);
assert(hr == S_OK);
depthSource->Release();
// デプスデータのサイズを得る
depthDescription->get_Width(&depthWidth);
depthDescription->get_Height(&depthHeight);
depthDescription->Release();
// カラーデータの読み込み設定
IColorFrameSource *colorSource;
hr = sensor->get_ColorFrameSource(&colorSource);
assert(hr == S_OK);
hr = colorSource->OpenReader(&colorReader);
assert(hr == S_OK);
IFrameDescription *colorDescription;
hr = colorSource->get_FrameDescription(&colorDescription);
assert(hr == S_OK);
colorSource->Release();
// カラーデータのサイズを得る
colorDescription->get_Width(&colorWidth);
colorDescription->get_Height(&colorHeight);
colorDescription->Release();
// 座標のマッピング
hr = sensor->get_CoordinateMapper(&coordinateMapper);
assert(hr == S_OK);
// depthCount と colorCount を計算してテクスチャとバッファオブジェクトを作成する
makeTexture();
// デプスデータからカメラ座標を求めるときに用いる一時メモリを確保する
position = new GLfloat[depthCount][3];
// カラーデータを変換する用いる一時メモリを確保する
color = new GLubyte[colorCount * 4];
}
}
示例7: if
void Kinect2StreamImpl::openFrameReader()
{
if (!m_pKinectSensor) {
return;
}
if (m_sensorType == ONI_SENSOR_COLOR && !m_pFrameReader.color) {
IColorFrameSource* frameSource = NULL;
HRESULT hr = m_pKinectSensor->get_ColorFrameSource(&frameSource);
if (SUCCEEDED(hr)) {
hr = frameSource->OpenReader(&m_pFrameReader.color);
if (FAILED(hr) && m_pFrameReader.color) {
m_pFrameReader.color->Release();
m_pFrameReader.color = NULL;
}
}
if (frameSource) {
frameSource->Release();
}
}
else if (m_sensorType == ONI_SENSOR_DEPTH && !m_pFrameReader.depth) {
IDepthFrameSource* frameSource = NULL;
HRESULT hr = m_pKinectSensor->get_DepthFrameSource(&frameSource);
if (SUCCEEDED(hr)) {
hr = frameSource->OpenReader(&m_pFrameReader.depth);
if (FAILED(hr) && m_pFrameReader.depth) {
m_pFrameReader.depth->Release();
m_pFrameReader.depth = NULL;
}
}
if (frameSource) {
frameSource->Release();
}
}
else if(!m_pFrameReader.infrared) { // ONI_SENSOR_IR
IInfraredFrameSource* frameSource = NULL;
HRESULT hr = m_pKinectSensor->get_InfraredFrameSource(&frameSource);
if (SUCCEEDED(hr)) {
hr = frameSource->OpenReader(&m_pFrameReader.infrared);
if (FAILED(hr) && m_pFrameReader.infrared) {
m_pFrameReader.infrared->Release();
m_pFrameReader.infrared = NULL;
}
}
if (frameSource) {
frameSource->Release();
}
}
}
示例8: initializeDefaultSensor
int TextureManager::initializeDefaultSensor(char *errorMessage)
{
HRESULT hr;
sprintf_s(errorMessage, MAX_ERROR_LENGTH, "");
hr = GetDefaultKinectSensor(&kinect_sensor_);
if (FAILED(hr))
{
sprintf_s(errorMessage, MAX_ERROR_LENGTH, "Could not initialize Kinect");
kinect_sensor_ = NULL;
return -1;
}
if (kinect_sensor_)
{
// Initialize the Kinect and get the depth reader
IDepthFrameSource* depthFrameSource = NULL;
hr = kinect_sensor_->Open();
if (SUCCEEDED(hr))
{
hr = kinect_sensor_->get_DepthFrameSource(&depthFrameSource);
}
if (SUCCEEDED(hr))
{
hr = depthFrameSource->OpenReader(&depth_frame_reader_);
}
if (depthFrameSource)
{
depthFrameSource->Release();
depthFrameSource = NULL;
}
}
if (!kinect_sensor_ || FAILED(hr))
{
sprintf_s(errorMessage, MAX_ERROR_LENGTH,
"Could not open kinect depth reader");
return -1;
}
return 0;
}
示例9: BaseImageSourceEngine
Kinect2Engine::Kinect2Engine(const char *calibFilename) : BaseImageSourceEngine(calibFilename)
{
imageSize_d = Vector2i(512, 424);
imageSize_rgb = Vector2i(640, 480);
data = new PrivateData();
colorAvailable = false;
HRESULT hr;
depthAvailable = true;
hr = GetDefaultKinectSensor(&data->kinectSensor);
if (FAILED(hr))
{
depthAvailable = false;
printf("Kinect2: Failed to initialise depth camera\n");
return;
}
if (data->kinectSensor)
{
IDepthFrameSource* pDepthFrameSource = NULL;
hr = data->kinectSensor->Open();
if (SUCCEEDED(hr))
hr = data->kinectSensor->get_DepthFrameSource(&pDepthFrameSource);
if (SUCCEEDED(hr))
hr = pDepthFrameSource->OpenReader(&data->depthFrameReader);
SafeRelease(pDepthFrameSource);
}
if (!data->kinectSensor || FAILED(hr))
{
depthAvailable = false;
printf("Kinect2: No ready Kinect 2 sensor found\n");
return;
}
}
示例10: InitializeDefaultSensor
/// <summary>
/// Initializes the default Kinect sensor
/// </summary>
/// <returns>indicates success or failure</returns>
HRESULT CDepthBasics::InitializeDefaultSensor()
{
HRESULT hr;
hr = GetDefaultKinectSensor(&m_pKinectSensor);
if (FAILED(hr))
{
return hr;
}
if (m_pKinectSensor)
{
// Initialize the Kinect and get the depth reader
IDepthFrameSource* pDepthFrameSource = NULL;
hr = m_pKinectSensor->Open();
if (SUCCEEDED(hr))
{
hr = m_pKinectSensor->get_DepthFrameSource(&pDepthFrameSource);
}
if (SUCCEEDED(hr))
{
hr = pDepthFrameSource->OpenReader(&m_pDepthFrameReader);
}
SafeRelease(pDepthFrameSource);
}
if (!m_pKinectSensor || FAILED(hr))
{
SetStatusMessage(L"No ready Kinect found!", 10000, true);
return E_FAIL;
}
return hr;
}
示例11: init
//----------
void Depth::init(IKinectSensor * sensor) {
this->reader = NULL;
try {
IDepthFrameSource * source = NULL;
if (FAILED(sensor->get_DepthFrameSource(& source))) {
throw(Exception("Failed to initialise Depth source"));
}
if (FAILED(source->OpenReader(& this->reader))) {
throw(Exception("Failed to initialise Depth reader"));
}
SafeRelease(source);
if (FAILED(sensor->get_CoordinateMapper(&this->coordinateMapper))) {
throw(Exception("Failed to acquire coordinate mapper"));
}
} catch (std::exception & e) {
SafeRelease(this->reader);
throw (e);
}
}
示例12: main
int main(int argc, char* argv[])
{
int similarity = 0;
string line;
ifstream myfile ("source_config.txt");
if (myfile.is_open())
{
getline (myfile,line);
hauteurCamera = stoi(line);
getline (myfile,line);
fountainXPosition = stoi(line);
getline (myfile,line);
fountainYPosition = stoi(line);
getline (myfile,line);
fountainWidth = stoi(line);
getline (myfile,line);
blasterWidth = stoi(line);
getline (myfile,line);
int numberOfBlaster = stoi(line);
for(int i = 0;i<numberOfBlaster;i++){
getline (myfile,line);
blasterXPosition.push_back(stoi(line));
getline (myfile,line);
blasterYPosition.push_back(stoi(line));
}
myfile.close();
}
else
{
cout << "Unable to open file";
exit(-1);
}
IKinectSensor* m_pKinectSensor;
IDepthFrameReader* pDepthReader;
IDepthFrameSource* pDepthFrameSource = NULL; // Depth image
IColorFrameReader* pColorReader;
IColorFrameSource* pColorFrameSource = NULL;
HRESULT hr;
hr = GetDefaultKinectSensor(&m_pKinectSensor);
if (FAILED(hr)){
cout << "ColorTrackerv2 Error : GetDefaultKinectSensor failed." << endl;
return false;
}
hr = m_pKinectSensor->Open();
if (FAILED(hr)){
cout << "ColorTrackerv2 Error : Open failed." << endl;
return false;
}
hr = m_pKinectSensor->get_DepthFrameSource( &pDepthFrameSource );
if (FAILED(hr)){
cout << "ColorTrackerv2 Error : get_DepthFrameSource failed." << endl;
return false;
}
hr = pDepthFrameSource->OpenReader( &pDepthReader );
if (FAILED(hr)){
cout << "ColorTrackerv2 Error : OpenReader failed." << endl;
return false;
}
IFrameDescription* pDepthDescription;
hr = pDepthFrameSource->get_FrameDescription( &pDepthDescription );
if( FAILED( hr ) ){
std::cerr << "Error : IDepthFrameSource::get_FrameDescription()" << std::endl;
return -1;
}
w = 0,h = 0;
pDepthDescription->get_Width( &w ); // 512
pDepthDescription->get_Height( &h ); // 424
//unsigned int irBufferSize = w * h * sizeof( unsigned short );
hr = m_pKinectSensor->get_ColorFrameSource( &pColorFrameSource );
if (FAILED(hr)){
cout << "ColorTrackerv2 Error : get_ColorFrameSource failed." << endl;
return false;
}
hr = pColorFrameSource->OpenReader( &pColorReader );
if (FAILED(hr)){
cout << "ColorTrackerv2 Error : OpenReader failed." << endl;
return false;
}
// Description
IFrameDescription* pColorDescription;
hr = pColorFrameSource->get_FrameDescription( &pColorDescription );
//.........这里部分代码省略.........
示例13: main
int main(int argc, char** argv)
{
// 1a. Get default Sensor
cout << "Try to get default sensor" << endl;
IKinectSensor* pSensor = nullptr;
if (GetDefaultKinectSensor(&pSensor) != S_OK)
{
cerr << "Get Sensor failed" << endl;
}
else
{
// 1b. Open sensor
cout << "Try to open sensor" << endl;
if (pSensor->Open() != S_OK)
{
cerr << "Can't open sensor" << endl;
}
else
{
// 2a. Get frame source
cout << "Try to get source" << endl;
IDepthFrameSource* pFrameSource = nullptr;
if (pSensor->get_DepthFrameSource(&pFrameSource) != S_OK)
{
cerr << "Can't get frame source" << endl;
}
else
{
// 2b. Get frame description
int iWidth = 0;
int iHeight = 0;
IFrameDescription* pFrameDescription = nullptr;
if (pFrameSource->get_FrameDescription(&pFrameDescription) == S_OK)
{
pFrameDescription->get_Width(&iWidth);
pFrameDescription->get_Height(&iHeight);
pFrameDescription->Release();
pFrameDescription = nullptr;
}
// 2c. get some dpeth only meta
UINT16 uDepthMin = 0, uDepthMax = 0;
pFrameSource->get_DepthMinReliableDistance(&uDepthMin);
pFrameSource->get_DepthMaxReliableDistance(&uDepthMax);
cout << "Reliable Distance: " << uDepthMin << " - " << uDepthMax << endl;
// perpare OpenCV
cv::Mat mDepthImg(iHeight, iWidth, CV_16UC1);
cv::Mat mImg8bit(iHeight, iWidth, CV_8UC1);
cv::namedWindow( "Depth Map" );
// 3a. get frame reader
cout << "Try to get frame reader" << endl;
IDepthFrameReader* pFrameReader = nullptr;
if (pFrameSource->OpenReader(&pFrameReader) != S_OK)
{
cerr << "Can't get frame reader" << endl;
}
else
{
// Enter main loop
cout << "Enter main loop" << endl;
while (true)
{
// 4a. Get last frame
IDepthFrame* pFrame = nullptr;
if (pFrameReader->AcquireLatestFrame(&pFrame) == S_OK)
{
// 4c. copy the depth map to image
if (pFrame->CopyFrameDataToArray(iWidth * iHeight, reinterpret_cast<UINT16*>(mDepthImg.data)) == S_OK)
{
// 4d. convert from 16bit to 8bit
mDepthImg.convertTo(mImg8bit, CV_8U, 255.0f / uDepthMax);
cv::imshow("Depth Map", mImg8bit);
}
else
{
cerr << "Data copy error" << endl;
}
// 4e. release frame
pFrame->Release();
}
// 4f. check keyboard input
if (cv::waitKey(30) == VK_ESCAPE){
break;
}
}
// 3b. release frame reader
cout << "Release frame reader" << endl;
pFrameReader->Release();
pFrameReader = nullptr;
}
// 2d. release Frame source
cout << "Release frame source" << endl;
pFrameSource->Release();
pFrameSource = nullptr;
//.........这里部分代码省略.........
示例14: main
int main()
{
// 1. Sensor related code
cout << "Try to get default sensor" << endl;
{
if (GetDefaultKinectSensor(&pSensor) != S_OK) {
cerr << "Get Sensor failed" << endl;
return -1;
}
cout << "Try to open sensor" << endl;
if (pSensor->Open() != S_OK) {
cerr << "Can't open sensor" << endl;
return -1;
}
}
// 2. Color related code
cout << "Try to get color source" << endl;
{
// Get frame source
IColorFrameSource* pFrameSource = nullptr;
if (pSensor->get_ColorFrameSource(&pFrameSource) != S_OK) {
cerr << "Can't get color frame source" << endl;
return -1;
}
// Get frame description
cout << "get color frame description" << endl;
IFrameDescription* pFrameDescription = nullptr;
if (pFrameSource->get_FrameDescription(&pFrameDescription) == S_OK) {
pFrameDescription->get_Width(&iColorWidth);
pFrameDescription->get_Height(&iColorHeight);
uColorPointNum = iColorWidth * iColorHeight;
uColorBufferSize = uColorPointNum * 4 * sizeof(BYTE);
pCSPoints = new CameraSpacePoint[uColorPointNum];
pColorBuffer = new BYTE[4 * uColorPointNum];
}
pFrameDescription->Release();
pFrameDescription = nullptr;
// get frame reader
cout << "Try to get color frame reader" << endl;
if (pFrameSource->OpenReader(&pColorFrameReader) != S_OK) {
cerr << "Can't get color frame reader" << endl;
return -1;
}
// release Frame source
cout << "Release frame source" << endl;
pFrameSource->Release();
pFrameSource = nullptr;
}
// 3. Depth related code
cout << "Try to get depth source" << endl;
{
// Get frame source
IDepthFrameSource* pFrameSource = nullptr;
if (pSensor->get_DepthFrameSource(&pFrameSource) != S_OK) {
cerr << "Can't get depth frame source" << endl;
return -1;
}
// Get frame description
cout << "get depth frame description" << endl;
IFrameDescription* pFrameDescription = nullptr;
if (pFrameSource->get_FrameDescription(&pFrameDescription) == S_OK) {
int iDepthWidth = 0,
iDepthHeight = 0;
pFrameDescription->get_Width(&iDepthWidth);
pFrameDescription->get_Height(&iDepthHeight);
uDepthPointNum = iDepthWidth * iDepthHeight;
pDepthBuffer = new UINT16[uDepthPointNum];
}
pFrameDescription->Release();
pFrameDescription = nullptr;
// get frame reader
cout << "Try to get depth frame reader" << endl;
if (pFrameSource->OpenReader(&pDepthFrameReader) != S_OK) {
cerr << "Can't get depth frame reader" << endl;
return -1;
}
// release Frame source
cout << "Release frame source" << endl;
pFrameSource->Release();
pFrameSource = nullptr;
}
// 4. Coordinate Mapper
if (pSensor->get_CoordinateMapper(&pCoordinateMapper) != S_OK) {
cerr << "get_CoordinateMapper failed" << endl;
return -1;
}
while (1) {
//.........这里部分代码省略.........
示例15: main
int main()
{
// name and position windows
cvNamedWindow("Color Probabilistic Tracking - Samples", 1);
cvMoveWindow("Color Probabilistic Tracking - Samples", 0, 0);
cvNamedWindow("Color Probabilistic Tracking - Result", 1);
cvMoveWindow("Color Probabilistic Tracking - Result", 1000, 0);
//control mouse
setMouseCallback("Color Probabilistic Tracking - Samples", onMouse, 0);
cv::setUseOptimized(true);
// Sensor
IKinectSensor* pSensor;
HRESULT hResult = S_OK;
hResult = GetDefaultKinectSensor(&pSensor);
if (FAILED(hResult)) {
std::cerr << "Error : GetDefaultKinectSensor" << std::endl;
return -1;
}
hResult = pSensor->Open();
if (FAILED(hResult)) {
std::cerr << "Error : IKinectSensor::Open()" << std::endl;
return -1;
}
// Source
IColorFrameSource* pColorSource;
hResult = pSensor->get_ColorFrameSource(&pColorSource);
if (FAILED(hResult)) {
std::cerr << "Error : IKinectSensor::get_ColorFrameSource()" << std::endl;
return -1;
}
IDepthFrameSource* pDepthSource;
hResult = pSensor->get_DepthFrameSource(&pDepthSource);
if (FAILED(hResult)) {
std::cerr << "Error : IKinectSensor::get_DepthFrameSource()" << std::endl;
return -1;
}
/*IBodyIndexFrameSource* pBodyIndexSource;
hResult = pSensor->get_BodyIndexFrameSource(&pBodyIndexSource);*/
// Reader
IColorFrameReader* pColorReader;
hResult = pColorSource->OpenReader(&pColorReader);
if (FAILED(hResult)) {
std::cerr << "Error : IColorFrameSource::OpenReader()" << std::endl;
return -1;
}
IDepthFrameReader* pDepthReader;
hResult = pDepthSource->OpenReader(&pDepthReader);
if (FAILED(hResult)) {
std::cerr << "Error : IDepthFrameSource::OpenReader()" << std::endl;
return -1;
}
//IBodyIndexFrameReader* pBodyIndexReader;//saferealease
//hResult = pBodyIndexSource->OpenReader(&pBodyIndexReader);
// Description
IFrameDescription* pColorDescription;
hResult = pColorSource->get_FrameDescription(&pColorDescription);
if (FAILED(hResult)) {
std::cerr << "Error : IColorFrameSource::get_FrameDescription()" << std::endl;
return -1;
}
int colorWidth = 0;
int colorHeight = 0;
pColorDescription->get_Width(&colorWidth); // 1920
pColorDescription->get_Height(&colorHeight); // 1080
unsigned int colorBufferSize = colorWidth * colorHeight * 4 * sizeof(unsigned char);
cv::Mat colorBufferMat(colorHeight, colorWidth, CV_8UC4);
cv::Mat colorMat(colorHeight / 2, colorWidth / 2, CV_8UC4);
cv::namedWindow("Color");
RGBQUAD* m_pDepthRGBX;
m_pDepthRGBX = new RGBQUAD[512 * 424];// create heap storage for color pixel data in RGBX format
IFrameDescription* pDepthDescription;
hResult = pDepthSource->get_FrameDescription(&pDepthDescription);
if (FAILED(hResult)) {
std::cerr << "Error : IDepthFrameSource::get_FrameDescription()" << std::endl;
return -1;
}
int depthWidth = 0;
int depthHeight = 0;
pDepthDescription->get_Width(&depthWidth); // 512
pDepthDescription->get_Height(&depthHeight); // 424
unsigned int depthBufferSize = depthWidth * depthHeight * sizeof(unsigned short);
cv::Mat depthBufferMat(depthHeight, depthWidth, CV_16UC1);
//.........这里部分代码省略.........