Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
OSError exception
Browse files Browse the repository at this point in the history
  • Loading branch information
patquem committed Sep 6, 2022
1 parent 4351a6f commit 10da8e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
17 changes: 12 additions & 5 deletions pyVSNR/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def vsnr2d(img, filters, nite=20, beta=10., nblocks='auto'):
u0 = img.flatten()
u = np.zeros_like(u0)

psis_p = (c_float * len(psis))(*psis)
u0_p = (c_float * len(u0))(*u0)
u_p = (c_float * len(u))(*u)
psis_ = (c_float * len(psis))(*psis)
u0_ = (c_float * len(u0))(*u0)
u_ = (c_float * len(u))(*u)

# 'auto' nblocks definition
nblocks_max = get_nblocks()
Expand All @@ -92,9 +92,16 @@ def vsnr2d(img, filters, nite=20, beta=10., nblocks='auto'):

# calculation
vmax = u0.max()
get_vsnr2d()(psis_p, length, u0_p, n0, n1, nite, beta, u_p, nblocks, vmax)
try:
get_vsnr2d()(psis_, length, u0_, n0, n1, nite, beta, u_, nblocks, vmax)
except OSError:
dir_path = os.path.dirname(os.path.realpath(__file__))
msg = '\n!!! Problem when running the cuda libvsnr2d.dll !!!\n'
msg += 'You probably need to recompile the .dll\n'
msg += f'See the README.txt for compilation instructions in {dir_path}'
print(msg)

# reshaping
img_corr = np.array(u_p).reshape(n0, n1).astype(float)
img_corr = np.array(u_).reshape(n0, n1).astype(float)

return img_corr
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pyVSNR
version = 1.0.1
version = 1.0.2
maintainer = Patrick QUEMERE
maintainer_email = [email protected]
description = VSNR algorithm for image destripping
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="pyVSNR",
version='1.0.0',
version='1.0.2',
license='GPLv3',
setup_requires=['setuptools_scm'],
include_package_data=True,
Expand Down

0 comments on commit 10da8e3

Please sign in to comment.