Skip to content

Commit

Permalink
add numpy.uint16 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazare committed Jun 12, 2018
1 parent 4420f7a commit 28a0ef4
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 34 deletions.
8 changes: 2 additions & 6 deletions benchmarks/bench_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@
# Author: Todd Goodall <[email protected]>
# 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
Expand All @@ -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()
Expand Down
8 changes: 6 additions & 2 deletions benchmarks/bench_vread.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
# Author: Todd Goodall <[email protected]>
# 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__":

Expand Down
7 changes: 3 additions & 4 deletions doc/examples/IOcorrupt.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions doc/examples/motion_charts.py
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
5 changes: 3 additions & 2 deletions doc/examples/outputdictexample.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
13 changes: 8 additions & 5 deletions doc/examples/scene_parse.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
18 changes: 11 additions & 7 deletions doc/examples/sparsevid.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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))
Expand Down
6 changes: 2 additions & 4 deletions skvideo/measure/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 28a0ef4

Please sign in to comment.