mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
WIP: Use CameraView for UM camera feeds
CURA-5821 The original implementation that refreshes a QImage seems to cause memory overflow on MacOSX and Windows. This is a different implementation. It doesn't cause memory overflow, but it does consume a lot of CPU power.
This commit is contained in:
parent
b00ea4719a
commit
9d07409cce
3 changed files with 31 additions and 26 deletions
|
@ -5,6 +5,7 @@ import QtQuick 2.2
|
|||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import UM 1.3 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
Item {
|
||||
property var camera: null;
|
||||
|
@ -33,11 +34,11 @@ Item {
|
|||
z: 999;
|
||||
}
|
||||
|
||||
Image {
|
||||
Cura.CameraView {
|
||||
id: cameraImage
|
||||
anchors.horizontalCenter: parent.horizontalCenter;
|
||||
anchors.verticalCenter: parent.verticalCenter;
|
||||
height: Math.round((sourceSize.height === 0 ? 600 * screenScaleFactor : sourceSize.height) * width / sourceSize.width);
|
||||
height: Math.round((imageHeight === 0 ? 600 * screenScaleFactor : imageHeight) * width / imageWidth);
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
if (camera != null) {
|
||||
|
@ -49,13 +50,18 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
source: {
|
||||
if (camera != null && camera.latestImage != null) {
|
||||
return camera.latestImage;
|
||||
|
||||
Connections
|
||||
{
|
||||
target: camera
|
||||
onNewImage: {
|
||||
if (cameraImage.visible) {
|
||||
cameraImage.image = camera.latestImage;
|
||||
cameraImage.update();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
width: Math.min(sourceSize.width === 0 ? 800 * screenScaleFactor : sourceSize.width, maximumWidth);
|
||||
width: Math.min(imageWidth === 0 ? 800 * screenScaleFactor : imageWidth, maximumWidth);
|
||||
z: 1
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue