I would change your code along the lines of:
#
unsigned char *buff = image.bits();
while(1)
{
memcpy(buff,(uchar*)deviceAccessTool.nextFrame(),/*size in bytes of the frame*/); //this should be faster then allocating each time a new image
image = myprocessingcode(image); //if you want this to fit in 25hz, then you should take in consideration that grabbing and processing should not be longer then 40ms!
myPixmap = myPixmap.fromImage(image);
myLabel.setPixmap(myPixmap);
window.repaint();
}
#
image = QImage( width, height, QImage::Format_Rgb32);
unsigned char *buff = image.bits();
while(1)
{
memcpy(buff,(uchar*)deviceAccessTool.nextFrame(),/*size in bytes of the frame*/); //this should be faster then allocating each time a new image
image = myprocessingcode(image); //if you want this to fit in 25hz, then you should take in consideration that grabbing and processing should not be longer then 40ms!
myPixmap = myPixmap.fromImage(image);
myLabel.setPixmap(myPixmap);
window.repaint();
}
To copy to clipboard, switch view to plain text mode
Also since I dont have much experiance with qt4, I would suggest to try (and can't say this IS better) the following:
instead of :
myPixmap = myPixmap.fromImage(image);
myLabel.setPixmap(myPixmap);
myPixmap = myPixmap.fromImage(image);
myLabel.setPixmap(myPixmap);
To copy to clipboard, switch view to plain text mode
I would try to use the QPainter with a QImage as paint device (one of the new Qt4 fetures, it could be faster then setPixmap()):
//somewhere declared: QPainter painter(&myLabel);
painter.drawImage(maLabel.rect(),image,image.rect());
//somewhere declared: QPainter painter(&myLabel);
painter.drawImage(maLabel.rect(),image,image.rect());
To copy to clipboard, switch view to plain text mode
So put togeather it would look somthing like:
unsigned char *buff = image.bits();
while(1)
{
memcpy(buff,(uchar*)deviceAccessTool.nextFrame(),/*size in bytes of the frame*/);
image = myprocessingcode(image); //if you want this to fit in 25hz, then you should take in consideration that grabbing and processing should not be longer then 40ms!
painter.drawImage(maLabel.rect(),image,image.rect());
}
image = QImage( width, height, QImage::Format_Rgb32);
unsigned char *buff = image.bits();
QPainter painter(&myLabel);
while(1)
{
memcpy(buff,(uchar*)deviceAccessTool.nextFrame(),/*size in bytes of the frame*/);
image = myprocessingcode(image); //if you want this to fit in 25hz, then you should take in consideration that grabbing and processing should not be longer then 40ms!
painter.drawImage(maLabel.rect(),image,image.rect());
}
To copy to clipboard, switch view to plain text mode
Please note, under Qt3 I can show you how to do a video stream in a crossplatform way, but under Qt4, this code is only a suggestion I think you shoud try, and take in consideration I didn't test it!
Since drawing in Qt4 is done only in a paint event, this all needs to be in a paint event...
Any comments from you Qt4 experts?
Bookmarks