#include <windows.h>
#include <wchar.h>
#include "pxcsensemanager.h"
#include "util_render.h" //SDK provided utility class used for rendering (packaged in libpxcutils.lib)
void QueryFilterDevice(PXCCaptureManager *filterbydeviceinfo, int n)
{
PXCSession::ImplDesc desc1 = {};
desc1.group = PXCSession::IMPL_GROUP_SENSOR;
desc1.subgroup = PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE;
PXCSession *session = PXCSession::CreateInstance();
PXCSession::ImplDesc desc2;
session->QueryImpl(&desc1, 0, &desc2)<PXC_STATUS_NO_ERROR;
wprintf_s(L"Module[%d]: %s\n", 0, desc2.friendlyName);
PXCCapture *capture = 0;
session->CreateImpl<PXCCapture>(&desc2, &capture);
PXCCapture::DeviceInfo dinfo;
capture->QueryDeviceInfo(n, &dinfo);
filterbydeviceinfo->FilterByDeviceInfo(&dinfo);
}
int wmain(int argc, WCHAR* argv[]) {
// initialize the util render
UtilRender renderColor(L"Color");
UtilRender renderDepth(L"Depth");
// create the PXCSenseManager
PXCSenseManager *psm = PXCSenseManager::CreateInstance();
if (!psm) {
wprintf_s(L"Unable to create the PXCSenseManager\n");
return 1;
}
PXCCaptureManager *cm = psm->QueryCaptureManager();
QueryFilterDevice(cm,0);
// select the color stream of size 640x480 and depth stream of size 320x240
psm->EnableStream(PXCCapture::STREAM_TYPE_COLOR, 640, 480);
psm->EnableStream(PXCCapture::STREAM_TYPE_DEPTH, 640, 480);
// initialize the PXCSenseManager
if (psm->Init() != PXC_STATUS_NO_ERROR) return 2;
PXCImage *colorIm, *depthIm;
for (int i = 0; /*i<MAX_FRAMES*/; i++) {
// This function blocks until all streams are ready (depth and color)
// if false streams will be unaligned
if (psm->AcquireFrame(true)<PXC_STATUS_NO_ERROR) break;
// retrieve all available image samples
PXCCapture::Sample *sample = psm->QuerySample();
// retrieve the image or frame by type from the sample
colorIm = sample->color;
depthIm = sample->depth;
// render the frame
renderColor.RenderFrame(colorIm);
renderDepth.RenderFrame(depthIm);
// release or unlock the current frame to fetch the next frame
psm->ReleaseFrame();
}
// close the last opened streams and release any session and processing module instances
psm->Release();
return 0;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)