예제 #1
0
def extract(videoName, outputBase, dataset):
    """
    Extracts the IDTFs and stores them in outputBase file.
    """
    if not dataset == "Something":
        videoName = videoName[:-4]
        if not os.path.exists(videoName):
            print '%s does not exist!' % videoName
            return False
        print(videoName)
        print(os.path.basename(videoName))
        resizedName = os.path.join(
            tmpDir,
            os.path.basename(videoName) + '/image_%05d.jpg')
        if not ffmpeg.resize(videoName, resizedName):
            resizedName = videoName + '/image_%05d.jpg'  # resize failed, just use the input video
    else:
        if not os.path.exists(videoName):
            print '%s does not exist!' % videoName
            return False
        print(videoName)
        print(os.path.basename(videoName))
        resizedName = os.path.join(tmpDir,
                                   os.path.basename(videoName) + '/%05d.jpg')
        if not ffmpeg.resize(videoName, resizedName):
            resizedName = videoName + '/%05d.jpg'  # resize failed, just use the input video

    subprocess.call('%s %s > %s' % (dtBin, resizedName, outputBase),
                    shell=True)
    return True
예제 #2
0
def extract(videoName, outputBase):
    """
    Extracts the IDTFs and stores them in outputBase file.
    """
    if not os.path.exists(videoName):
        print '%s does not exist!' % videoName
        return False
    resizedName = os.path.join(tmpDir, os.path.basename(videoName))
    if not ffmpeg.resize(videoName, resizedName):
        resizedName = videoName     # resize failed, just use the input video
    subprocess.call('%s %s > %s' % (dtBin, resizedName, outputBase), shell=True)
    return True
예제 #3
0
def extract(videoName, outputBase):
    if not os.path.exists(videoName):
        print '%s does not exist!' % videoName
        return False
    if check_dup(outputBase):
        print '%s processed' % videoName
        return True
    resizedName = os.path.join(tmpDir, os.path.basename(videoName))
    if not ffmpeg.resize(videoName, resizedName):
        resizedName = videoName     # resize failed, just use the input video
    subprocess.call('%s %s | %s %s %s %s %s' % (dtBin, resizedName, tevBin, projMatList, rMeanList, codeBookList, outputBase), shell=True)
    return True
예제 #4
0
def extract(videoName, outputBase):
    """
    Extracts the IDTFs and stores them in outputBase file.
    """
    if not os.path.exists(videoName):
        print '%s does not exist!' % videoName
        return False
    resizedName = os.path.join(tmpDir, os.path.basename(videoName))
    if not ffmpeg.resize(videoName, resizedName):
        resizedName = videoName  # resize failed, just use the input video
    subprocess.call('%s %s > %s' % (dtBin, resizedName, outputBase),
                    shell=True)
    return True
예제 #5
0
def extractFV(videoName, outputBase, gmm_list, dataset):
    """
    Extracts the IDTFs, constructs a Fisher Vector, and saves the Fisher Vector at outputBase
    outputBase: the full path to the newly constructed fisher vector.
    gmm_list: file of the saved list of gmms
    """
    if not dataset == "Something":
        videoName = videoName[:-4]
        if not os.path.exists(videoName):
            print '%s does not exist!' % videoName
            return False
        resizedName = os.path.join(
            tmpDir,
            os.path.basename(videoName) + '/image_%05d.jpg')
        resized_vids = [filename for filename in os.listdir(tmpDir)]
        # resized_vids = [filename for filename in os.listdir(tmpDir) if filename.endswith('.avi')]
        if os.path.basename(videoName) not in resized_vids:
            if not ffmpeg.resize(videoName, resizedName):
                resizedName = videoName + '/image_%05d.jpg'  # resize failed, just use the input video
    else:
        if not os.path.exists(videoName):
            print '%s does not exist!' % videoName
            return False
        resizedName = os.path.join(tmpDir,
                                   os.path.basename(videoName) + '/%05d.jpg')
        resized_vids = [filename for filename in os.listdir(tmpDir)]
        # resized_vids = [filename for filename in os.listdir(tmpDir) if filename.endswith('.avi')]
        if os.path.basename(videoName) not in resized_vids:
            if not ffmpeg.resize(videoName, resizedName):
                resizedName = videoName + '/%05d.jpg'  # resize failed, just use the input video

    print videoName
    subprocess.call('%s %s | %s %s %s' %
                    (dtBin, resizedName, COMPUTE_FV, outputBase, gmm_list),
                    shell=True)
    return True
예제 #6
0
def extractFV(videoName, outputBase,gmm_list):
    """
    Extracts the IDTFs, constructs a Fisher Vector, and saves the Fisher Vector at outputBase
    outputBase: the full path to the newly constructed fisher vector.
    gmm_list: file of the saved list of gmms
    """
    if not os.path.exists(videoName):
        print '%s does not exist!' % videoName
        return False
    resizedName = os.path.join(tmpDir, os.path.basename(videoName))
    resized_vids = [filename for filename in os.listdir(tmpDir) if filename.endswith('.avi')]
    if os.path.basename(videoName) not in resized_vids:
        if not ffmpeg.resize(videoName, resizedName):
            resizedName = videoName     # resize failed, just use the input video
    print videoName
    subprocess.call('%s %s | %s %s %s' % (dtBin, resizedName, COMPUTE_FV, outputBase, gmm_list), shell=True)
    return True
예제 #7
0
                        help="Name of the input desired to test prediction",
                        type=str)
    parser.add_argument(
        '--no_pca',
        dest='no_pca',
        action='store_const',
        const=True,
        default=False,
        help='Testing without PCA reduction (default: uses PCA)')
    args = parser.parse_args()
    video = args.video_name

    vid = os.path.join(video_dir, video)
    if not check_resolution(vid):
        resizedName = os.path.join(tmp_dir, video)
        if ffmpeg.resize(vid, resizedName):
            vid = resizedName
    command = dtBin + ' ' + vid
    p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
    raw_features, _ = p.communicate()
    features = raw_features.split("\n")
    points = []
    for point in features:
        if point != '' and point[
                0] != '[':  #to delete info messages from DenseTrackStab
            points.append(IDT_feature.IDTFeature(point))
    video_desc = IDT_feature.vid_descriptors(points)
    gmm_list = np.load(gmm_list + ".npz")['gmm_list']
    fish = computeFV.create_fisher_vector_unsaved(gmm_list, video_desc)
    if not args.no_pca:
        pca = classify_library.load_model('../data/models/pca.sav')