Exemple d’usage simple
Importer le module OLIV
import os
import sys
sys.path.append("/path/to/folder/velocimetry-api")
from oliv import *
Charger une vidéo:
lv_param = LoadVideoParams("../tmp/20231020_142415.mp4")
my_video = video.from_file(lv_param)
Extraire une série d’images:
ef_param = ExtractFrameParams(start_index=401, end_index=405, skip_index=1)
my_frame_stack = video.extract_framestack(my_video, ef_param)
Créer, calibrer et vérifier une caméra avec la méthode DLT:
my_grp = ortho.read_GRP_table(file_path="GRP.dat")
my_dlt = ortho.projection_method(AvailableProjection.DLT, my_grp)
dlt_stats = my_dlt.check()
Créer un mapping d’image à partir d’un ROI, de propriété d’image et d’une projection DLT:
my_roi = ROI(xmin=-5.294, ymin=-5.118, xmax=2.395, ymax=3)
ortho_params = OrthoImageParams(roi=my_roi, pixel_size=0.008, z=0.53)
dlt_im_mapping = ortho.image_mapping(method=my_dlt, params=ortho_params)
Créer une série d’ortho-image via le mapping d’image:
my_ortho_frame_stack = ortho.build_orthoimages(my_frame_stack, im_map=dlt_mapping)
Construire une grille de vitesse:
my_grid = grid.from_ij_file("grid.dat", fs_ortho=my_ortho_frame_stack, swap=True)
mask = import_mask("orthomask.png")
my_grid = grid.crop(grid=my_grid, tool=mask)
Calcul des champs de vitesses pour chaque séquence d’image par PIV:
my_piv_param = PIVParams(IA=32, Sim=10, Sjm=10, Sip=10, Sjp=10)
vel_results = motion.compute_piv(fs_in=my_ortho_frame_stack, grid=my_grid, piv_param=my_piv_param)
Créer une liste de filtres pour les champs de vitesse:
f_param1 = FilterVelocityThresholdParams(v_norm=(0, 100), v_x=(-100, 100), v_y=(-100, 100))
f_param2 = FilterCorrelationThresholdParams(c_min=0.4, c_max=0.98)
my_filter_list = [FilterVelocityThreshold(f_param1)]
my_filter_list.append(FilterCorrelationThreshold(f_param2))
Appliquer les filtres au champs de velocimétrie:
filtered_results = post_processing.apply_filters(res_in=vel_results, filter_list=my_filter_list)
Aggréger temporellement les résultats de vélocimétrie:
agg_params = AggregationParams(method=AggregationMethod.MEDIAN, time_filter=[])
avg_results = post_processing.aggregate_results(res_in=vel_results, params=agg_params,
filter_list=my_filter_list)
Importer et re-échantillonner un transect bathymétrique:
my_xs = import_bathymetry(filepath="bathy.dat")
my_xs = resample_bathymetry(xs_bathy=my_xs, dist_max=0.25)
Calcul de débit dans le transect:
xs_param = FlowRateParameters(water_height=0.53, r_x=0.5, r_y=1, n_points=3,
interpolator=VelocityInterpolator.ivp, fill_empty=False)
xs_results = compute_flowrate(res_in=avg_results, xs_bathy=my_xs, params=xs_param)
Affichage des résultats:
plot.plot_velocity_field(vel_res=avg_results, img=my_ortho_frame_stack.imgs[-1], roi=my_roi, xs_res=xs_results)
plot_cross_section_flow(xs_res=xs_results)