本文整理汇总了Python中managers.CaptureManager.getFrame方法的典型用法代码示例。如果您正苦于以下问题:Python CaptureManager.getFrame方法的具体用法?Python CaptureManager.getFrame怎么用?Python CaptureManager.getFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类managers.CaptureManager
的用法示例。
在下文中一共展示了CaptureManager.getFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Gui
# 需要导入模块: from managers import CaptureManager [as 别名]
# 或者: from managers.CaptureManager import getFrame [as 别名]
#.........这里部分代码省略.........
logger.debug("closing")
if self.ebb:
self.ebb.closeSerial()
if self._cap.isWritingVideo:
self._cap.stopWritingVideo()
for h in logger.handlers:
if type(h) == logging.FileHandler:
h.close()
try:
cv2.destroyWindow('gaussian')
except Exception as e:
pass
def isColor( self, imgIn ):
s = np.shape(imgIn)
if s == 3:
try:
ncolor = np.shape(imgIn)[2]
boolt = int(ncolor) > 2
return boolt
except IndexError:
if self.existingVid:
logger.warning('Video has ended')
self.existingVid = False
self.resetAll()
else:
logger.warning('Issue with video input')
self.resetAll()
else:
return False
def play( self ):
if self.showImage:
## Get image from camera
self._cap.enterFrame()
self.currentFrame = self._cap.getFrame()
self.color = self.isColor(self.currentFrame)
t1 = time.time()
if self.color:
try:
self.currentFrame = cv2.cvtColor(self.currentFrame, cv2.COLOR_BGR2GRAY)
except TypeError:
logger.exception("No Frame")
finally:
self._cap.exitFrame()
else:
self._cap.exitFrame()
if not self.runTracking: #no finder
if self.showImage: #yes capture
self.ui.videoFrame.setPixmap(self._cap.convertFrame(self.currentFrame))
self.ui.videoFrame.setScaledContents(True)
else: # yes finder
## Stop if too dark!!!
if time.time() - self.startTrackTime < 5:
self.firstAvgPixIntensity = np.mean(self.currentFrame)
logger.warning('first avg int: %d' % self.firstAvgPixIntensity)
## Tracking procedure
if time.time() - self._lastCheck >= self._sampleFreq:
gaussian = self._wormFinder.processFrame( self.currentFrame )
if gaussian is not None:
cv2.imshow( 'gaussian', gaussian )
if self.motorsOn: #yes motorized
## Stop motors if too dark
self.currentAvgPixIntensity = np.mean(self.currentFrame)
logger.warning('current avg int: %d' % self.currentAvgPixIntensity)
if self.currentAvgPixIntensity < self.firstAvgPixIntensity - 50:
logger.warning('Darkening of picture: motors turned off')
if self.motorsOn:
self.motorized()
if self._cap.isWritingVideo:
self.record()
else:
self._wormFinder.decideMove()
self._lastCheck = time.time()
self._wormFinder.drawDebugCropped( self.currentFrame)
self.ui.videoFrame.setPixmap(self._cap.convertFrame(self.currentFrame))
self.ui.videoFrame.setScaledContents(True)
if self._cap._fpsEstimate:
self.ui.fps.setText( 'FPS: %0.2f' % ( self._cap._fpsEstimate ))
if self.startRecTime:
elapsedSec = time.time() - self.startRecTime
elapsed = time.strftime("%H.%M.%S", time.gmtime(elapsedSec) )
self.ui.lcdNumber.setNumDigits(8)
self.ui.lcdNumber.display( elapsed )
else:
self.ui.lcdNumber.display("")
return
'''