Reputation: 1
I play real-time video streams on a 2DTexture node in OSG,
image->setPixelBufferObject(new osg::PixelBufferObject(image.get()));
pTexture2D->setDataVariance(osg::Object::DYNAMIC);
pTexture2D->setImage (image.get());
and use two other threads for video parsing (opencv) and updating (update_image).
cv::VideoCapture cap;
cap.open(_url.toStdString());//RTSP
while(1)
{
cap.read(frame);
frame.copyTo(*_frame);
}
_image->setImage(_frame->cols, _frame->rows, 1, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE, frameCalibration.data, osg::Image::NO_DELETE, 1);
I can find that the frames obtained by opencv and those drawn in shared memory(_image) are both real-time and frequency controllable(maybe not?). However, the actual displayed video has a frame rate of only 2 on a poor CPU (i7-10510U) and can reach 14 on a high-performance CPU (i7-12700).
I have tried to optimize this program but failed,The methods to try include: using the dirty() function to force Image data updates and forcing qtwidget update(); Adjust thread affinity (even on 10510U CPU, it still occupies less than 50%)。
so here's the problem, why CPU keep running in half load but the program seems be forced to run in a low performance way.
how can i manage this.
Upvotes: 0
Views: 21