if message['command'] == 'get image':
if len(self._images) > 0:
await self.bus.send(Message(self.name,
- {'image': self._images[0]}))
+ {'image': self._images[0][0],
+ 'date': self._images[0][1]}))
elif message['command'] == 'start capture':
self._capture = True
elif message['command'] == 'stop capture':
"""Register plugin as bus client."""
self._images = collections.deque()
self._capture = False
- self._resolution = '1280x720'
+ self._resolution = '1024x768'
if 'resolution' in self.conf:
self._resolution = self.conf['resolution']
self._resize = '640x480'
if 'iso' in self.conf:
self._iso = self.conf['iso']
sends = [MessageTemplate({'event': {'const': 'new image'},
- 'image': {'type': 'string'}}),
- MessageTemplate({'image': {'type': 'string'}})]
+ 'image': {'type': 'string'},
+ 'date': {'type': 'string'}}),
+ MessageTemplate({'image': {'type': 'string'},
+ 'date': {'type': 'string'}})]
receives = [MessageTemplate({'target': {'const': self.name},
'command': {'const': 'get image'}}),
MessageTemplate({'target': {'const': self.name},
camera.awb_gains = gains
while self._capture:
while len(self._images) >= self.conf['keep']:
- filename = self._images.popleft()
+ filename = self._images.popleft()[0]
filepath = os.path.join(self.conf['path'],
filename)
await aiofiles.os.remove(filepath)
stream = io.BytesIO()
camera.capture(stream, 'jpeg', resize=self._resize)
- filename = (datetime.datetime.utcnow()
- .strftime('%Y%m%d%H%M%S%f') + '.jpg')
+ timestamp = datetime.datetime.utcnow()
+ filename = timestamp.strftime('%Y%m%d%H%M%S%f') + '.jpg'
+ filedatetime = timestamp.strftime('%Y-%m-%d %H:%M:%S')
filepath = os.path.join(self.conf['path'], filename)
async with aiofiles.open(filepath, 'wb') as f:
await f.write(stream.getvalue())
stream.close()
- self._images.append(filename)
+ self._images.append((filename, filedatetime))
await self.bus.send(Message(self.name,
{'event': 'new image',
- 'image': filename}))
+ 'image': filename,
+ 'date': filedatetime}))
camera.stop_preview()
await asyncio.sleep(2)
except asyncio.CancelledError:
camera.stop_preview()
camera.close()
while len(self._images) > 0:
- filename = self._images.popleft()
+ filename = self._images.popleft()[0]
filepath = os.path.join(self.conf['path'],
filename)
os.remove(filepath)