-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvideocapture.py
67 lines (40 loc) · 1.25 KB
/
videocapture.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 14 16:06:02 2019
@author: Evangelos Tzardis
"""
import mylibrary as mlb
import rw_config as cfg
import imageio
import numpy as np
import os
from time import sleep, time
def init_camera():
# read config file
section= 'image sequence config'
keys = ['height','width']
settings = cfg.read_config(section, keys)
num = 0
# Init camera, set configurations
nodes = mlb.run_camera(num)
return [nodes, settings]
cam_nodes, cam_settings = init_camera()
subfolder = '\\videoframes\\m'
folder = os.path.dirname(os.path.realpath(__file__)) + subfolder
if not os.path.exists(folder):
os.makedirs(folder)
rows = cam_settings[0] # Look at init_camera() --> keys --> order of elements
cols = cam_settings[1]
height = 500
#
image_stack = np.zeros([height, rows, cols])
cam = cam_nodes[0]
mlb.begin_acquisition(cam)
for j in range(height):
image_stack[j] = mlb.grab_next_image_by_trigger(cam)
sleep(1/24)
del cam
mlb.release_camera(cam_nodes)
for j in range(height):
fn = '\\' + str(j) + '.tiff'
imageio.imsave(folder + fn, image_stack[j])