
Originally Posted by
superutsav
I should also mention what i'm using right now, which i'm sure is really horrible, inefficient code, and which keeps the processor busy in a loop, hence making it impossible for me to close the app without killing the process:
You have to kill the process because of the "while(1) {}" infinite loop. You have to give Qt a chance to handle events. So for testing I would add a qapp->processEvents() call to the loop.

Originally Posted by
superutsav
layout.addWidget(myLabel);
window.setLayout(&layout);
while(1)
{
image
= QImage::QImage((uchar
*)deviceAccessTool.
nextFrame(), width, height,
QImage::Format_Rgb32);
image = myprocessingcode(image);
myPixmap = myPixmap.fromImage(image);
myLabel.setPixmap(myPixmap);
window.repaint();
}
QPixmap myPixmap;
QImage image;
QLabel myLabel;
QWidget window;
QHBoxLayout layout;
layout.addWidget(myLabel);
window.setLayout(&layout);
while(1)
{
image = QImage::QImage((uchar*)deviceAccessTool.nextFrame(), width, height, QImage::Format_Rgb32);
image = myprocessingcode(image);
myPixmap = myPixmap.fromImage(image);
myLabel.setPixmap(myPixmap);
window.repaint();
}
To copy to clipboard, switch view to plain text mode
My idea would be to subclass QWidget and override the paintEvent() method.
following code untested!!
void VideoWidget::paintEvent()
{
QImage image
((uchar
*)deviceAccessTool.
nextFrame(), width, height,
QImage::Format_Rgb32);
myprocessingcode(&image);
p.drawImage (image.rect(), image);
}
void VideoWidget::paintEvent()
{
QPainter p( this );
QImage image((uchar*)deviceAccessTool.nextFrame(), width, height, QImage::Format_Rgb32);
myprocessingcode(&image);
p.drawImage (image.rect(), image);
}
To copy to clipboard, switch view to plain text mode
and somewhere else maybe....
{
deviceAccessTool.loadNextFrame();
connect(deviceAccessTool, SIGNAL(nextFrameAvailable()),
videoWidget, SLOT(update()));
}
{
deviceAccessTool.loadNextFrame();
connect(deviceAccessTool, SIGNAL(nextFrameAvailable()),
videoWidget, SLOT(update()));
}
To copy to clipboard, switch view to plain text mode
Bookmarks