本文整理汇总了Python中PostProcessing类的典型用法代码示例。如果您正苦于以下问题:Python PostProcessing类的具体用法?Python PostProcessing怎么用?Python PostProcessing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PostProcessing类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply
def apply(self, cur_image):
"""
apply the algorithm for running average in color
:param cur_image: numpy array; a color image (RGB)
:return new_objects_box: array consists of new object squares
:return new_fg: binary image consists of image (black and white)
"""
cur_image_gray = cv2.cvtColor(cur_image, cv2.COLOR_BGR2GRAY)
if self.prev_image is not None:
threshold_array = np.multiply(np.ones_like(cur_image_gray, 'uint8'), self.threshold)
diff = np.absolute(np.subtract(cur_image_gray, self.prev_frame))
fg_raw = np.multiply(
np.ones_like(cur_image_gray, 'uint8'),
np.where(
np.less(diff, threshold_array),
0,
255
)
)
raw_boxes, new_fg = PostProcessing.foreground_process(fg_raw)
new_objects_box = PostProcessing.bounding_box_mask(raw_boxes, new_fg)
else:
new_fg = np.zeros_like(cur_image_gray)
new_objects_box = []
self.prev_image = np.copy(cur_image_gray)
return new_objects_box, new_fg
示例2: run
def run(self, rect, cur_frame, next_frame):
x, y, w, h = rect
cur_roi = PostProcessing.get_roi_from_images(rect, cur_frame)
center_of_window = (x + (w / 2), y + (h / 2))
# compute centroid of current frame
cur_moment = cv2.moments(cur_roi)
cx = x + int(cur_moment['m10'] / cur_moment['m00'])
cy = y + int(cur_moment['m01'] / cur_moment['m00'])
cur_frame_centroid = (cx, cy)
# compute centroid of next frame with current windows
cur_roi_next = PostProcessing.get_roi_from_images(rect, next_frame)
cur_moment_next = cv2.moments(cur_roi_next)
next_cx = x + int(cur_moment_next['m10'] / cur_moment_next['m00'])
next_cy = y + int(cur_moment_next['m01'] / cur_moment_next['m00'])
next_frame_centroid = (next_cx, next_cy)
# calculate distance between current frame centroid and next frame centroid
x0, y0 = cur_frame_centroid
x1, y1 = next_frame_centroid
xwin, ywin = center_of_window
new_center_of_window = ((xwin + (x1 - x0)), (ywin + (y1 - y0)))
new_rect = (new_center_of_window[0] - (w / 2), new_center_of_window[1] - (h / 2), w, h)
print new_rect
pass
示例3: removeEffect
def removeEffect(effect):
ch = list(PostProcessing.chain())
try:
ch.remove(effect)
PostProcessing.chain(ch)
except ValueError:
pass
示例4: disable
def disable(self):
self.__curMode = None
for effect in self.__curEffects:
effect.disable()
self.__curEffects = []
PostProcessing.chain([])
示例5: load
def load(self, pSection, prereqs = None):
"""
This method loads a .ppchain file. You may also specify additional
properties to set on the chain.
"""
if PostProcessing.isSupported(pSection.asString):
actor = PostProcessing.load(pSection.asString)
if actor == None or len(actor) == 0:
ERROR_MSG('Could not load PostProcessing chain %s' % (pSection.asString,))
actor = []
else:
actor = []
for name, section in pSection.items():
if name == 'Property':
varName = section.asString
if section.has_key('Float'):
PostProcessing.setMaterialProperty(actor, varName, section.readFloat('Float'))
elif section.has_key('Vector4'):
PostProcessing.setMaterialProperty(actor, varName, section.readVector4('Vector4'))
elif section.has_key('Colour'):
col = section.readVector4('Colour')
col[0] /= 255.0
col[1] /= 255.0
col[2] /= 255.0
col[3] /= 255.0
PostProcessing.setMaterialProperty(actor, varName, col)
else:
PostProcessing.setMaterialProperty(actor, varName, section.asString)
return actor
示例6: fini
def fini(self):
self.__curEffects = []
for mode in self.__modes.itervalues():
for effect in mode:
effect.destroy()
PostProcessing.fini()
self.__saveSettings()
示例7: detach
def detach(self, actor, source, target = None):
ch = PostProcessing.chain()
for effect in actor:
try:
ch.remove(effect)
except ValueError:
pass
PostProcessing.chain(ch)
示例8: fini
def fini(self):
from account_helpers.SettingsCore import g_settingsCore
g_settingsCore.onSettingsChanged -= self.__onSettingsChanging
self.__curEffects = []
for mode in self.__modes.itervalues():
for effect in mode:
effect.destroy()
PostProcessing.fini()
self.__saveSettings()
示例9: init
def init(self):
self.__loadSettings()
PostProcessing.g_graphicsSettingListeners.append(_FuncObj(self, 'onSelectQualityOption'))
PostProcessing.init()
PostProcessing.chain(None)
section = ResMgr.openSection(WGPostProcessing.__CONFIG_FILE_NAME)
self.__load(section)
for mode in self.__modes.itervalues():
for effect in mode:
effect.create()
示例10: onBlurred
def onBlurred(self, callbackFn):
import PostProcessing
c = list(PostProcessing.chain())
ch = []
for e in c:
if e.name != 'Teleport Progress Bar':
ch.append(e)
PostProcessing.chain(ch)
if callbackFn:
callbackFn()
示例11: go
def go(self, effect, actor, source, target, **kargs):
duration = effect.totalDuration
try:
self.v4 = Math.Vector4Translation(source.root)
except:
try:
self.v4 = Math.Vector4Translation(source.model.root)
except:
self.v4 = Math.Vector4Translation(source.source)
PostProcessing.setMaterialProperty(actor, self.propName, self.v4)
return duration
示例12: enable
def enable(self, mode):
if self.__modes.get(mode, None) is None:
LOG_WARNING('Effect mode with name %s was not found.' % mode)
return
self.__curMode = mode
self.__gatherEffects('common')
self.__gatherEffects(mode)
chain = []
for effect in self.__curEffects:
chain += effect.enable(self.__settings)
PostProcessing.chain(chain)
示例13: init
def init(self):
self.__loadSettings()
PostProcessing.g_graphicsSettingListeners.append(_FuncObj(self, 'onSelectQualityOption'))
PostProcessing.init()
PostProcessing.chain(None)
section = ResMgr.openSection(WGPostProcessing.__CONFIG_FILE_NAME)
self.__load(section)
for mode in self.__modes.itervalues():
for effect in mode:
effect.create()
from account_helpers.SettingsCore import g_settingsCore
g_settingsCore.onSettingsChanged += self.__onSettingsChanging
return
示例14: preTeleport
def preTeleport(self, callbackFn):
import PostProcessing
effect = PostProcessing.blur()
effect.name = 'Teleport Progress Bar'
effect.phases[-1].renderTarget = BigWorld.RenderTarget('teleportGobo', -3, -3)
effect.phases[-1].material.additionalAlpha = 1.0
c = list(PostProcessing.chain())
c.append(effect)
PostProcessing.chain(c)
self.component.secondaryTexture = effect.phases[-1].renderTarget.texture
self.component.freeze = None
self.component.fader.value = 1.0
BigWorld.callback(self.component.fader.speed, lambda : self.onBlurred(callbackFn))
return
示例15: add_object
def add_object(self, obj, frame):
# set up ROI
roi = PostProcessing.get_roi_from_images(obj, frame)
hsv_roi = cv2.cvtColor(roi, cv2.COLOR_BGR2HSV)
n_in_frame = 0
n_not_moving = 0
self.list_of_objects.append((obj, hsv_roi, n_in_frame, n_not_moving))