def main(): with sample_video() as video: db = scannerpy.Database() [shots] = shot_detection.detect_shots(db, videos=[video]) montage_img = video.montage(shots) imwrite('sample_shots.jpg', montage_img) print('Wrote shot montage to {}'.format(os.path.abspath('sample_shots.jpg')))
def main(): with sample_video() as video: db = scannerpy.Database() frames = [0, 100, 200] [bboxes] = face_detection.detect_faces(db, videos=[video], frames=[frames]) [clothing] = clothing_detection.detect_clothing(db, videos=[video], frames=[frames], bboxes=[bboxes]) print(next(clothing.load())[0])
def database(self, retries=3, **kwargs): while True: try: return scannerpy.Database(master=self.master_address(), start_cluster=False, **kwargs) except scannerpy.ScannerException: if retries == 0: raise else: retries -= 1
def main(): with sample_video() as video: db = scannerpy.Database() frames = list(range(10)) bboxes = face_detection.detect_faces(db, videos=[video], frames=[frames]) embeddings = face_embedding.embed_faces(db, videos=[video], frames=[frames], bboxes=bboxes) print('First embedding: {}'.format(next(embeddings[0].load()))) print('Finished computing embeddings')
def main(): with sample_video() as video: db = scannerpy.Database() frames = list(range(50)) bboxes = face_detection.detect_faces(db, videos=[video], frames=[frames]) genders = gender_detection.detect_genders(db, videos=[video], frames=[frames], bboxes=bboxes) print('First gender: {}'.format(next(genders[0].load()))) print('Finished computing genders')
def db(): cfg = scannerpy.Config.default_config() cfg['network']['master'] = 'localhost' cfg['storage']['db_path'] = tempfile.mkdtemp() with tempfile.NamedTemporaryFile() as cfg_f: cfg_f.write(bytes(toml.dumps(cfg), 'utf-8')) cfg_f.flush() with scannerpy.Database(config_path=cfg_f.name) as db: yield db shutil.rmtree(cfg['storage']['db_path'])
def main(): with sample_video() as video: db = scannerpy.Database() frames = [0, 100, 200] poses = pose_detection.detect_poses(db, videos=[video], frames=[frames]) vis.draw_poses(db, videos=[video], poses=poses, frames=[frames], path='sample_poses.mp4') print('Wrote video with poses drawn to {}'.format( os.path.abspath('sample_poses.mp4')))
def main(): with sample_video() as video: db = scannerpy.Database() frames = list(range(50)) bboxes = face_detection.detect_faces(db, videos=[video], frames=[frames]) vis.draw_bboxes(db, videos=[video], frames=[frames], bboxes=bboxes, paths=['sample_faces.mp4']) print('Wrote video with objects drawn to {}'.format( os.path.abspath('sample_faces.mp4')))
def main(): with sample_video() as video: db = scannerpy.Database() frames = list(range(0, 20, 3)) print('Running object detector') [bboxes] = object_detection.detect_objects(db, videos=[video], frames=[frames]) print('Running bbox visualizer') vis.draw_bboxes(db, videos=[video], frames=[frames], bboxes=[bboxes], paths=['sample_objects.mp4']) print('Wrote video with objects drawn to {}'.format( os.path.abspath('sample_objects.mp4')))
from scannertools import pose_detection, vis, sample_video import scannerpy import os with sample_video() as video: db = scannerpy.Database() frames = [0, 100, 200] poses = pose_detection.detect_poses(db, videos=[video], frames=[frames]) vis.draw_poses(db, videos=[video], poses=poses, frames=[frames], path='sample_poses.mp4') print('Wrote video with poses drawn to {}'.format(os.path.abspath('sample_poses.mp4')))
def database(self): return scannerpy.Database(master=self.master_address(), start_cluster=False)