Josh, I'm curious how this worked out for you? Were you able to get the CPU load down?
On Mon, Dec 12, 2016 at 5:03 PM Joshua Grauman <jnf...@grauman.com> wrote: > Brilliant! How did I miss that constructor?! > > Josh > > > Hi,Why not construct the image object from the shared memory buffer to > begin with? Then lock the sm while drawing. > > Look for example this constructor: > http://doc.qt.io/qt-5/qimage.html#QImage-3 > > > > On Mon, Dec 12, 2016 at 11:45 PM, Joshua Grauman <jnf...@grauman.com> > wrote: > > Hello all, > > > > I have been able to generate a screen capture of my program by > rendering a window into a QImage at 30fps (called from QTimer), and then > copying the QImage to shared memory > > (QSharedMemory) where another program grabs the frames and outputs > them to ffmpeg. It all works great. > > > > However, my cpu is barely keeping up if I do much on my app. > > > > One of the ways I thought of to speed it up is to avoid the memcpy > from the QImage (img) to QSharedMemory (sharedMemory) by deriving from > QImage to a new class > > (QSharedMemoryImage) which allocates its image data in shared > memory to begin with so that the window->render() function renders the > window right into shared memory so the copy > > isn't necessary. QImage was a bit too complex for me to figure out > how to do this. > > > > For you experts, is this possible? How hard would it be? > > > > Here's the relevant code in the QTimer: > > > > window->render(&img, QPoint(), QRegion(), QWidget::DrawChildren); > > sharedMemory.lock(); > > char *to = (char*)sharedMemory.data(); > > const unsigned char *from = img.constBits(); > > memcpy(to, from, sharedMemory.size()); > > sharedMemory.unlock(); > > > > Josh > > _______________________________________________ > > Interest mailing list > > Interest@qt-project.org > > http://lists.qt-project.org/mailman/listinfo/interest > > > > > > > >_______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > -- Phi|ip
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest