Skip to content

Commit

Permalink
improve API, Python >= 3.5 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Nov 8, 2017
1 parent 0faa78a commit 28bf8f7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
4 changes: 3 additions & 1 deletion HornSchunck.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# -*- coding: future_fstrings -*-
"""
./HornSchunck.py data/box/box
./HornSchunck.py data/office/office
Expand All @@ -16,7 +17,8 @@
FILTER = 7

def demo(stem):
flist,ext = getimgfiles(stem)
flist = getimgfiles(stem)
ext = flist[0].suffix

for i in range(len(flist)-1):
fn1 = f'{stem}.{i}{ext}'
Expand Down
4 changes: 3 additions & 1 deletion LucasKanade.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# -*- coding: future_fstrings -*-
"""
./LucasKanade.py data/box/box
./LucasKanade.py data/office/office
Expand All @@ -13,7 +14,8 @@
from pyoptflow.plots import compareGraphsLK

def demo(stem, kernel=5,Nfilter=7):
flist,ext = getimgfiles(stem)
flist = getimgfiles(stem)
ext = flist[0].suffix
#%% priming read
im1 = imread(f'{stem}.0{ext}', flatten=True)
Y,X = im1.shape
Expand Down
5 changes: 3 additions & 2 deletions pyoptflow/io.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: future_fstrings -*-
from pathlib import Path

def getimgfiles(stem):
Expand All @@ -7,7 +8,7 @@ def getimgfiles(stem):
exts = ['.ppm','.bmp','.png','.jpg']
for ext in exts:
pat = f'{name}.*{ext}'
print(f'searching {path}/{pat}')
print(f'searching {path/pat}')
flist = sorted(path.glob(pat))
if flist:
break
Expand All @@ -17,4 +18,4 @@ def getimgfiles(stem):

print(f'analyzing {len(flist)} files {stem}.*{ext}')

return flist,ext
return flist
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
#!/usr/bin/env python
req = ['nose','setuptools','pillow','scipy','numpy']
pipreq = ['future-fstrings']
ereq = ['matplotlib']
# %%
import pip
try:
import conda.cli
conda.cli.main('install',*req)
except Exception:
import pip
pip.main(['install'] + req)
pip.main(['install'] + pipreq)
# %%
from setuptools import setup

setup(name='pyoptflow',
packages=['pyoptflow'],
author='Michael Hirsch, Ph.D.',
url='https://github.com/scivision/pyoptflow',
version='1.0.0',
version='1.1.0',
classifiers=[
'Topic :: Scientific/Engineering',
'Development Status :: 3 - Alpha',
'Programming Language :: Python :: 3',
],
install_requires=req,
install_requires = req + pipreq,
extras_require={'plot':ereq},
description='Pure Python optical flow: Horn-Schunck, Lucas-Kanade',
)
4 changes: 2 additions & 2 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def test_lucaskanade():
print(V)

def test_io():
im1 = pio.getimgfiles(RDIR/'data/box/box')
print()
flist = pio.getimgfiles(RDIR/'data/box/box')
print(flist)



Expand Down

0 comments on commit 28bf8f7

Please sign in to comment.