我正在研究openPIV的示例代码。该版本是最新版本(openpiv-python-master)。我有一个错误;
AttributeError:“模块”对象没有属性“验证”
尽管我设置了路径,但似乎openPIV无法找到validation.py。
你能告诉我如何解决吗?
import openpiv.tools
import openpiv.process
import openpiv.scaling
import numpy as np
import sys
sys.path.append('/Users/myname/openpiv-python-master/openpiv')
filedir = '/Users/myname/tutorial-part1/'
frame_a = openpiv.tools.imread( filedir + 'exp1_001_a.bmp' )
frame_b = openpiv.tools.imread( filedir + 'exp1_001_b.bmp' )
u, v, sig2noise = openpiv.process.extended_search_area_piv( frame_a.astype(np.int32), frame_b.astype(np.int32), window_size=24, overlap=12, dt=0.02, search_area_size=64, sig2noise_method='peak2peak' )
x, y = openpiv.process.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=12 )
u, v, mask = openpiv.validation.sig2noise_val( u, v, sig2noise, threshold = 1.3 )
u, v = openpiv.filters.replace_outliers( u, v, method='localmean', max_iter=10, kernel_size=2)
x, y, u, v = openpiv.scaling.uniform(x, y, u, v, scaling_factor = 96.52 )
openpiv.tools.save(x, y, u, v, mask, 'exp1_001.txt' )
openpiv.tools.display_vector_field('exp1_001.txt', scale=100, width=0.0025)
最佳答案
我有同样的错误。您只需要将其导入示例代码中即可。只需添加这些行。
import openpiv.validation
import openpiv.filters