summaryrefslogtreecommitdiffhomepage
path: root/tracker-kinect-face
diff options
context:
space:
mode:
authorStéphane Lenclud <github@lenclud.com>2019-02-03 15:20:36 +0100
committerStéphane Lenclud <github@lenclud.com>2019-02-07 13:24:14 +0100
commit1f82111bbee522c4d31372f9f64b903a08ccc11e (patch)
treef293e143d34b668f80689619b54911175682d47a /tracker-kinect-face
parent4508be24ef4adc4dac0c40ef316b07da75765b77 (diff)
Kinect: Don't do video preview when not needed.
Diffstat (limited to 'tracker-kinect-face')
-rw-r--r--tracker-kinect-face/kinect_face_tracker.cpp76
1 files changed, 43 insertions, 33 deletions
diff --git a/tracker-kinect-face/kinect_face_tracker.cpp b/tracker-kinect-face/kinect_face_tracker.cpp
index ab568f1e..5663de0f 100644
--- a/tracker-kinect-face/kinect_face_tracker.cpp
+++ b/tracker-kinect-face/kinect_face_tracker.cpp
@@ -5,6 +5,7 @@
#include <QLayout>
#include <QPainter>
+#include "compat/check-visible.hpp"
///
@@ -308,6 +309,8 @@ HRESULT KinectFaceTracker::InitializeDefaultSensor()
return hr;
}
+
+
/// <summary>
/// Main processing function
/// </summary>
@@ -355,48 +358,55 @@ void KinectFaceTracker::Update()
if (SUCCEEDED(hr))
{
- // Fetch color buffer
- if (imageFormat == ColorImageFormat_Rgba)
- {
- hr = pColorFrame->AccessRawUnderlyingBuffer(&nBufferSize, reinterpret_cast<BYTE**>(&pBuffer));
- }
- else if (m_pColorRGBX)
- {
- pBuffer = m_pColorRGBX;
- nBufferSize = cColorWidth * cColorHeight * sizeof(RGBQUAD);
- hr = pColorFrame->CopyConvertedFrameDataToArray(nBufferSize, reinterpret_cast<BYTE*>(pBuffer), ColorImageFormat_Rgba);
- }
- else
- {
- hr = E_FAIL;
- }
-
- }
-
- if (SUCCEEDED(hr))
- {
//DrawStreams(nTime, pBuffer, nWidth, nHeight);
ProcessFaces();
}
- if (SUCCEEDED(hr))
- {
- // Setup our image
- QImage image((const unsigned char*)pBuffer, cColorWidth, cColorHeight, sizeof(RGBQUAD)*cColorWidth, QImage::Format_RGBA8888);
- if (IsValidRect(iFaceBox))
+ if (check_is_visible())
+ {
+ //OutputDebugStringA("Widget visible!\n");
+ // If our widget is visible we feed it our frame
+ if (SUCCEEDED(hr))
{
- // Draw our face bounding box
- QPainter painter(&image);
- painter.setBrush(Qt::NoBrush);
- painter.setPen(QPen(Qt::red, 8));
- painter.drawRect(iFaceBox.Left, iFaceBox.Top, iFaceBox.Right - iFaceBox.Left, iFaceBox.Bottom - iFaceBox.Top);
- bool bEnd = painter.end();
+ // Fetch color buffer
+ if (imageFormat == ColorImageFormat_Rgba)
+ {
+ hr = pColorFrame->AccessRawUnderlyingBuffer(&nBufferSize, reinterpret_cast<BYTE**>(&pBuffer));
+ }
+ else if (m_pColorRGBX)
+ {
+ pBuffer = m_pColorRGBX;
+ nBufferSize = cColorWidth * cColorHeight * sizeof(RGBQUAD);
+ hr = pColorFrame->CopyConvertedFrameDataToArray(nBufferSize, reinterpret_cast<BYTE*>(pBuffer), ColorImageFormat_Rgba);
+ }
+ else
+ {
+ hr = E_FAIL;
+ }
+
+ }
+
+ if (SUCCEEDED(hr))
+ {
+ // Setup our image
+ QImage image((const unsigned char*)pBuffer, cColorWidth, cColorHeight, sizeof(RGBQUAD)*cColorWidth, QImage::Format_RGBA8888);
+ if (IsValidRect(iFaceBox))
+ {
+ // Draw our face bounding box
+ QPainter painter(&image);
+ painter.setBrush(Qt::NoBrush);
+ painter.setPen(QPen(Qt::red, 8));
+ painter.drawRect(iFaceBox.Left, iFaceBox.Top, iFaceBox.Right - iFaceBox.Left, iFaceBox.Bottom - iFaceBox.Top);
+ bool bEnd = painter.end();
+ }
+
+ // Update our video preview
+ iVideoWidget->update_image(image);
}
- // Update our video preview
- iVideoWidget->update_image(image);
}
+
SafeRelease(pFrameDescription);
}