Hmmm.
But then my mutex locking is messing up !!!
Here's the code.
wrokerthread:
void imageThread::run()
{
while(!stopped)
{
{
mutex.lock();
// QMutexLocker locker(&mutex);
qDebug("imageThread::run ::: locked");
memset(buffer, 0, 320*240*2);
pointer1 = livePreview();
mutex.unlock();
qDebug("imageThread::run ::: unlocked");
emit frameRecieved(pointer1);
}
}
}
void imageThread::run()
{
while(!stopped)
{
{
mutex.lock();
// QMutexLocker locker(&mutex);
qDebug("imageThread::run ::: locked");
memset(buffer, 0, 320*240*2);
pointer1 = livePreview();
mutex.unlock();
qDebug("imageThread::run ::: unlocked");
emit frameRecieved(pointer1);
}
}
}
To copy to clipboard, switch view to plain text mode
GUi thread SLot:
void image::frameUpdate(unsigned char *buffer)
{
mutex.lock();
qDebug("image::frameUpdate ::: locked");
// QMutexLocker locker(&mutex);
mutex.unlock();
qDebug("image::frameUpdate ::: unlocked");
ui
->label_image
->setPixmap
(QPixmap::fromImage(image
).
scaled(ui
->label_image
->width
(), ui
->label_image
->height
(), Qt
::IgnoreAspectRatio));
ui->label_image->update();
}
void image::frameUpdate(unsigned char *buffer)
{
mutex.lock();
qDebug("image::frameUpdate ::: locked");
// QMutexLocker locker(&mutex);
QImage image(buffer, 320, 240, QImage::Format_RGB16);
mutex.unlock();
qDebug("image::frameUpdate ::: unlocked");
ui->label_image->setPixmap(QPixmap::fromImage(image).scaled(ui->label_image->width(), ui->label_image->height(), Qt::IgnoreAspectRatio));
ui->label_image->update();
}
To copy to clipboard, switch view to plain text mode
I have connected the signal and slot and the mutex is global.
But the locking unlocking prints are ideal.
Bookmarks