201 MITK_ERROR <<
"Unable to initialize MultiFrameReader";
204 IMultiSourceFrame* pMultiSourceFrame =
nullptr;
205 IDepthFrame* pDepthFrame =
nullptr;
209 static DWORD lastTime = 0;
210 DWORD currentTime = GetTickCount();
212 if(
unsigned int(currentTime - lastTime) > 33 )
215 lastTime = currentTime;
220 IDepthFrameReference* pDepthFrameReference =
nullptr;
222 hr = pMultiSourceFrame->get_DepthFrameReference(&pDepthFrameReference);
225 hr = pDepthFrameReference->AcquireFrame(&pDepthFrame);
232 UINT nDepthBufferSize = 0;
233 UINT16 *pDepthBuffer =
nullptr;
237 hr = pDepthFrame->AccessUnderlyingBuffer(&nDepthBufferSize, &pDepthBuffer);
246 textureCoordinates->SetNumberOfComponents(2);
247 textureCoordinates->Allocate(pointCount);
254 vertices->InsertNextCell(1);
255 vertices->InsertCellPoint(
id);
256 distances[i] =
static_cast<float>(*pDepthBuffer);
261 int colorInDepthX = (int)(floor(colorPoint.X + 0.5));
262 int colorInDepthY = (int)(floor(colorPoint.Y + 0.5));
268 if ( colorInDepthX >= 0 && colorInDepthX < d->m_RGBCaptureWidth && colorInDepthY >= 0 && colorInDepthY < d->m_RGBCaptureHeight )
270 textureCoordinates->InsertTuple2(
id, xNorm, yNorm);
276 d->
m_PolyData->GetPointData()->SetTCoords(textureCoordinates);
280 MITK_ERROR <<
"AccessUnderlyingBuffer";
286 if( hr != -1 && !SUCCEEDED(hr) )
290 MITK_DEBUG <<
"HR result false in KinectV2Controller::GetDistances()";
299 MITK_ERROR <<
"Unable to initialize MultiFrameReader";
302 IMultiSourceFrame* pMultiSourceFrame =
nullptr;
303 IColorFrame* pColorFrame =
nullptr;
307 static DWORD lastTime = 0;
308 DWORD currentTime = GetTickCount();
310 if(
unsigned int(currentTime - lastTime) > 33 )
313 lastTime = currentTime;
316 ColorImageFormat imageFormat = ColorImageFormat_None;
317 UINT nColorBufferSize = 0;
318 RGBQUAD *pColorBuffer =
nullptr;
322 hr = pColorFrame->get_RawColorImageFormat(&imageFormat);
327 if (imageFormat == ColorImageFormat_Bgra)
329 hr = pColorFrame->AccessRawUnderlyingBuffer(&nColorBufferSize,
reinterpret_cast<BYTE**
>(&pColorBuffer));
335 hr = pColorFrame->CopyConvertedFrameDataToArray(nColorBufferSize,
reinterpret_cast<BYTE*
>(pColorBuffer), ColorImageFormat_Bgra);
346 rgb[i+0] = pColorBuffer->rgbRed;
347 rgb[i+1] = pColorBuffer->rgbGreen;
348 rgb[i+2] = pColorBuffer->rgbBlue;
356 if( hr != -1 && !SUCCEEDED(hr) )
360 MITK_DEBUG <<
"HR result false in KinectV2Controller::GetRgb()";
368 MITK_ERROR <<
"Unable to initialize MultiFrameReader";
372 IMultiSourceFrame* pMultiSourceFrame =
nullptr;
373 IDepthFrame* pDepthFrame =
nullptr;
374 IColorFrame* pColorFrame =
nullptr;
375 IInfraredFrame* pInfraRedFrame =
nullptr;
379 static DWORD lastTime = 0;
380 DWORD currentTime = GetTickCount();
382 if(
unsigned int(currentTime - lastTime) > 33 )
385 lastTime = currentTime;
390 IDepthFrameReference* pDepthFrameReference =
nullptr;
392 hr = pMultiSourceFrame->get_DepthFrameReference(&pDepthFrameReference);
395 hr = pDepthFrameReference->AcquireFrame(&pDepthFrame);
402 IColorFrameReference* pColorFrameReference =
nullptr;
404 hr = pMultiSourceFrame->get_ColorFrameReference(&pColorFrameReference);
407 hr = pColorFrameReference->AcquireFrame(&pColorFrame);
414 IInfraredFrameReference* pInfraredFrameReference =
nullptr;
416 hr = pMultiSourceFrame->get_InfraredFrameReference(&pInfraredFrameReference);
419 hr = pInfraredFrameReference->AcquireFrame(&pInfraRedFrame);
426 UINT nDepthBufferSize = 0;
427 UINT16 *pDepthBuffer =
nullptr;
428 UINT16 *pInfraRedBuffer =
nullptr;
430 ColorImageFormat imageFormat = ColorImageFormat_None;
431 UINT nColorBufferSize = 0;
432 RGBQUAD *pColorBuffer =
nullptr;
436 hr = pDepthFrame->AccessUnderlyingBuffer(&nDepthBufferSize, &pDepthBuffer);
440 hr = pInfraRedFrame->AccessUnderlyingBuffer(&nDepthBufferSize, &pInfraRedBuffer);
450 const double meterfactor = 1000.0;
454 vertexIdList->Allocate(pointCount);
455 vertexIdList->SetNumberOfIds(pointCount);
456 for(
unsigned int i = 0; i < pointCount; ++i)
458 vertexIdList->SetId(i, 0);
461 std::vector<bool> isPointValid;
462 isPointValid.resize(pointCount);
465 vertexIdList->Allocate(pointCount);
466 vertexIdList->SetNumberOfIds(pointCount);
467 textureCoordinates->SetNumberOfComponents(2);
468 textureCoordinates->Allocate(pointCount);
479 distances[inverseid] =
static_cast<float>(*pDepthBuffer);
480 amplitudes[inverseid] =
static_cast<float>(*pInfraRedBuffer);
486 isPointValid[pixelID] =
false;
490 isPointValid[pixelID] =
true;
503 if((i >= 1) && (j >= 1))
517 vtkIdType xy = pixelID;
518 vtkIdType x_1y = pixelID-1;
520 vtkIdType x_1y_1 = xy_1-1;
523 vtkIdType xyV = vertexIdList->GetId(xy);
524 vtkIdType x_1yV = vertexIdList->GetId(x_1y);
525 vtkIdType xy_1V = vertexIdList->GetId(xy_1);
526 vtkIdType x_1y_1V = vertexIdList->GetId(x_1y_1);
528 if (isPointValid[xy]&&isPointValid[x_1y]&&isPointValid[x_1y_1]&&isPointValid[xy_1])
530 double pointXY[3], pointX_1Y[3], pointXY_1[3], pointX_1Y_1[3];
532 points->GetPoint(xyV, pointXY);
533 points->GetPoint(x_1yV, pointX_1Y);
534 points->GetPoint(xy_1V, pointXY_1);
535 points->GetPoint(x_1y_1V, pointX_1Y_1);
543 polys->InsertNextCell(3);
544 polys->InsertCellPoint(x_1yV);
545 polys->InsertCellPoint(xyV);
546 polys->InsertCellPoint(x_1y_1V);
548 polys->InsertNextCell(3);
549 polys->InsertCellPoint(x_1y_1V);
550 polys->InsertCellPoint(xyV);
551 polys->InsertCellPoint(xy_1V);
556 vertices->InsertNextCell(1);
557 vertices->InsertCellPoint(xyV);
565 vertices->InsertNextCell(1);
566 vertices->InsertCellPoint(vertexIdList->GetId(pixelID));
571 int colorInDepthX = (int)(floor(colorPoint.X + 0.5));
572 int colorInDepthY = (int)(floor(colorPoint.Y + 0.5));
578 if ( colorInDepthX >= 0 && colorInDepthX < d->m_RGBCaptureWidth && colorInDepthY >= 0 && colorInDepthY < d->m_RGBCaptureHeight )
580 textureCoordinates->InsertTuple2(vertexIdList->GetId(pixelID), xNorm, yNorm);
584 textureCoordinates->InsertTuple2(vertexIdList->GetId(pixelID), 0, 0);
594 d->
m_PolyData->GetPointData()->SetTCoords(textureCoordinates);
598 MITK_ERROR <<
"AccessUnderlyingBuffer";
604 hr = pColorFrame->get_RawColorImageFormat(&imageFormat);
609 if (imageFormat == ColorImageFormat_Bgra)
611 hr = pColorFrame->AccessRawUnderlyingBuffer(&nColorBufferSize,
reinterpret_cast<BYTE**
>(&pColorBuffer));
617 hr = pColorFrame->CopyConvertedFrameDataToArray(nColorBufferSize,
reinterpret_cast<BYTE*
>(pColorBuffer), ColorImageFormat_Bgra);
633 rgb[
id+0] = pColorBuffer->rgbRed;
634 rgb[
id+1] = pColorBuffer->rgbGreen;
635 rgb[
id+2] = pColorBuffer->rgbBlue;
648 if( hr != -1 && !SUCCEEDED(hr) )
652 MITK_DEBUG <<
"HR result false in KinectV2Controller::GetAllData()";