Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
All4Gis committed Jun 4, 2019
1 parent 26fe559 commit 4e7a950
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
47 changes: 34 additions & 13 deletions code/player/QgsFmvPlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,69 +480,90 @@ def contextMenuRequested(self, point):
def grayFilter(self, value):
''' Gray Video Filter '''
self.UncheckFilters(self.sender(), value)
self.videoWidget.SetGray(value)

if value and self.player.playbackRate() == self.playbackRateSlow:
self.player.setPlaybackRate(1.0)
self.videoWidget.SetGray(value)
return

self.videoWidget.UpdateSurface()
return

def MirrorHorizontalFilter(self, value):
''' Mirror Horizontal Video Filter '''
self.UncheckFilters(self.sender(), value)
self.videoWidget.SetMirrorH(value)

if value and self.player.playbackRate() == self.playbackRateSlow:
self.player.setPlaybackRate(1.0)
self.videoWidget.SetMirrorH(value)
return

self.videoWidget.UpdateSurface()
return

def NDVIFilter(self, value):
''' NDVI Video Filter '''
self.UncheckFilters(self.sender(), value)
self.videoWidget.SetNDVI(value)

# TODO : Temporarily we lower in rate. Player in other thread?
if value and self.player.playbackRate()!= self.playbackRateSlow:
self.player.setPlaybackRate(self.playbackRateSlow)
QApplication.processEvents()
self.videoWidget.SetNDVI(value)
self.player.setPlaybackRate(self.playbackRateSlow)
return

#QApplication.processEvents()
self.videoWidget.UpdateSurface()
return

def edgeFilter(self, value):
''' Edge Detection Video Filter '''
self.UncheckFilters(self.sender(), value)
self.videoWidget.SetEdgeDetection(value)

# TODO : Temporarily we lower in rate. Player in other thread?
if value and self.player.playbackRate()!= self.playbackRateSlow:
self.player.setPlaybackRate(self.playbackRateSlow)
QApplication.processEvents()
self.videoWidget.SetEdgeDetection(value)
self.player.setPlaybackRate(self.playbackRateSlow)
return
#QApplication.processEvents()
self.videoWidget.UpdateSurface()
return

def invertColorFilter(self, value):
''' Invert Color Video Filter '''
self.UncheckFilters(self.sender(), value)
self.videoWidget.SetInvertColor(value)

if value and self.player.playbackRate() == self.playbackRateSlow:
self.player.setPlaybackRate(1.0)
self.videoWidget.SetInvertColor(value)
return

#QApplication.processEvents()
self.videoWidget.UpdateSurface()
return

def autoContrastFilter(self, value):
''' Auto Contrast Video Filter '''
self.UncheckFilters(self.sender(), value)
self.videoWidget.SetAutoContrastFilter(value)
# TODO : Temporarily we lower in rate. Player in other thread?
if value and self.player.playbackRate()!= self.playbackRateSlow:
self.player.setPlaybackRate(self.playbackRateSlow)
QApplication.processEvents()
self.videoWidget.SetAutoContrastFilter(value)
self.player.setPlaybackRate(self.playbackRateSlow)
return

#QApplication.processEvents()
self.videoWidget.UpdateSurface()
return

def monoFilter(self, value):
''' Filter Mono Video '''
self.UncheckFilters(self.sender(), value)
self.videoWidget.SetMonoFilter(value)

if value and self.player.playbackRate() == self.playbackRateSlow:
self.player.setPlaybackRate(1.0)
self.videoWidget.SetMonoFilter(value)
return

#QApplication.processEvents()
self.videoWidget.UpdateSurface()
return

Expand Down
13 changes: 10 additions & 3 deletions code/video/QgsVideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ def present(self, frame):
if (self.surfaceFormat().pixelFormat() != frame.pixelFormat() or
self.surfaceFormat().frameSize() != frame.size()):
self.setError(QAbstractVideoSurface.IncorrectFormatError)
self.stop()
# if is a hight quality frame is stopped and not call start function
#self.stop()
return False
else:
self._currentFrame = frame
Expand Down Expand Up @@ -207,7 +208,7 @@ def paint(self, painter):
if self.widget._filterSatate.edgeDetectionFilter:
try:
self.image = filter.EdgeFilter(self.image)
except Exception:
except Exception as e:
None
# TODO : Test in other thread
if self.widget._filterSatate.contrastFilter:
Expand Down Expand Up @@ -453,7 +454,7 @@ def videoSurface(self):
return self.surface

def UpdateSurface(self):
''' Update Video Surface '''
''' Update Video Surface only is is stopped or paused '''
if self.parent.playerState in (QMediaPlayer.StoppedState,
QMediaPlayer.PausedState):
self.update()
Expand Down Expand Up @@ -537,6 +538,12 @@ def RemoveCanvasRubberbands(self):

def paintEvent(self, event):
''' Paint Event '''
if not self.surface.isActive():
return

#print("paintEvent : " + str(event.region().boundingRect()))
#print("Active : " + str(self.surface.isActive()))

self.painter = QPainter(self)
self.painter.setRenderHint(QPainter.HighQualityAntialiasing)

Expand Down

0 comments on commit 4e7a950

Please sign in to comment.