Usage examples :

Detect shot in a video

  • Using ShotDetector class :
from import ShotDetector,HistogramExtractor

v = Video("file:///tmp/myvideo.avi"video_uri,begin=0,end=42)
sd = ShotDetector()
cuts,diss = sd.process(v)
  • Using command line :
python -m [-i input_dir] [-o output] [option]
usage  :
Options :
-s      : save histogram feature in numpy format with filename videofile.mpg.npy
-e .avi : video file extension default is .mpg
-d file : debug file, print log in file

Scene clustering using gist descriptor

Using cut detection, you can produce a SVG graph to display a scene clustering :

from import Video
from import gistClustering
from import VideoDendogram

video = Video("file:///tmp/6min.avi")

gc = gistClustering()
clust = gc.getcluster(video)
vd = VideoDendogram(gc,video)

Encode video segment

from import Video
from import html5_Encoder,MPEG2_FAAC_AVI_Encoder
video = Video("file:///tmp/6min.avi",begin=12.28,end=12.96)
he = html5_Encoder(video)
mf = MPEG2_FAAC_AVI_Encoder(video)

Extract frames

from import Video
from import FrameExtractor

video = Video("file:///tmp/6min.avi")
fe = FrameExtractor(video)

Compute Video Features

To list available video descriptors :

from import Video
v = Video("file:///tmp/2min.avi")

output :

['histogramsampled4drgba', 'histogramrgb', 'gist', 'bindct','goodfeaturestotrack','surf','sift']

Get video histogram

Compute video histogram of 15 seconds (between 45 and 60) of video

from import Video
v = Video("file:///tmp/2min.avi",begin=45,end=60)

Results one histogram per frame in a numpy array

Get video histogram on frame 10,20,30

kwargs = {'framefilter' : [10,20,30] }
histos = v.get_feature('histogramrgb',**kwargs)

Get video sifts

Compute video sift of 5 seconds (between 45 and 50) of video

from import Video
v = Video("file:///tmp/2min.avi",begin=45,end=50)

Results sift array per frame

Get image sifts

Compute sift on image lenna.png ::
from pimpy.image import Image im = Image() im.load(“/tmp/lenna.png”) s = im.get_feature(‘sift’)

Video content based retrieval

Request a segment of 15 seconds (between 60 and 75) between two videos

from import Video
from  import ContentBasedRetrieval

target  = Video("file:///tmp/6min.avi")
request = Video("file:///tmp/2min_low_quality.flv",begin=60,end=75 )

#Init CBR engine
c = ContentBasedRetrieval(target)


Output is the frame number