Hello,
We have a program that captures video data and we want to be able to render that data (from OpenCV's IplImage format) into a QGraphicsScene.
Currently we can get that conversion by going through a QImage which involves a fair amount of additional data movement. Unfortunately this method also causes threading issues (under Mac OS X) where we get an error "QPixmap: It is not safe to use pixmaps outside the GUI thread". We don't see this warning running on Windows. The rendering of the QGraphicsPixmapItem is done with signaling to allow the GUI thread to add the updated tile to the QGraphicsScene.
Right now we have a class that inherits from QGraphicsPixmapItem and the snippet below converts from an IplImage to a QImage to a QPixmap into our QGraphicsPixmapItem subclass. (Horribly inefficient!)
unsigned char* qImageBuffer = (unsigned char*)(ipl_img->imageData);
QImage* temp
= new QImage((const unsigned char*)qImageBuffer, ipl_img
->width, ipl_img
->height, ipl_img
->widthStep,
QImage::Format_RGB888);
TEMP_pixmap.convertFromImage( *temp );
this->setPixmap( TEMP_pixmap );
unsigned char* qImageBuffer = (unsigned char*)(ipl_img->imageData);
QImage* temp = new QImage((const unsigned char*)qImageBuffer, ipl_img->width, ipl_img->height, ipl_img->widthStep, QImage::Format_RGB888);
QPixmap TEMP_pixmap;
TEMP_pixmap.convertFromImage( *temp );
this->setPixmap( TEMP_pixmap );
To copy to clipboard, switch view to plain text mode
My question is if anyone knows how we might be able to write a direct conversion into a QPixmap or QGraphicsPixmapItem (from any basic image buffer)? Preferably this would be thread-safe under Windows & Mac OS even if we do this processing outside the GUI thread.
Thanks in advance.
Bookmarks