From e0c1fb5f769a692474b24dbead8c16e38bd1dd68 Mon Sep 17 00:00:00 2001 From: Alexander Mordvintsev Date: Mon, 28 May 2012 08:51:50 +0000 Subject: [PATCH] updated video_threaded.py sample: - switch btw threaded and non-threaded mode - performance counters - description --- samples/python2/common.py | 11 ++++++ samples/python2/video_threaded.py | 73 +++++++++++++++++++++++++++++++++------ 2 files changed, 74 insertions(+), 10 deletions(-) diff --git a/samples/python2/common.py b/samples/python2/common.py index 7319ceb..54e23d6 100644 --- a/samples/python2/common.py +++ b/samples/python2/common.py @@ -126,6 +126,17 @@ def Timer(msg): finally: print "%.2f ms" % ((clock()-start)*1000) +class StatValue: + def __init__(self, smooth_coef = 0.5): + self.value = None + self.smooth_coef = smooth_coef + def update(self, v): + if self.value is None: + self.value = v + else: + c = self.smooth_coef + self.value = c * self.value + (1.0-c) * v + class RectSelector: def __init__(self, win, callback): self.win = win diff --git a/samples/python2/video_threaded.py b/samples/python2/video_threaded.py index 85d9b6a..6f92d06 100644 --- a/samples/python2/video_threaded.py +++ b/samples/python2/video_threaded.py @@ -1,29 +1,82 @@ +''' +Multithreaded video processing sample. +Usage: + video_threaded.py {