From 21859b276f13d4a81c56c7b833abe16c68201a46 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Feb 2015 20:23:59 +0000 Subject: [PATCH 1/9] Add new open stream function --- lib/PlaYUVerStream.cpp | 26 ++++++++++++++++++++++++++ lib/PlaYUVerStream.h | 1 + 2 files changed, 27 insertions(+) diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 7acda98..80b7529 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -155,6 +155,32 @@ PlaYUVerStream::~PlaYUVerStream() close(); } +Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::string input_format_name, UInt frame_rate, Bool bInput ) +{ + UInt width; + UInt height; + Int input_format = -1; + + sscanf( resolution.c_str(), "%ux%u", &width, &height ); + if( width <= 0 || height <= 0 ) + { + return false; + } + for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) + { + if( PlaYUVerFrame::supportedPixelFormatListNames()[i] == input_format_name ) + { + input_format = i; + break; + } + } + if( width > 0 && height > 0 && input_format >= 0 ) + { + return open( filename, width, height, input_format, frame_rate, bInput ); + } + return false; +} + Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput ) { if( m_bInit ) diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index 565d005..09245ef 100644 --- a/lib/PlaYUVerStream.h +++ b/lib/PlaYUVerStream.h @@ -115,6 +115,7 @@ public: END_OF_SEQ, }; + Bool open( std::string filename, std::string resolution, std::string input_format, UInt frame_rate, Bool bInput = true ); Bool open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput = true ); Void close(); From 77a6247addafc460260053ee74050fec02ce7f44 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Feb 2015 20:44:35 +0000 Subject: [PATCH 2/9] Use opencv to save images --- lib/PlaYUVerStream.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 80b7529..2d5d1c6 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -27,11 +27,12 @@ #include #include "LibMemory.h" #include "PlaYUVerStream.h" -#include -#include #ifdef USE_FFMPEG #include "LibAvContextHandle.h" #endif +#ifdef USE_OPENCV +#include +#endif namespace plaYUVer { @@ -555,7 +556,6 @@ Bool PlaYUVerStream::saveFrame( const std::string& filename ) Bool PlaYUVerStream::saveFrame( const std::string& filename, PlaYUVerFrame *saveFrame ) { - QString qtString = QString::fromStdString( filename ); Int iFileFormat = INVALID_HANDLER; std::string fmtExt; @@ -585,12 +585,23 @@ Bool PlaYUVerStream::saveFrame( const std::string& filename, PlaYUVerFrame *save auxFrameStream.close(); return true; } +#if 0 else { saveFrame->fillRGBBuffer(); QImage qimg = QImage( saveFrame->getRGBBuffer(), saveFrame->getWidth(), saveFrame->getHeight(), QImage::Format_RGB32 ); return qimg.save( qtString ); } +#endif +#ifdef USE_OPENCV + else + { + cv::Mat* image; + saveFrame->getCvMat( (Void**)&image ); + return cv::imwrite( filename, *image ); + } + +#endif } return false; } From 60e3d37d02d586b8bc1c489b41f4f482190653e6 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Feb 2015 21:34:32 +0000 Subject: [PATCH 3/9] Add function to convert a string to lowercase --- lib/PlaYUVerDefs.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/PlaYUVerDefs.h b/lib/PlaYUVerDefs.h index 26c6516..2976e92 100644 --- a/lib/PlaYUVerDefs.h +++ b/lib/PlaYUVerDefs.h @@ -26,6 +26,7 @@ #define __TYPEDEF_H__ #include +#include namespace plaYUVer { @@ -116,6 +117,13 @@ enum RGBcomponent COLOR_A, }; +inline std::string lowercase( const std::string& in ) +{ + std::string out; + transform( in.begin(), in.end(), std::back_inserter( out ), tolower ); + return out; +} + } // NAMESPACE #endif // __TYPEDEF_H__ From 2b68739d5ab60cab08f7bb3543cef931f2ab2013 Mon Sep 17 00:00:00 2001 From: Luis Lucas Date: Sun, 22 Feb 2015 01:09:44 +0000 Subject: [PATCH 4/9] Some fixes on zoom and scroll functions, when image windows are overlapped --- app/SubWindowHandle.cpp | 63 +++++++++++++++++++++++++++-------------- app/SubWindowHandle.h | 6 ++-- app/VideoHandle.cpp | 8 ++++-- app/ViewArea.cpp | 3 ++ 4 files changed, 55 insertions(+), 25 deletions(-) diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp index b42dc1c..e3709ee 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -39,8 +39,8 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) : setWindowIcon( QIcon( ":/images/playuver.png" ) ); // Create a new scroll area inside the sub-window - connect( horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) ); - connect( verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) ); + connect( horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValue() ) ); + connect( verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValue() ) ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); @@ -71,60 +71,81 @@ QSize SubWindowHandle::getScrollSize() Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset ) { - QScrollBar *scrollBar = horizontalScrollBar(); - scrollBar->setValue( int( scrollBar->value() + Offset.x() ) ); - m_cLastScroll.setX( scrollBar->value() ); - scrollBar = verticalScrollBar(); - scrollBar->setValue( int( scrollBar->value() + Offset.y() ) ); - m_cLastScroll.setY( scrollBar->value() ); - updateLastScrollValue(); + QPoint cLastScroll = m_cCurrScroll; + m_cCurrScroll.setX(int( cLastScroll.x() + Offset.x() )); + m_cCurrScroll.setY(int( cLastScroll.y() + Offset.y() )); + + if(!widget()->visibleRegion().isEmpty()) + { + QScrollBar *scrollBar = horizontalScrollBar(); + scrollBar->setValue( m_cCurrScroll.x() ); + scrollBar = verticalScrollBar(); + scrollBar->setValue( m_cCurrScroll.y() ); + } } // This function was developed with help of the schematics presented in // http://stackoverflow.com/questions/13155382/jscrollpane-zoom-relative-to-mouse-position Void SubWindowHandle::adjustScrollBarByScale( Double scale, QPoint center ) { + QPoint cLastScroll = m_cCurrScroll; QScrollBar *scrollBar = horizontalScrollBar(); if( center.isNull() ) { - scrollBar->setValue( int( scale * scrollBar->value() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) ) ); + m_cCurrScroll.setX(int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) )); } else { - Int x = center.x() - m_cLastScroll.x(); - Int value = int( scale * m_cLastScroll.x() + ( ( scale - 1 ) * x ) ); + Int x = center.x() - cLastScroll.x(); + Int value = int( scale * cLastScroll.x() + ( ( scale - 1 ) * x ) ); if( value > scrollBar->maximum() ) value = scrollBar->maximum(); if( value < scrollBar->minimum() ) value = scrollBar->minimum(); - scrollBar->setValue( value ); + m_cCurrScroll.setX(value); } scrollBar = verticalScrollBar(); if( center.isNull() ) { - scrollBar->setValue( int( scale * scrollBar->value() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) ) ); + m_cCurrScroll.setY(int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) )); } else { - Int y = center.y() - m_cLastScroll.y(); - Int value = int( scale * m_cLastScroll.y() + ( ( scale - 1 ) * y ) ); + Int y = center.y() - cLastScroll.y(); + Int value = int( scale * cLastScroll.y() + ( ( scale - 1 ) * y ) ); if( value > scrollBar->maximum() ) value = scrollBar->maximum(); if( value < scrollBar->minimum() ) value = scrollBar->minimum(); - scrollBar->setValue( value ); + m_cCurrScroll.setY(value); } - updateLastScrollValue(); + if(!widget()->visibleRegion().isEmpty()) + { + scrollBar = horizontalScrollBar(); + scrollBar->setValue( m_cCurrScroll.x() ); + scrollBar = verticalScrollBar(); + scrollBar->setValue( m_cCurrScroll.y() ); + } + + update(); } -Void SubWindowHandle::updateLastScrollValue() +Void SubWindowHandle::updateCurScrollValue() { QScrollBar *scrollBar = horizontalScrollBar(); - m_cLastScroll.setX( scrollBar->value() ); + m_cCurrScroll.setX( scrollBar->value() ); scrollBar = verticalScrollBar(); - m_cLastScroll.setY( scrollBar->value() ); + m_cCurrScroll.setY( scrollBar->value() ); +} + +Void SubWindowHandle::setCurScrollValues() +{ + QScrollBar *scrollBar = horizontalScrollBar(); + scrollBar->setValue(m_cCurrScroll.x() ); + scrollBar = verticalScrollBar(); + scrollBar->setValue(m_cCurrScroll.y() ); } Void SubWindowHandle::setWindowName( QString name ) diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index 4670a16..2d77016 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -44,6 +44,7 @@ Q_OBJECT private: QPoint m_cLastScroll; + QPoint m_cCurrScroll; UInt m_uiCategory; QString m_cWindowName; @@ -134,10 +135,11 @@ Q_SIGNALS: void aboutToClose( SubWindowHandle* ); public Q_SLOTS: -void onDestroyed(); + void onDestroyed(); void adjustScrollBarByScale( double scale, QPoint center ); void adjustScrollBarByOffset( QPoint Offset ); - void updateLastScrollValue(); + void updateCurScrollValue(); + void setCurScrollValues(); }; diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 6dfaf02..cb18a0c 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -314,13 +314,17 @@ Void VideoHandle::moveAllScrollBars( const QPoint offset ) { if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() ) { + SubWindowHandle *subWindow; QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); for( Int i = 0; i < subWindowList.size(); i++ ) { - if( m_pcCurrentVideoSubWindow == subWindowList.at( i ) ) + subWindow = subWindowList.at( i ); + if( m_pcCurrentVideoSubWindow == subWindow ) continue; else - subWindowList.at( i )->adjustScrollBarByOffset( offset ); + { + subWindow->adjustScrollBarByOffset( offset ); + } } } } diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index d711a67..3c68a53 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -331,6 +331,9 @@ void ViewArea::paintEvent( QPaintEvent *event ) { QRect winRect = event->rect(); + if(visibleRegion().isEmpty()) + return; + if( size().isEmpty() || m_pixmap.isNull() ) return; From 3bc693515b3adbe7304f43f00b5e7fb0e6e79fa0 Mon Sep 17 00:00:00 2001 From: Luis Lucas Date: Sun, 22 Feb 2015 02:28:18 +0000 Subject: [PATCH 5/9] Some fixes. WA_StaticContents attributted is removed. This was causing overlapping bug. --- app/PlaYUVerMdiSubWindow.h | 1 - app/SubWindowHandle.cpp | 31 +++++++++++++------------------ app/SubWindowHandle.h | 2 +- app/ViewArea.cpp | 2 -- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/app/PlaYUVerMdiSubWindow.h b/app/PlaYUVerMdiSubWindow.h index dc0f3c9..3b47bbe 100644 --- a/app/PlaYUVerMdiSubWindow.h +++ b/app/PlaYUVerMdiSubWindow.h @@ -49,7 +49,6 @@ Q_SIGNALS: protected: QSize sizeHint() const; void closeEvent( QCloseEvent *event ); - }; } // NAMESPACE diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp index e3709ee..4277667 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -39,8 +39,8 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) : setWindowIcon( QIcon( ":/images/playuver.png" ) ); // Create a new scroll area inside the sub-window - connect( horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValue() ) ); - connect( verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValue() ) ); + connect( horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) ); + connect( verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); @@ -75,13 +75,11 @@ Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset ) m_cCurrScroll.setX(int( cLastScroll.x() + Offset.x() )); m_cCurrScroll.setY(int( cLastScroll.y() + Offset.y() )); - if(!widget()->visibleRegion().isEmpty()) - { - QScrollBar *scrollBar = horizontalScrollBar(); - scrollBar->setValue( m_cCurrScroll.x() ); - scrollBar = verticalScrollBar(); - scrollBar->setValue( m_cCurrScroll.y() ); - } + // Update window scroll + QScrollBar *scrollBar = horizontalScrollBar(); + scrollBar->setValue( m_cCurrScroll.x() ); + scrollBar = verticalScrollBar(); + scrollBar->setValue( m_cCurrScroll.y() ); } // This function was developed with help of the schematics presented in @@ -121,18 +119,15 @@ Void SubWindowHandle::adjustScrollBarByScale( Double scale, QPoint center ) m_cCurrScroll.setY(value); } - if(!widget()->visibleRegion().isEmpty()) - { - scrollBar = horizontalScrollBar(); - scrollBar->setValue( m_cCurrScroll.x() ); - scrollBar = verticalScrollBar(); - scrollBar->setValue( m_cCurrScroll.y() ); - } + // Update window scroll + scrollBar = horizontalScrollBar(); + scrollBar->setValue( m_cCurrScroll.x() ); + scrollBar = verticalScrollBar(); + scrollBar->setValue( m_cCurrScroll.y() ); - update(); } -Void SubWindowHandle::updateCurScrollValue() +Void SubWindowHandle::updateCurScrollValues() { QScrollBar *scrollBar = horizontalScrollBar(); m_cCurrScroll.setX( scrollBar->value() ); diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index 2d77016..e0f9d6d 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -138,7 +138,7 @@ public Q_SLOTS: void onDestroyed(); void adjustScrollBarByScale( double scale, QPoint center ); void adjustScrollBarByOffset( QPoint Offset ); - void updateCurScrollValue(); + void updateCurScrollValues(); void setCurScrollValues(); }; diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index 3c68a53..478b13e 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -49,8 +49,6 @@ static const QColor eraserColor = Qt::red; ViewArea::ViewArea( QWidget *parent ) : QWidget( parent ) { - setAttribute( Qt::WA_StaticContents ); -// setAttribute( Qt::WA_NoBackground ); setMouseTracking( true ); m_pcCurrFrame = NULL; From b441e3200928e37f57c9f7699568fc85ffd4c1e9 Mon Sep 17 00:00:00 2001 From: Luis Lucas Date: Sun, 22 Feb 2015 02:39:01 +0000 Subject: [PATCH 6/9] Fix bug related with maximum and minimum scrool value. --- app/SubWindowHandle.cpp | 59 ++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp index 4277667..0a304fb 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -72,14 +72,29 @@ QSize SubWindowHandle::getScrollSize() Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset ) { QPoint cLastScroll = m_cCurrScroll; - m_cCurrScroll.setX(int( cLastScroll.x() + Offset.x() )); - m_cCurrScroll.setY(int( cLastScroll.y() + Offset.y() )); + QScrollBar *scrollBarH, *scrollBarV; + Int valueX, valueY; + + valueX = int( cLastScroll.x() + Offset.x() ); + valueY = int( cLastScroll.y() + Offset.y() ); + + scrollBarH = horizontalScrollBar(); + if( valueX > scrollBarH->maximum() ) + valueX = scrollBarH->maximum(); + if( valueX < scrollBarH->minimum() ) + valueX = scrollBarH->minimum(); + m_cCurrScroll.setX(valueX); + + scrollBarV = verticalScrollBar(); + if( valueY > scrollBarV->maximum() ) + valueY = scrollBarV->maximum(); + if( valueY < scrollBarV->minimum() ) + valueY = scrollBarV->minimum(); + m_cCurrScroll.setY( valueY ); // Update window scroll - QScrollBar *scrollBar = horizontalScrollBar(); - scrollBar->setValue( m_cCurrScroll.x() ); - scrollBar = verticalScrollBar(); - scrollBar->setValue( m_cCurrScroll.y() ); + scrollBarH->setValue( m_cCurrScroll.x() ); + scrollBarV->setValue( m_cCurrScroll.y() ); } // This function was developed with help of the schematics presented in @@ -87,43 +102,43 @@ Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset ) Void SubWindowHandle::adjustScrollBarByScale( Double scale, QPoint center ) { QPoint cLastScroll = m_cCurrScroll; - QScrollBar *scrollBar = horizontalScrollBar(); + QScrollBar *scrollBarH, *scrollBarV; + + scrollBarH = horizontalScrollBar(); if( center.isNull() ) { - m_cCurrScroll.setX(int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) )); + m_cCurrScroll.setX(int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBarH->pageStep() / 2 ) )); } else { Int x = center.x() - cLastScroll.x(); Int value = int( scale * cLastScroll.x() + ( ( scale - 1 ) * x ) ); - if( value > scrollBar->maximum() ) - value = scrollBar->maximum(); - if( value < scrollBar->minimum() ) - value = scrollBar->minimum(); + if( value > scrollBarH->maximum() ) + value = scrollBarH->maximum(); + if( value < scrollBarH->minimum() ) + value = scrollBarH->minimum(); m_cCurrScroll.setX(value); } - scrollBar = verticalScrollBar(); + scrollBarV = verticalScrollBar(); if( center.isNull() ) { - m_cCurrScroll.setY(int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) )); + m_cCurrScroll.setY(int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBarV->pageStep() / 2 ) )); } else { Int y = center.y() - cLastScroll.y(); Int value = int( scale * cLastScroll.y() + ( ( scale - 1 ) * y ) ); - if( value > scrollBar->maximum() ) - value = scrollBar->maximum(); - if( value < scrollBar->minimum() ) - value = scrollBar->minimum(); + if( value > scrollBarV->maximum() ) + value = scrollBarV->maximum(); + if( value < scrollBarV->minimum() ) + value = scrollBarV->minimum(); m_cCurrScroll.setY(value); } // Update window scroll - scrollBar = horizontalScrollBar(); - scrollBar->setValue( m_cCurrScroll.x() ); - scrollBar = verticalScrollBar(); - scrollBar->setValue( m_cCurrScroll.y() ); + scrollBarH->setValue( m_cCurrScroll.x() ); + scrollBarV->setValue( m_cCurrScroll.y() ); } From 56d3a7a6842479aca200d554a62bd4ddfb85c5a0 Mon Sep 17 00:00:00 2001 From: Luis Lucas Date: Sun, 22 Feb 2015 02:56:30 +0000 Subject: [PATCH 7/9] Stop moving scroll of other images, when active image reaches maximum or minimum scroll positions. --- app/VideoHandle.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index cb18a0c..e88b401 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -312,10 +312,27 @@ Void VideoHandle::zoomToFactorAll( const Double scale, const QPoint center ) Void VideoHandle::moveAllScrollBars( const QPoint offset ) { + QPoint newOffset = offset; if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() ) { SubWindowHandle *subWindow; QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); + + QScrollBar *scrollBar; + scrollBar = m_pcCurrentVideoSubWindow->horizontalScrollBar(); + + // Do not move other images, if current image reached maximum or minimum scroll position + if(scrollBar->value()==scrollBar->maximum() && offset.x()>0) + newOffset.setX(0); + if(scrollBar->value()==scrollBar->minimum() && offset.x()<0) + newOffset.setX(0); + + scrollBar = m_pcCurrentVideoSubWindow->verticalScrollBar(); + if(scrollBar->value()==scrollBar->maximum() && offset.y()>0) + newOffset.setY(0); + if(scrollBar->value()==scrollBar->minimum() && offset.y()<0) + newOffset.setY(0); + for( Int i = 0; i < subWindowList.size(); i++ ) { subWindow = subWindowList.at( i ); @@ -323,7 +340,7 @@ Void VideoHandle::moveAllScrollBars( const QPoint offset ) continue; else { - subWindow->adjustScrollBarByOffset( offset ); + subWindow->adjustScrollBarByOffset( newOffset ); } } } From b176f98f0e9d10e1849cb29dda9281fbc4967dd9 Mon Sep 17 00:00:00 2001 From: Luis Lucas Date: Sun, 22 Feb 2015 22:50:03 +0000 Subject: [PATCH 8/9] Use integer precision for zoom percentage value. This fixes alignment of zoommed pixels between two tiled images. --- app/ViewArea.cpp | 24 +++++++++++++++--------- app/plaYUVerApp.cpp | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index 478b13e..0322c08 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -114,7 +114,18 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize Double maxZoom = 100.0; Double minZoom = 0.01; //( 1.0 / m_pixmap.width() ); Double new_scale = 1.0; - Double zoomFactor = m_zoomFactor * scale; + + if( ( m_zoomFactor == minZoom ) && ( scale < 1 ) ) + return new_scale; + + if( ( m_zoomFactor == maxZoom ) && ( scale > 1 ) ) + return new_scale; + + Double zoomFactor = m_zoomFactor * scale * 100.0; + zoomFactor=round(zoomFactor); + zoomFactor=zoomFactor/100.0; + scale = zoomFactor/m_zoomFactor; + if(!minimumSize.isNull()) { @@ -140,18 +151,13 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize else scale = hfactor; - zoomFactor = zoomFactor * scale; + zoomFactor = zoomFactor * scale * 100.0; + zoomFactor=round(zoomFactor); + zoomFactor=zoomFactor/100.0; scale = zoomFactor/m_zoomFactor; } } - if( ( m_zoomFactor == minZoom ) && ( scale < 1 ) ) - return new_scale; - - if( ( m_zoomFactor == maxZoom ) && ( scale > 1 ) ) - return new_scale; - - new_scale = scale; if( zoomFactor < minZoom ) diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index 2e003bf..c958294 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -779,6 +779,7 @@ Void plaYUVerApp::createToolBars() m_arrayToolBars[VIEW_TOOLBAR] = new QToolBar( tr( "View" ) ); m_pcZoomFactorSBox = new QDoubleSpinBox; m_pcZoomFactorSBox->setRange( 1.0, 10000.0 ); + m_pcZoomFactorSBox->setDecimals(0); m_pcZoomFactorSBox->setSingleStep( 10.0 ); m_pcZoomFactorSBox->setValue( 100.0 ); m_pcZoomFactorSBox->setSuffix( "%" ); From 66a3764d48fa58466aa29796b1cf5b15c2eb4ff9 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 23 Feb 2015 18:19:59 +0000 Subject: [PATCH 9/9] minor changes in PlaYUVerFrame and Stream --- lib/PlaYUVerFrame.cpp | 2 +- lib/PlaYUVerFrame.h | 2 +- lib/PlaYUVerStream.cpp | 19 +++++++++---------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 854f8ec..e546cba 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -120,7 +120,7 @@ Int PlaYUVerFrame::getColorSpace() const return m_pcPelFormat->colorSpace; } -Int PlaYUVerFrame::getNumberChannels() const +UInt PlaYUVerFrame::getNumberChannels() const { return m_pcPelFormat->numberChannels; } diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h index a3824b1..d0562a4 100644 --- a/lib/PlaYUVerFrame.h +++ b/lib/PlaYUVerFrame.h @@ -102,7 +102,7 @@ public: static UInt64 getBytesPerFrame( UInt, UInt, Int ); Int getColorSpace() const; - Int getNumberChannels() const; + UInt getNumberChannels() const; UInt getChromaWidth() const; UInt getChromaHeight() const; UInt getChromaLength() const; diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 2d5d1c6..6ce5d58 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -162,10 +162,13 @@ Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::st UInt height; Int input_format = -1; - sscanf( resolution.c_str(), "%ux%u", &width, &height ); - if( width <= 0 || height <= 0 ) + if( resolution.size() > 0 ) { - return false; + sscanf( resolution.c_str(), "%ux%u", &width, &height ); + if( width <= 0 || height <= 0 ) + { + return false; + } } for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) { @@ -175,11 +178,7 @@ Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::st break; } } - if( width > 0 && height > 0 && input_format >= 0 ) - { - return open( filename, width, height, input_format, frame_rate, bInput ); - } - return false; + return open( filename, width, height, input_format, frame_rate, bInput ); } Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput ) @@ -480,7 +479,7 @@ Void PlaYUVerStream::readFrame() if( !m_bInit || !m_bIsInput ) return; - if( m_iCurrFrameNum + 1 >= ( Int64 )m_uiTotalFrameNum ) + if( m_iCurrFrameNum + ( m_uiFrameBufferSize - 1 )>= ( Int64 )m_uiTotalFrameNum ) { m_iErrorStatus = LAST_FRAME; m_pcNextFrame = NULL; @@ -597,7 +596,7 @@ Bool PlaYUVerStream::saveFrame( const std::string& filename, PlaYUVerFrame *save else { cv::Mat* image; - saveFrame->getCvMat( (Void**)&image ); + saveFrame->getCvMat( ( Void** )&image ); return cv::imwrite( filename, *image ); }