# command lines To save the online youtube video of the land slide (need the pytube package) # 'pip install pytube' on the cmd prompt # You may run this script for any video link from youtube yt = YouTube("https://www.youtube.com/watch?time_continue=2&v=5-nyAz484WA") stre = yt.streams.first() # stre.download(folder_main) # %% # if the video has been correctly downloaded you may run this commands to load the video name. vidName = stre.default_filename vidPath = folder_main + '/' + vidName landSlide = opyf.videoAnalyzer(vidPath) #%% landSlide.set_vlim([0, 20]) landSlide.set_vecTime(Ntot=10, shift=2) landSlide.set_filtersParams(maxDevInRadius=1) landSlide.extractGoodFeaturesAndDisplacements() #%% And now to draw a FIeld landSlide.extractGoodFeaturesPositionsDisplacementsAndInterpolate() #%% optional by loading the mask landSlide = opyf.videoAnalyzer(vidPath, mask=folder_main + '/mask.png') landSlide.extractGoodFeaturesPositionsDisplacementsAndInterpolate()
os.chdir("./") # if opyf is not installed where is the opyf folder? sys.path.append('../../') import opyf import matplotlib.pyplot as plt #On ipython try the magic command "%matplotlib qt5" for external outputs or "%matplotlib inline" for inline outputs plt.close('all') #Path toward the video file filePath='./2018.07.04_Station_fixe_30m_sample.mp4' #set the object information video=opyf.videoAnalyzer(filePath) ''' this manipualtion create an object [video] that contains information deduced from the video file. #if it is a frame sequence use: {opyf.frameSequenceAnalyzer(path)} and type the "path" where images are. ''' #%% ###################### video.set_vecTime(Ntot=10,shift=1,step=2,starting_frame=20) print(video.vec,'\n',video.prev) """ #Use .set_vecTime vector to define the processing plan #This method define video.vec and video.prev, two vecotrs required for the image processing: # (by default {.set_vecttTime(starting_frame=0, step=1, shift=1, Ntot=1)}
#%% # %matplotlib qt5 import sys, os os.chdir(os.path.dirname(os.path.abspath(__file__))) import opyf import cv2 import numpy as np import matplotlib.pyplot as plt plt.close('all') #%% video = opyf.videoAnalyzer('IMG_1139.MOV') #extract a a picture to build a mask # cv2.imwrite('for_mask_1142.png',video.vis) video.set_vecTime(Ntot=25, starting_frame=200) video.set_interpolationParams(Sharpness=2) video.set_goodFeaturesToTrackParams(qualityLevel=0.01) # video.set_filtersParams(CLAHE=True, maxDevInRadius=2, minNperRadius=5, wayBackGoodFlag=1,RadiusF=15) mask = cv2.imread('mask_1139.png') A = mask > 100 video.set_stabilization(mask=A[:, :, 0], mute=False) image_points = np.array( [