summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_HT
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-01-18 23:44:36 +0000
committerStanislaw Halik <sthalik@misaki.pl>2013-01-18 23:44:36 +0000
commite467346fef4402c1f30372bc8926924a23f4e22a (patch)
tree517c453984921ac250adfad961413dc30be48889 /FTNoIR_Tracker_HT
parent3c848addfcdd70986a12e328655f3272d392e784 (diff)
Reduce mutex contention
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@214 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FTNoIR_Tracker_HT')
-rw-r--r--FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp b/FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp
index 0b9c923f..8c88363b 100644
--- a/FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp
+++ b/FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp
@@ -138,10 +138,10 @@ bool Tracker::GiveHeadPoseData(THeadPoseData* data)
{
bool ret = false;
- if (WaitForSingleObject(hMutex, INFINITE) == WAIT_OBJECT_0)
+ if (WaitForSingleObject(hMutex, 100) == WAIT_OBJECT_0)
{
shm->timer = 0;
- if (WaitForSingleObject(videoWidget->hMutex, INFINITE) == WAIT_OBJECT_0)
+ if (WaitForSingleObject(videoWidget->hMutex, 100) == WAIT_OBJECT_0)
{
memcpy(&videoWidget->videoFrame, &shm->frame, sizeof(ht_video_t));
ReleaseMutex(videoWidget->hMutex);
@@ -182,16 +182,23 @@ VideoWidget::~VideoWidget()
void VideoWidget::paintEvent(QPaintEvent *e)
{
- if (WaitForSingleObject(hMutex, INFINITE) == WAIT_OBJECT_0)
+ uchar* data = NULL;
+ if (WaitForSingleObject(hMutex, 100) == WAIT_OBJECT_0)
{
if (videoFrame.width > 0)
{
- QImage image((uchar*) videoFrame.frame, videoFrame.width, videoFrame.height, QImage::Format_RGB888);
- QPainter painter(this);
- painter.drawPixmap(e->rect(), QPixmap::fromImage(image.rgbSwapped()).scaled(WIDGET_WIDTH, WIDGET_HEIGHT, Qt::AspectRatioMode::KeepAspectRatioByExpanding), e->rect());
+ data = new uchar[videoFrame.width * videoFrame.height * 3];
+ memcpy(data, videoFrame.frame, videoFrame.width * videoFrame.height * 3);
}
ReleaseMutex(hMutex);
}
+ if (data)
+ {
+ QImage image((uchar*) data, videoFrame.width, videoFrame.height, QImage::Format_RGB888);
+ QPainter painter(this);
+ painter.drawPixmap(e->rect(), QPixmap::fromImage(image.rgbSwapped()).scaled(WIDGET_WIDTH, WIDGET_HEIGHT, Qt::AspectRatioMode::KeepAspectRatioByExpanding), e->rect());
+ delete[] data;
+ }
}
//-----------------------------------------------------------------------------