From 28a0ef477a74f39ff5423eb4fd7ed2de9a478c16 Mon Sep 17 00:00:00 2001 From: Lazare Date: Tue, 12 Jun 2018 19:45:05 +0200 Subject: [PATCH] add numpy.uint16 support --- benchmarks/bench_motion.py | 8 ++------ benchmarks/bench_vread.py | 8 ++++++-- doc/examples/IOcorrupt.py | 7 +++---- doc/examples/motion_charts.py | 10 ++++++---- doc/examples/outputdictexample.py | 5 +++-- doc/examples/scene_parse.py | 13 ++++++++----- doc/examples/sparsevid.py | 18 +++++++++++------- skvideo/measure/scene.py | 6 ++---- 8 files changed, 41 insertions(+), 34 deletions(-) diff --git a/benchmarks/bench_motion.py b/benchmarks/bench_motion.py index 28178af..807ea71 100644 --- a/benchmarks/bench_motion.py +++ b/benchmarks/bench_motion.py @@ -21,13 +21,9 @@ # Author: Todd Goodall # License: BSD clause -import os from time import time -import numpy as np -import skvideo.io -import skvideo.datasets -import skvideo.motion +import skvideo.motion if __name__ == "__main__": # TODO: as code gets faster, make benchmark more @@ -51,7 +47,7 @@ times = [] for es in estimators: - print es + print(es) time_start = time() skvideo.motion.blockMotion(vdata, method=es) time_end = time() diff --git a/benchmarks/bench_vread.py b/benchmarks/bench_vread.py index 8f61bff..b2c5045 100644 --- a/benchmarks/bench_vread.py +++ b/benchmarks/bench_vread.py @@ -18,12 +18,16 @@ # Author: Todd Goodall # License: BSD clause -import os from time import time + import numpy as np -import skvideo.io + import skvideo.datasets +try: + xrange +except NameError: + xrange = range if __name__ == "__main__": diff --git a/doc/examples/IOcorrupt.py b/doc/examples/IOcorrupt.py index 163243e..93094d7 100644 --- a/doc/examples/IOcorrupt.py +++ b/doc/examples/IOcorrupt.py @@ -1,8 +1,7 @@ -import skvideo.io -import skvideo.datasets - import numpy as np +import skvideo.datasets + filename = skvideo.datasets.bigbuckbunny() vid_in = skvideo.io.FFmpegReader(filename) @@ -19,7 +18,7 @@ '-r': rate, }) for idx, frame in enumerate(vid_in.nextFrame()): - print "Writing frame %d/%d" % (idx, T) + print("Writing frame %d/%d" % (idx, T)) if (idx >= (T/2)) & (idx <= (T/2 + 10)): frame = np.random.normal(128, 128, size=frame.shape).astype(np.uint8) vid_out.writeFrame(frame) diff --git a/doc/examples/motion_charts.py b/doc/examples/motion_charts.py index d33aa56..69b060f 100644 --- a/doc/examples/motion_charts.py +++ b/doc/examples/motion_charts.py @@ -1,11 +1,13 @@ -import skvideo.io -import skvideo.motion -import skvideo.datasets - import matplotlib.pyplot as plt import numpy as np import scipy.misc +import skvideo.datasets + +try: + xrange +except NameError: + xrange = range def getPlots(motionData): motionMagnitude = np.sqrt(np.sum(motionData**2, axis=2)) diff --git a/doc/examples/outputdictexample.py b/doc/examples/outputdictexample.py index 5d8705a..55861e6 100644 --- a/doc/examples/outputdictexample.py +++ b/doc/examples/outputdictexample.py @@ -1,7 +1,8 @@ -import skvideo.io import skvideo.measure import numpy as np +import numpy as np +import skvideo.measure outputfile = "test.mp4" outputdata = np.random.random(size=(30, 480, 640, 3)) * 255 @@ -24,4 +25,4 @@ mSSIM += skvideo.measure.ssim(np.mean(inputdata[i], axis=2), np.mean(outputdata[i], axis=2)) mSSIM /= 30.0 -print mSSIM +print(mSSIM) diff --git a/doc/examples/scene_parse.py b/doc/examples/scene_parse.py index 811b512..224fe6f 100644 --- a/doc/examples/scene_parse.py +++ b/doc/examples/scene_parse.py @@ -1,12 +1,15 @@ -import skvideo.io -import skvideo.datasets +import matplotlib.pyplot as plt +import numpy as np + import skvideo.measure -import numpy as np -import matplotlib.pyplot as plt +try: + xrange +except NameError: + xrange = range def getPlot(edgelist1, edgelist2, t, w, h, T): - myDPI = 100.0 + myDPI = 100 fig = plt.figure(figsize=(w/myDPI, h/myDPI), dpi=myDPI) plt.subplot(211) plt.title("histogram algorithm") diff --git a/doc/examples/sparsevid.py b/doc/examples/sparsevid.py index 4bee903..f961bb6 100644 --- a/doc/examples/sparsevid.py +++ b/doc/examples/sparsevid.py @@ -1,13 +1,17 @@ -import skvideo.io -import skvideo.datasets - +import matplotlib.pyplot as plt import numpy as np import scipy -import matplotlib.pyplot as plt -from matplotlib import gridspec import sklearn.linear_model +from matplotlib import gridspec from sklearn.feature_extraction import image +import skvideo.datasets + +try: + xrange +except NameError: + xrange = range + np.random.seed(0) # use greedy K-SVD algorithm with OMP @@ -25,7 +29,7 @@ def dict_step(X, C, D): usedidx = np.abs(C[:, k])>0 if np.sum(usedidx) <= 1: - print "Skipping filter #%d" % (k,) + print("Skipping filter #%d" % (k,)) unused_indices.append(k) continue @@ -109,7 +113,7 @@ def plot_weights(basis): X = X[np.random.permutation(X.shape[0])[:10000]] for i in range(200): - print "Iteration %d / %d" % (i, 200) + print("Iteration %d / %d" % (i, 200)) C = code_step(X, D) D = dict_step(X, C, D) frame = plot_weights(D.reshape(100, 1, 7, 7)) diff --git a/skvideo/measure/scene.py b/skvideo/measure/scene.py index f68865a..dac90d9 100644 --- a/skvideo/measure/scene.py +++ b/skvideo/measure/scene.py @@ -4,13 +4,11 @@ """ import numpy as np -import os import scipy.ndimage import scipy.spatial -import time -from ..utils import * from ..motion.gme import globalEdgeMotion +from ..utils import * def _percentage_distance(canny_in, canny_out, r): @@ -121,7 +119,7 @@ def scenedet(videodata, method='histogram', parameter1=None, min_scene_length=2) "intensity" --> Detects fast cuts using changes in colour and intensity between frames. Parameter1 is the threshold used for detection, which defaults to 30.0. - parameter1 : int + parameter1 : float Number used as a tuning parameter. See method argument for details. min_scene_length : int