diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-12-18 20:41:49 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-12-18 20:46:49 +0100 |
commit | 377202f037aeff97481252bdc7856cfacf939b66 (patch) | |
tree | da69ce1aafdab9e13ad4a7c086dfd55a3284ab23 /tracker-pt | |
parent | 29b43593962137f27abac7ca4d7f86a3e6d81dd2 (diff) |
tracker/pt: optimize widget
Diffstat (limited to 'tracker-pt')
-rw-r--r-- | tracker-pt/pt_video_widget.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/tracker-pt/pt_video_widget.cpp b/tracker-pt/pt_video_widget.cpp index cbb7c268..860d0a77 100644 --- a/tracker-pt/pt_video_widget.cpp +++ b/tracker-pt/pt_video_widget.cpp @@ -23,33 +23,29 @@ void PTVideoWidget::update_image(const cv::Mat& frame) void PTVideoWidget::update_and_repaint() { - QImage qframe; { QMutexLocker foo(&mtx); if (_frame.empty() || !freshp) return; - qframe = QImage(_frame.cols, _frame.rows, QImage::Format_RGB888); + texture = QImage(_frame.cols, _frame.rows, QImage::Format_RGB888); freshp = false; - uchar* data = qframe.bits(); - const int pitch = qframe.bytesPerLine(); - unsigned char *input = (unsigned char*) _frame.data; + uchar* data = texture.bits(); const int chans = _frame.channels(); + const int pitch = texture.bytesPerLine(); for (int y = 0; y < _frame.rows; y++) { - const int step = y * _frame.step; - const int pitch_ = y * pitch; + unsigned char* dest = data + pitch * y; + const unsigned char* ln = _frame.ptr(y); for (int x = 0; x < _frame.cols; x++) { - data[pitch_ + x * 3 + 0] = input[step + x * chans + 2]; - data[pitch_ + x * 3 + 1] = input[step + x * chans + 1]; - data[pitch_ + x * 3 + 2] = input[step + x * chans + 0]; + const int idx = x * chans; + const int x_ = x * 3; + dest[x_ + 0] = ln[idx + 2]; + dest[x_ + 1] = ln[idx + 1]; + dest[x_ + 2] = ln[idx + 0]; } } } - qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); - { - QMutexLocker foo(&mtx); - texture = qframe; - } + texture = texture.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); update(); } |