update eaf package
This commit is contained in:
@@ -24,7 +24,7 @@ from PyQt5.QtGui import QBrush
|
||||
from PyQt5.QtGui import QColor
|
||||
from PyQt5.QtMultimedia import QCameraInfo, QCamera, QCameraImageCapture
|
||||
from PyQt5.QtMultimediaWidgets import QGraphicsVideoItem
|
||||
from PyQt5.QtWidgets import QGraphicsScene, QGraphicsView
|
||||
from PyQt5.QtWidgets import QGraphicsScene, QGraphicsView, QFrame
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout
|
||||
from core.buffer import Buffer
|
||||
from pathlib import Path
|
||||
@@ -34,6 +34,9 @@ import os
|
||||
class AppBuffer(Buffer):
|
||||
def __init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict, module_path):
|
||||
Buffer.__init__(self, buffer_id, url, arguments, emacs_var_dict, module_path, True)
|
||||
|
||||
self.background_color = QColor(0, 0, 0)
|
||||
|
||||
self.add_widget(CameraWidget(QColor(0, 0, 0, 255)))
|
||||
|
||||
def all_views_hide(self):
|
||||
@@ -46,9 +49,12 @@ class AppBuffer(Buffer):
|
||||
|
||||
def take_photo(self):
|
||||
if os.path.exists(os.path.expanduser(self.emacs_var_dict["eaf-camera-save-path"])):
|
||||
self.buffer_widget.take_photo(self.emacs_var_dict["eaf-camera-save-path"])
|
||||
location = self.emacs_var_dict["eaf-camera-save-path"]
|
||||
else:
|
||||
self.buffer_widget.take_photo("~/Downloads")
|
||||
location = "~/Downloads"
|
||||
result = self.buffer_widget.take_photo(location)
|
||||
if result:
|
||||
self.message_to_emacs.emit("Captured Photo at " + location)
|
||||
|
||||
def destroy_buffer(self):
|
||||
self.buffer_widget.stop_camera()
|
||||
@@ -65,13 +71,13 @@ class CameraWidget(QWidget):
|
||||
self.graphics_view = QGraphicsView(self.scene)
|
||||
self.graphics_view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
self.graphics_view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
self.graphics_view.setFrameStyle(0)
|
||||
self.graphics_view.setStyleSheet("QGraphicsView {background: transparent; border: 3px; outline: none;}")
|
||||
self.graphics_view.setFrameStyle(QFrame.NoFrame)
|
||||
self.graphics_view.scale(-1, 1) # this make live video from camero mirror.
|
||||
self.video_item = QGraphicsVideoItem()
|
||||
self.scene.addItem(self.video_item)
|
||||
|
||||
self.layout = QVBoxLayout(self)
|
||||
self.layout.setSpacing(0)
|
||||
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.layout.addWidget(self.graphics_view)
|
||||
|
||||
@@ -93,9 +99,8 @@ class CameraWidget(QWidget):
|
||||
def take_photo(self, camera_save_path):
|
||||
image_capture = QCameraImageCapture(self.camera)
|
||||
save_path = str(Path(os.path.expanduser(camera_save_path)))
|
||||
photo_path = os.path.join(save_path, "EAF_Camera_Photo_" + time.strftime("%Y-%m-%d_%H:%M:%S", time.localtime(int(time.time()))))
|
||||
image_capture.capture(photo_path)
|
||||
self.message_to_emacs.emit("Captured Photo at " + photo_path)
|
||||
photo_path = os.path.join(save_path, "EAF_Camera_Photo_" + time.strftime("%Y%m%d_%H%M%S", time.localtime(int(time.time()))))
|
||||
return image_capture.capture(photo_path)
|
||||
|
||||
def stop_camera(self):
|
||||
self.camera.stop()
|
||||
|
||||
Reference in New Issue
Block a user