1 from pyforms.terminal.Controls.ControlBase import ControlBase
2 import numpy
3 import cv2
4 import base64
5 import numpy as np
6 import StringIO
7 from PIL import Image
12 _currentFrame = None
13 _min = 0
14 _max = 0
15 _filename = ''
16 _position = 0
17
19 self._currentFrame = None
20 return "controls.push(new ControlPlayer('"+self._name+"'));"
21
23
25
27
28 - def save(self, data): pass
29
30 - def load(self, data): pass
31
33
35 currentMilliseconds = (frame / self.value.videoFrameRate) * 1000
36 totalseconds = int(currentMilliseconds/1000)
37 minutes = int(totalseconds / 60)
38 seconds = totalseconds - (minutes*60)
39 milliseconds = currentMilliseconds - (totalseconds*1000)
40 return ( minutes, seconds, milliseconds )
41
43
45
47
49
51
52
53 @property
55 result = {'min': self._min, 'max': self._max, 'position': self.video_index, 'frame': '', 'filename': self._filename }
56 capture = self._value
57
58 _, image = capture.read()
59 if isinstance(image, numpy.ndarray):
60 image = self.processFrame(image)
61
62 if isinstance(image, list) or isinstance(image, tuple):
63 image = groupImage(image, True)
64
65
66 if len(image.shape)>2: image = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
67 image = Image.fromarray(image)
68 buff = StringIO.StringIO()
69 image.save(buff, format="PNG")
70 content = buff.getvalue()
71 buff.close()
72 result['frame'] = base64.b64encode(content)
73
74 return result
75
76 @value.setter
86
87
88
89 @property
91
92 @video_index.setter
94
95
96
97 @property
99 if self._value: return self._value.startFrame
100 else: return -1
101
102 @startFrame.setter
104
105 @property
107 if self._value: return self._value.startFrame
108 else: return -1
109
110 @endFrame.setter
112
113
114
115 @property
117
118 @image.setter
119 - def image(self, value): pass
120