本文整理汇总了C++中IDepthFrameSource::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IDepthFrameSource::Release方法的具体用法?C++ IDepthFrameSource::Release怎么用?C++ IDepthFrameSource::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDepthFrameSource
的用法示例。
在下文中一共展示了IDepthFrameSource::Release方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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];
}
}
示例3: if
IFrameDescription* Kinect2StreamImpl::getFrameDescription(OniSensorType sensorType)
{
if (!m_pKinectSensor) {
return NULL;
}
IFrameDescription* frameDescription = NULL;
if (sensorType == ONI_SENSOR_COLOR) {
IColorFrameSource* frameSource = NULL;
HRESULT hr = m_pKinectSensor->get_ColorFrameSource(&frameSource);
if (SUCCEEDED(hr)) {
hr = frameSource->get_FrameDescription(&frameDescription);
if (FAILED(hr) && frameDescription) {
frameDescription->Release();
frameDescription = NULL;
}
}
if (frameSource) {
frameSource->Release();
}
}
else if (sensorType == ONI_SENSOR_DEPTH) {
IDepthFrameSource* frameSource = NULL;
HRESULT hr = m_pKinectSensor->get_DepthFrameSource(&frameSource);
if (SUCCEEDED(hr)) {
hr = frameSource->get_FrameDescription(&frameDescription);
if (FAILED(hr) && frameDescription) {
frameDescription->Release();
frameDescription = NULL;
}
}
if (frameSource) {
frameSource->Release();
}
}
else { // ONI_SENSOR_IR
IInfraredFrameSource* frameSource = NULL;
HRESULT hr = m_pKinectSensor->get_InfraredFrameSource(&frameSource);
if (SUCCEEDED(hr)) {
hr = frameSource->get_FrameDescription(&frameDescription);
if (FAILED(hr) && frameDescription) {
frameDescription->Release();
frameDescription = NULL;
}
}
if (frameSource) {
frameSource->Release();
}
}
return frameDescription;
}
示例4: 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;
}
示例5: 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;
//.........这里部分代码省略.........
示例6: 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) {
//.........这里部分代码省略.........
示例7: main
int main(int argc, char** argv)
{
int first_time = 0;
Size screen_size(1440, 900);//the dst image size,e.g.100x100
Scalar text_color = Scalar(0, 255, 0);
Scalar text_color2 = Scalar(0, 255, 255);
Scalar text_color3 = Scalar(0, 0, 255);
inhaler_coach coach;
coach.control = 0;
thread mThread(test_func, &coach);
// 1a. Get Kinect Sensor
cout << "Try to get default sensor" << endl;
IKinectSensor* pSensor = nullptr;
if (GetDefaultKinectSensor(&pSensor) != S_OK)
{
cerr << "Get Sensor failed" << endl;
return -1;
}
// 1b. Open sensor
cout << "Try to open sensor" << endl;
if (pSensor->Open() != S_OK)
{
cerr << "Can't open sensor" << endl;
return -1;
}
// 2. Color Related code
IColorFrameReader* pColorFrameReader = nullptr;
cv::Mat mColorImg;
UINT uBufferSize = 0;
UINT uColorPointNum = 0;
int iWidth = 0;
int iHeight = 0;
{
// 2a. Get color frame source
cout << "Try to get color source" << endl;
IColorFrameSource* pFrameSource = nullptr;
if (pSensor->get_ColorFrameSource(&pFrameSource) != S_OK)
{
cerr << "Can't get color frame source" << endl;
return -1;
}
// 2b. Get frame description
cout << "get color frame description" << endl;
IFrameDescription* pFrameDescription = nullptr;
if (pFrameSource->get_FrameDescription(&pFrameDescription) == S_OK)
{
pFrameDescription->get_Width(&iWidth);
pFrameDescription->get_Height(&iHeight);
}
pFrameDescription->Release();
pFrameDescription = nullptr;
// 2c. 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;
}
// 2d. release Frame source
cout << "Release frame source" << endl;
pFrameSource->Release();
pFrameSource = nullptr;
// Prepare OpenCV data
mColorImg = cv::Mat(iHeight, iWidth, CV_8UC4);
uBufferSize = iHeight * iWidth * 4 * sizeof(BYTE);
uColorPointNum = iHeight * iWidth;
}
// 3. Depth related code
IDepthFrameReader* pDepthFrameReader = nullptr;
UINT uDepthPointNum = 0;
int iDepthWidth = 0, iDepthHeight = 0;
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)
{
pFrameDescription->get_Width(&iDepthWidth);
pFrameDescription->get_Height(&iDepthHeight);
uDepthPointNum = iDepthWidth * iDepthHeight;
}
//.........这里部分代码省略.........