本文整理汇总了Python中managers.CaptureManager.getResolution方法的典型用法代码示例。如果您正苦于以下问题:Python CaptureManager.getResolution方法的具体用法?Python CaptureManager.getResolution怎么用?Python CaptureManager.getResolution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类managers.CaptureManager
的用法示例。
在下文中一共展示了CaptureManager.getResolution方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Gui
# 需要导入模块: from managers import CaptureManager [as 别名]
# 或者: from managers.CaptureManager import getResolution [as 别名]
#.........这里部分代码省略.........
self._cap.resetFPSestimate()
if self._wormFinder:
self._wormFinder.servos = self.ebb
self.setAble('motorized', True)
except serial.SerialException as e:
logger.exception(str(e))
QtWidgets.QMessageBox.information( self, "Motors Issue",
"Unable to connect to motors. Please connect or reboot motors. If problem persists, reboot computer")
def setSource ( self, value ):
self.existingVid = False
if type(value) != int:
nums = re.compile(r'\d*')
mat = re.match(nums,value).group(0)
if re.match(nums, value).group(0) is not u'':
src = int(value)
else:
src = str(value)
self.existingVid = True
else: #read in from calibration
src = value
self.ui.sourceCombo.setCurrentText(str(src))
if self._cap:
if self._cap._capture.isOpened(): #ugly access to VideoCapture object from managers
self._cap._capture.release()
self._cap = CaptureManager( cv2.VideoCapture(src) )
self.showImage = True
self.actualRes = self._cap.getResolution()
if self.actualRes != self.calibrationRes and not self.existingVid:
self._cap.setProp( 'height', self.calibrationRes[1] )
self._cap.setProp( 'width', self.calibrationRes[0] )
self.showImage = True
self.actualRes = self._cap.getResolution()
logger.warning("Actual resolution from cam is %s" % str( self.actualRes ) )
self.setAble('source', False)
self.setAble('buttons', True)
self.ui.buttonRefresh.setEnabled(False)
def setLogging( self, value ):
addFile = True
formatter = logging.Formatter( '%(asctime)s\t%(levelname)s\t%(name)s\t\t%(message)s' )
file = logging.FileHandler( '%s.log' % self.shareFileName )
logger.warning('New file')
file.setLevel( LOGGING_LEVELS['debug'] )
file.setFormatter( formatter )
console = logging.StreamHandler()
console.setLevel( LOGGING_LEVELS['debug'] )
console.setFormatter( formatter )
for h in logger.handlers:
if type(h) == logging.StreamHandler:
logger.removeHandler( h )
elif type(h) == logging.FileHandler: #if file has started, leave it be!!!
addFile = False
if addFile:
示例2: Gui
# 需要导入模块: from managers import CaptureManager [as 别名]
# 或者: from managers.CaptureManager import getResolution [as 别名]
class Gui(QtWidgets.QMainWindow):
## Signals
#closeGui = QtCore.pyqtSignal()
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)
## Instantiate classes
self.ui = Ui_CalibrationUI()
self.ui.setupUi(self)
self._cap = None
self.ebb = None
## Stuff you can change in the UI
self.width = None
self.idealRes = [1280, 960]
self.colSteps = 0
self.rowSteps = 0
self.multFactor = 1
self.motorsAble = False
self.showImage = False
## Stuff that doesn't change
#self._cap = CaptureManager( cv2.VideoCapture(0) )
## Video stuff
self._timer = QtCore.QTimer( self )
self._timer.timeout.connect( self.play )
self._timer.start(27)
self.update()
source = [0, 1, 2,3, 'led_move1.avi',
'screencast.avi',
'screencast 1.avi',
'shortNoBox.avi',
'longNoBox.avi',
'H299.avi',
'testRec.avi',
'longDemo.avi']
for s in source:
self.ui.sourceCombo.addItem(str(s))
## Register button actions
self.ui.buttonSet.clicked.connect( self.set )
self.ui.buttonCenter.clicked.connect( self.center )
self.ui.buttonReset.clicked.connect( self.reset )
self.ui.buttonSave.clicked.connect( self.save )
self.ui.buttonRight.clicked.connect( partial( self.motors, 'right' ) )
self.ui.buttonLeft.clicked.connect( partial( self.motors, 'left' ) )
self.ui.buttonUp.clicked.connect( partial( self.motors, 'up' ) )
self.ui.buttonDown.clicked.connect( partial( self.motors, 'down' ) )
self.ui.scalingSlider.valueChanged[int].connect( self.setMultFactor )
self.ui.scalingSlider.setValue(10)
self.ui.scaling.setText( 'Motor scaling is %d' % self.ui.scalingSlider.value() )
self.ui.sourceCombo.activated[int].connect( self.setSource )
self.ui.comboBox.activated.connect ( self.resolutionSelect )
self.setAble('settings', False)
self.setAble('motors', False)
self.setAble('center', False)
self.setAble('reset', False)
self.setAble('save', False)
def setSource ( self, value ):
if self._cap:
if self._cap._capture.isOpened(): #ugly access to VideoCapture object from managers
self._cap._capture.release()
self._cap = CaptureManager( cv2.VideoCapture(int(value)) )
#self.indWindow = cv2.namedWindow("Camera Display")
self.showImage = True
self.actualRes = self._cap.getResolution()
# Set to default resolution from camera (640x480)
#res = "%d x %d" % (int(self.actualRes[0]), int(self.actualRes[1]) )
#index = self.ui.comboBox.findText(res) #Sets picker to default resolution
#self.ui.comboBox.setCurrentIndex(index)
# Set to Hoky desired default res (1280x960)
res = "%d x %d" % (int(self.idealRes[0]), int(self.idealRes[1]) )
index = self.ui.comboBox.findText(res) #Sets picker to default resolution
self.ui.comboBox.setCurrentIndex(index)
self.resolutionSelect()
self.p = Point(200,300)
self.c = Point(self.actualRes[0] // 2, self.actualRes[1] // 2)
self.setAble('settings', True)
#.........这里部分代码省略.........
示例3: Tracker
# 需要导入模块: from managers import CaptureManager [as 别名]
# 或者: from managers.CaptureManager import getResolution [as 别名]
class Tracker ( object ):
def __init__( self, method, src ):
### Sensitivity of tracker params
self._sampleFreq = 0.1 #in sec
### Set Camera params
#self.resolution = (640, 480 )
self.resolution = (1280, 960)
source = {
0:0,
1:1,
2:'led_move1.avi',
3:'screencast.avi',
4:'screencast 1.avi',
5: 'shortNoBox.avi',
6: 'longNoBox.avi',
7: 'H299.avi',
8: 'testRec.avi',
9: 'longDemo.avi',
10: 'worm2014_05_05-12-44-53.avi'
}
self.color = True
self.captureSource = source[int(src)]
### Timing initialization
self._startTime = time.time()
self._lastCheck = self._startTime - self._sampleFreq
### Display params
self.mirroredPreview = False
### Initialize Objects
##### Windows
self._rawWindow = WindowManager( 'RawFeed', self.onKeypress )
### Capture -- resolution set here
self._cap = CaptureManager(
cv2.VideoCapture(self.captureSource),
self._rawWindow,
self.mirroredPreview, self.resolution)
actualCols, actualRows = self._cap.getResolution()
## from here on out use this resolution
### Arguments for finder
self.finderArgs = {
'method' : method,
'gsize' : 45,
'gsig' : 9,
'window' : 3,
'boundBoxRow' : 150,
'boundBoxCol' : 150,
'limRow' : 100,
'limCol' : 100,
'MAXONEFRAME': 500,
'REFPING' : 600000,
'MAXREF': 1000,
'capCols':actualCols,
'capRows': actualRows,
'color' : self.color
}
self._wormFinder = WormFinder( **self.finderArgs )
##### Debugging
self._overlayWindow = WindowManager( 'Overlay', self.onKeypress )
self.motorsOn = False
def run( self ):
# Show windows
self._rawWindow.createWindow()
self._overlayWindow.createWindow()
while self._rawWindow.isWindowCreated:
self._cap.enterFrame()
frame = self._cap.frame
# Probably not useful, removes errors when playing from video
# if not self._captureManager.gotFrame:
# self.shutDown()
# break
# Display raw frame to rawWindow
t1 = time.time()
# Get frame
frame = self._cap.frame
# Show frame to raw feed
self._rawWindow.show(frame)
# If tracking is enabled or motors are on, start tracking
#.........这里部分代码省略.........
示例4: Tracker
# 需要导入模块: from managers import CaptureManager [as 别名]
# 或者: from managers.CaptureManager import getResolution [as 别名]
class Tracker(object):
def __init__(self, method, src):
self.color = True
self.motorsOn = False
### Sensitivity of tracker params
self._sampleFreq = 0.1 # in sec
### Set Camera params
# self.resolution = (640, 480 )
self.resolution = (1280, 960)
source = {
0: 0,
1: 1,
2: "led_move1.avi",
3: "screencast.avi",
4: "screencast 1.avi",
5: "shortNoBox.avi",
6: "longNoBox.avi",
7: "H299.avi",
8: "testRec.avi",
9: "longDemo.avi",
}
self.captureSource = source[int(src)]
### Timing initialization
self._startTime = time.time()
self._lastCheck = self._startTime - self._sampleFreq
### Display params
self.mirroredPreview = False
### Initialize Objects
##### Windows
self._rawWindow = WindowManager("RawFeed", self.onKeypress)
### Capture -- resolution set here
self._cap = CaptureManager(
cv2.VideoCapture(self.captureSource), self._rawWindow, self.mirroredPreview, self.resolution
)
actualCols, actualRows = self._cap.getResolution()
self.centerPt = utils.Point(actualCols / 2, actualRows / 2)
## from here on out use this resolution
boundCols = 600
boundRows = 600
### Arguments for finder
# --> Pairs are always COLS, ROWS !!!!!!!
self.finderArgs = {
"method": method,
"gsize": 45,
"gsig": 9,
"window": 3,
"MAXONEFRAME": 500,
"REFPING": 600000,
"MAXREF": 1000,
"captureSize": utils.Rect(actualCols, actualRows, self.centerPt),
"cropRegion": utils.Rect(100, 100, self.centerPt),
"decisionBoundary": utils.Rect(boundCols, boundRows, self.centerPt),
"color": self.color,
"motorsOn": self.motorsOn,
}
self._wormFinder = WormFinder(**self.finderArgs)
##### Debugging
# self._gaussianWindow = WindowManager('Gaussian', self.onKeypress)
self._overlayWindow = WindowManager("Overlay", self.onKeypress)
def run(self):
# Show windows
self._rawWindow.createWindow()
self._overlayWindow.createWindow()
i = 0
while self._rawWindow.isWindowCreated:
self._cap.enterFrame()
frame = self._cap.frame
# Probably not useful, removes errors when playing from video
# if not self._captureManager.gotFrame:
# self.shutDown()
# break
# Display raw frame to rawWindow
t1 = time.time()
# Get frame
frame = self._cap.frame
# Show frame to raw feed
self._rawWindow.show(frame)
# If tracking is enabled or motors are on, start tracking
if time.time() - self._lastCheck >= self._sampleFreq:
if self.finderArgs["method"] in ["lazyc", "lazyd", "lazy"]:
self.gaussian = self._wormFinder.processFrame(frame)
#.........这里部分代码省略.........