@@ -4,6 +4,7 @@ import QtQuick.Controls
44import Qt5Compat.GraphicalEffects
55import QtQuick.Layouts
66import BackgroundFilter
7+ import CaptureProcessor
78
89Item {
910 id: renderer
@@ -41,6 +42,29 @@ Item {
4142 }
4243 }
4344
45+ CaptureProcessor
46+ {
47+ id: captureProcessor
48+
49+ rotation: applicationSettings .cameraOrientation
50+
51+ onCaptureSaved : fileName =>
52+ {
53+
54+ if (backgroundFilterEnabled)
55+ {
56+ console .log (" Process file: " + fileName)
57+ backgroundFilter .processCapture (fileName)
58+ }
59+ else
60+ {
61+ renderer .state = " preview"
62+ savedPhoto (" file:" + fileName)
63+ console .log (" Saved: " + fileName)
64+ }
65+ }
66+ }
67+
4468 CaptureSession {
4569
4670 camera: Camera {
@@ -60,25 +84,25 @@ Item {
6084 imageCapture: ImageCapture {
6185 id: imageCapture
6286
63- onImageSaved : (_ , fileName ) => {
64-
65- if (backgroundFilterEnabled)
66- {
67- console .log (" Process file: " + fileName)
68- backgroundFilter .processCapture (fileName)
69- }
70- else
87+ onImageCaptured:
7188 {
72- renderer .state = " preview"
73- savedPhoto (" file:" + fileName)
74- console .log (" Saved: " + fileName)
89+ whiteOverlay .state = " released"
90+ renderer .state = " store"
91+ console .log (" Captured" )
92+
93+ console .log (applicationSettings .foldername .toString ())
94+ var path = applicationSettings .foldername .toString ()
95+ if (backgroundFilterEnabled)
96+ {
97+ path = path + " /raw"
98+ }
99+ path = path .replace (/ ^ (file:\/ {2} )/ , " " )
100+ var cleanPath = decodeURIComponent (path)
101+ console .log (cleanPath)
102+
103+ captureProcessor .saveCapture (preview, cleanPath + " /Pict_" + new Date ().toLocaleString (
104+ locale, " dd_MM_yyyy_hh_mm_ss" ) + " .jpg" )
75105 }
76- }
77- onImageCaptured: {
78- whiteOverlay .state = " released"
79- renderer .state = " store"
80- console .log (" Captured" )
81- }
82106 onErrorOccurred: {
83107 renderer .state = " preview"
84108 failed ()
@@ -120,14 +144,15 @@ Item {
120144 videoSink: output .videoSink
121145 background: backgroundImage
122146
123- onCaptureProcessingFinished: {
124- console .log (" Capture processing finished" )
125- if (backgroundFilterEnabled) {
126- renderer .state = " preview"
127- savedPhoto (" file:" + fileName)
128- console .log (" Saved: " + fileName)
129- }
130- }
147+ onCaptureProcessingFinished : fileName =>
148+ {
149+ console .log (" Capture processing finished" )
150+ if (backgroundFilterEnabled) {
151+ renderer .state = " preview"
152+ savedPhoto (" file:" + fileName)
153+ console .log (" Saved: " + fileName)
154+ }
155+ }
131156 }
132157
133158 Connections {
@@ -221,28 +246,17 @@ Item {
221246 function takePhoto () {
222247 if (cameraSession .imageCapture .readyForCapture ) {
223248 state = " snapshot"
224- console .log (applicationSettings .foldername .toString ())
225- var path = applicationSettings .foldername .toString ()
226- if (backgroundFilterEnabled)
227- {
228- path = path + " /raw"
229- }
230- path = path .replace (/ ^ (file:\/ {2} )/ , " " )
231- var cleanPath = decodeURIComponent (path)
232- console .log (cleanPath)
233- cameraSession .imageCapture .captureToFile (
234- cleanPath + " /Pict_" + new Date ().toLocaleString (
235- locale, " dd_MM_yyyy_hh_mm_ss" ) + " .jpg" )
249+ cameraSession .imageCapture .capture ()
236250 } else {
237251 renderer .state = " preview"
238252 failed ()
239253 }
240254 }
241255
242256 BusyIndicator {
243- id: busyIndicator
244- anchors .centerIn : parent
245- visible: false
257+ id: busyIndicator
258+ anchors .centerIn : parent
259+ visible: false
246260 }
247261
248262 states: [
0 commit comments