Skip to content

Commit c96119d

Browse files
authored
Merge pull request #187 from saeugetier/185-apply-background-removal-to-captured-images
Background removal filter will be applied on captures images and saved with background removed.
2 parents d196df4 + adbba7b commit c96119d

11 files changed

Lines changed: 12969 additions & 71 deletions

models/yolo11l-seg.onnx

Lines changed: 12694 additions & 0 deletions
Large diffs are not rendered by default.

models/yolo11n-seg.onnx

-7.99 MB
Binary file not shown.

qml.qrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
<file>shaders/fisheye.frag.qsb</file>
9595
<file>shaders/previewshader.frag</file>
9696
<file>shaders/previewshader.frag.qsb</file>
97-
<file>models/yolo11n-seg.onnx</file>
9897
<file>models/coco.names</file>
9998
</qresource>
10099
</RCC>

qml/content/CameraRenderer.qml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,18 @@ Item {
6060
id: imageCapture
6161

6262
onImageSaved: (_, fileName) => {
63-
renderer.state = "preview"
64-
savedPhoto("file:" + fileName)
65-
console.log("Saved: " + fileName)
63+
64+
if(backgroundFilterEnabled)
65+
{
66+
console.log("Process file: " + fileName)
67+
backgroundFilter.processCapture(fileName)
68+
}
69+
else
70+
{
71+
renderer.state = "preview"
72+
savedPhoto("file:" + fileName)
73+
console.log("Saved: " + fileName)
74+
}
6675
}
6776
onImageCaptured: {
6877
whiteOverlay.state = "released"
@@ -108,6 +117,16 @@ Item {
108117
ReplaceBackgroundVideoFilter {
109118
id: backgroundFilter
110119
videoSink: output.videoSink
120+
background: "qrc:/images/backgrounds/pexels-pixabay-259915.jpg"
121+
122+
onCaptureProcessingFinished: {
123+
console.log("Capture processing finished")
124+
if (backgroundFilterEnabled) {
125+
renderer.state = "preview"
126+
savedPhoto("file:" + fileName)
127+
console.log("Saved: " + fileName)
128+
}
129+
}
111130
}
112131

113132
Connections {
@@ -203,6 +222,10 @@ Item {
203222
state = "snapshot"
204223
console.log(applicationSettings.foldername.toString())
205224
var path = applicationSettings.foldername.toString()
225+
if(backgroundFilterEnabled)
226+
{
227+
path = path + "/raw"
228+
}
206229
path = path.replace(/^(file:\/{2})/, "")
207230
var cleanPath = decodeURIComponent(path)
208231
console.log(cleanPath)
@@ -215,6 +238,12 @@ Item {
215238
}
216239
}
217240

241+
BusyIndicator {
242+
id: busyIndicator
243+
anchors.centerIn: parent
244+
visible: false
245+
}
246+
218247
states: [
219248
State {
220249
name: "idle"
@@ -229,6 +258,10 @@ Item {
229258
target: shutterButton
230259
state: "idle"
231260
}
261+
PropertyChanges {
262+
target: busyIndicator
263+
visible: false
264+
}
232265
StateChangeScript {
233266
script: {
234267
camera.start()
@@ -246,7 +279,11 @@ Item {
246279
name: "store"
247280
PropertyChanges {
248281
target: whiteOverlay
249-
state: "released"
282+
state: "processing"
283+
}
284+
PropertyChanges {
285+
target: busyIndicator
286+
visible: true
250287
}
251288
}
252289
]

qml/content/WhiteOverlay.qml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ Rectangle {
1313
opacity: 1.0
1414
}
1515
},
16+
State {
17+
name: "processing"
18+
PropertyChanges {
19+
target: rect
20+
opacity: 0.5
21+
}
22+
},
1623
State {
1724
name: "released"
1825
PropertyChanges {

qtbooth.pro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ SOURCES += src/collageiconmodel.cpp \
2727
src/translationhelper.cpp \
2828
src/yolo11seg.cpp
2929

30-
RESOURCES += qml.qrc
30+
RESOURCES += qml.qrc \
31+
yolomodel.large.qrc \
32+
yolomodel.small.qrc
3133

3234
# Additional import path used to resolve QML modules in Qt Creator's code model
3335
QML_IMPORT_PATH =

src/filesystem.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ void FileSystem::checkImageFolders()
8989
{
9090
QDir().mkdir(collagePath);
9191
}
92+
QString rawPath = imagePath + "/raw";
93+
if(!QDir(rawPath).exists())
94+
{
95+
QDir().mkdir(rawPath);
96+
}
9297
}
9398

9499
bool FileSystem::removableDriveMounted()

0 commit comments

Comments
 (0)