Preview mirrors image

This commit is contained in:
Balthasar Reuter
2018-03-31 20:33:26 +02:00
parent fb62d2fdb2
commit 235c795a75
3 changed files with 6 additions and 8 deletions

View File

@@ -15,9 +15,9 @@ class CameraOpenCV(Camera):
self.hasPreview = True self.hasPreview = True
self.hasIdle = False self.hasIdle = False
# self._cap = cv2.VideoCapture(0) self._cap = cv2.VideoCapture(0)
# if not self._cap.isOpened(): if not self._cap.isOpened():
# raise RuntimeError('Camera could not be opened') raise RuntimeError('Camera could not be opened')
def getPreview(self): def getPreview(self):

View File

@@ -10,7 +10,7 @@ from PyQt5Gui import PyQt5Gui
from CameraOpenCV import CameraOpenCV as Camera from CameraOpenCV import CameraOpenCV as Camera
from PIL import Image from PIL import Image, ImageOps
from multiprocessing import Pipe, Process from multiprocessing import Pipe, Process
@@ -71,7 +71,7 @@ class Photobooth:
while toc < pose_time: while toc < pose_time:
self._send.send( Gui.PreviewState( self._send.send( Gui.PreviewState(
message = str(pose_time - int(toc)), message = str(pose_time - int(toc)),
picture = self._cap.getPreview() ) ) picture = ImageOps.mirror(self._cap.getPreview()) ) )
toc = time() - tic toc = time() - tic
else: else:
for i in range(pose_time): for i in range(pose_time):

View File

@@ -60,11 +60,9 @@ class PyQt5Gui(Gui.Gui):
elif isinstance(state, Gui.PoseState): elif isinstance(state, Gui.PoseState):
self._p.setCentralWidget(PyQt5PictureMessage('Will capture 4 pictures!')) self._p.setCentralWidget(PyQt5PictureMessage('Will capture 4 pictures!'))
elif isinstance(state, Gui.PreviewState): elif isinstance(state, Gui.PreviewState):
# img = QImage(state.picture, state.picture.shape[1], state.picture.shape[0], QImage.Format_RGB888)
img = ImageQt.ImageQt(state.picture) img = ImageQt.ImageQt(state.picture)
self._p.setCentralWidget(PyQt5PictureMessage(state.message, img)) self._p.setCentralWidget(PyQt5PictureMessage(state.message, img))
elif isinstance(state, Gui.PictureState): elif isinstance(state, Gui.PictureState):
# img = QImage(state.picture, state.picture.shape[1], state.picture.shape[0], QImage.Format_RGB888)
img = ImageQt.ImageQt(state.picture) img = ImageQt.ImageQt(state.picture)
self._p.setCentralWidget(PyQt5PictureMessage('', img)) self._p.setCentralWidget(PyQt5PictureMessage('', img))
elif isinstance(state, Gui.ErrorState): elif isinstance(state, Gui.ErrorState):
@@ -88,7 +86,7 @@ class PyQt5Gui(Gui.Gui):
def showIdle(self): def showIdle(self):
self._p.handleKeypressEvent = self.handleKeypressEvent self._p.handleKeypressEvent = self.handleKeypressEvent
self._p.setCentralWidget(PyQt5PictureMessage('Hit the button!', 'homer.jpg')) self._p.setCentralWidget(PyQt5PictureMessage('Hit the button!'))#, 'homer.jpg'))
def showError(self, title, message): def showError(self, title, message):