├── .editorconfig
├── .gitattributes
├── .github
└── workflows
│ ├── build.yml
│ └── pack-tools.yml
├── .gitignore
├── .nuke
├── build.schema.json
└── parameters.json
├── GitVersion.yml
├── LICENSE
├── README.md
├── assets
├── icon.ico
├── icon.png
├── logo.png
└── sample_image.png
├── build.cmd
├── build.ps1
├── build.sh
├── build
├── .editorconfig
├── BuildBase.cs
├── BuildForDev.cs
├── BuildForRelease.cs
├── BuildUtils.cs
├── Configuration.cs
├── Directory.Build.props
├── Directory.Build.targets
├── PackTools.cs
├── Parameters.cs
├── build.csproj
└── build.csproj.DotSettings
├── depth-estimate-gui.sln
├── lgtm.yml
├── scripts
├── cmapgen.py
├── midas_1kgen.py
└── monodepth2_1kgen.py
└── src
├── App.axaml
├── App.axaml.cs
├── Controls
├── DrawingIcon.axaml
└── DrawingIcon.axaml.cs
├── Core
├── ColorMap.cs
├── Graphic.cs
├── Process.cs
└── ProcessData.cs
├── Program.cs
├── Properties
└── launchSettings.json
├── Styles
└── Generic.axaml
├── Utils
├── FormatFilter.cs
└── UI
│ ├── Commands.cs
│ ├── Converters.cs
│ └── MetroWindow.cs
├── Windows
├── EditorWindow.axaml
├── EditorWindow.axaml.cs
├── LogWindow.axaml
├── LogWindow.axaml.cs
├── MainWindow.axaml
└── MainWindow.axaml.cs
└── depth-estimate-gui.csproj
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 |
3 | root = true
4 |
5 | [*]
6 | insert_final_newline = true
7 | indent_style = space
8 | indent_size = 2
9 | charset = utf-8
10 | trim_trailing_whitespace = true
11 |
12 | [*.cs]
13 | indent_size = 4
14 |
15 | [*.{xaml,axaml}]
16 | indent_size = 4
17 |
18 | [*.py]
19 | indent_size = 4
20 |
21 | # Generated code
22 | [*{_AssemblyInfo.cs,.notsupported.cs}]
23 | generated_code = true
24 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | build:
7 | name: Build
8 |
9 | strategy:
10 | matrix:
11 | target:
12 | - '{"rid":"win-x64","os":"windows-latest"}'
13 | - '{"rid":"linux-x64","os":"ubuntu-latest"}'
14 | - '{"rid":"osx-x64","os":"macos-latest"}'
15 |
16 | runs-on: ${{ fromJson(matrix.target).os }}
17 |
18 | steps:
19 | - name: Checkout
20 | uses: actions/checkout@v2
21 | with:
22 | submodules: recursive
23 | fetch-depth: 0
24 |
25 | - uses: actions/setup-dotnet@v1
26 | with:
27 | dotnet-version: '5.0.x'
28 |
29 | - uses: actions/setup-dotnet@v1
30 | with:
31 | dotnet-version: '6.0.x'
32 | include-prerelease: true
33 |
34 | - name: Build and Pack
35 | run: ./build.cmd PackRelease --configuration Release --runtime ${{ fromJson(matrix.target).rid }}
36 |
37 | - name: Push Artifacts
38 | uses: actions/upload-artifact@v2
39 | with:
40 | name: gui-${{ fromJson(matrix.target).rid }}-${{ github.sha }}
41 | path: dist/depth-estimate-gui.zip
42 |
--------------------------------------------------------------------------------
/.github/workflows/pack-tools.yml:
--------------------------------------------------------------------------------
1 | name: Pack Tools
2 |
3 | on: workflow_dispatch
4 |
5 | jobs:
6 | build:
7 | name: Pack Tools
8 |
9 | strategy:
10 | matrix:
11 | target:
12 | - '{"rid":"win-x64","os":"windows-latest","cuda":"10.2"}'
13 | - '{"rid":"linux-x64","os":"ubuntu-latest","cuda":"10.2"}'
14 | - '{"rid":"win-x64","os":"windows-latest","cuda":"11.1"}'
15 | - '{"rid":"linux-x64","os":"ubuntu-latest","cuda":"11.1"}'
16 | - '{"rid":"win-x64","os":"windows-latest","cuda":"cpuonly"}'
17 | - '{"rid":"linux-x64","os":"ubuntu-latest","cuda":"cpuonly"}'
18 | - '{"rid":"osx-x64","os":"macos-latest","cuda":"cpuonly"}'
19 |
20 | runs-on: ${{ fromJson(matrix.target).os }}
21 |
22 | steps:
23 | - name: Checkout
24 | uses: actions/checkout@v2
25 | with:
26 | submodules: recursive
27 | fetch-depth: 0
28 |
29 | # - name: Maximize build space
30 | # uses: easimon/maximize-build-space@master
31 | # with:
32 | # remove-dotnet: true
33 | # remove-android: true
34 | # remove-haskell: true
35 |
36 | - uses: actions/setup-dotnet@v1
37 | with:
38 | dotnet-version: '5.0.x'
39 |
40 | - uses: actions/setup-dotnet@v1
41 | with:
42 | dotnet-version: '6.0.x'
43 | include-prerelease: true
44 |
45 | - uses: s-weigand/setup-conda@v1
46 |
47 | - name: Build and Pack
48 | run: ./build.cmd PackTools --configuration Release --runtime ${{ fromJson(matrix.target).rid }} --cuda-version ${{ fromJson(matrix.target).cuda }}
49 |
50 | - name: Push Artifacts
51 | uses: actions/upload-artifact@v2
52 | with:
53 | name: tools-${{ fromJson(matrix.target).rid }}-${{ fromJson(matrix.target).cuda }}-${{ github.sha }}
54 | path: dist/depth-estimate-gui-tools.7z
55 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # Tye
66 | .tye/
67 |
68 | # ASP.NET Scaffolding
69 | ScaffoldingReadMe.txt
70 |
71 | # StyleCop
72 | StyleCopReport.xml
73 |
74 | # Files built by Visual Studio
75 | *_i.c
76 | *_p.c
77 | *_h.h
78 | *.ilk
79 | *.meta
80 | *.obj
81 | *.iobj
82 | *.pch
83 | *.pdb
84 | *.ipdb
85 | *.pgc
86 | *.pgd
87 | *.rsp
88 | *.sbr
89 | *.tlb
90 | *.tli
91 | *.tlh
92 | *.tmp
93 | *.tmp_proj
94 | *_wpftmp.csproj
95 | *.log
96 | *.vspscc
97 | *.vssscc
98 | .builds
99 | *.pidb
100 | *.svclog
101 | *.scc
102 |
103 | # Chutzpah Test files
104 | _Chutzpah*
105 |
106 | # Visual C++ cache files
107 | ipch/
108 | *.aps
109 | *.ncb
110 | *.opendb
111 | *.opensdf
112 | *.sdf
113 | *.cachefile
114 | *.VC.db
115 | *.VC.VC.opendb
116 |
117 | # Visual Studio profiler
118 | *.psess
119 | *.vsp
120 | *.vspx
121 | *.sap
122 |
123 | # Visual Studio Trace Files
124 | *.e2e
125 |
126 | # TFS 2012 Local Workspace
127 | $tf/
128 |
129 | # Guidance Automation Toolkit
130 | *.gpState
131 |
132 | # ReSharper is a .NET coding add-in
133 | _ReSharper*/
134 | *.[Rr]e[Ss]harper
135 | *.DotSettings.user
136 |
137 | # JustCode is a .NET coding add-in
138 | .JustCode
139 |
140 | # TeamCity is a build add-in
141 | _TeamCity*
142 |
143 | # DotCover is a Code Coverage Tool
144 | *.dotCover
145 |
146 | # AxoCover is a Code Coverage Tool
147 | .axoCover/*
148 | !.axoCover/settings.json
149 |
150 | # Coverlet is a free, cross platform Code Coverage Tool
151 | coverage*.json
152 | coverage*.xml
153 | coverage*.info
154 |
155 | # Visual Studio code coverage results
156 | *.coverage
157 | *.coveragexml
158 |
159 | # NCrunch
160 | _NCrunch_*
161 | .*crunch*.local.xml
162 | nCrunchTemp_*
163 |
164 | # MightyMoose
165 | *.mm.*
166 | AutoTest.Net/
167 |
168 | # Web workbench (sass)
169 | .sass-cache/
170 |
171 | # Installshield output folder
172 | [Ee]xpress/
173 |
174 | # DocProject is a documentation generator add-in
175 | DocProject/buildhelp/
176 | DocProject/Help/*.HxT
177 | DocProject/Help/*.HxC
178 | DocProject/Help/*.hhc
179 | DocProject/Help/*.hhk
180 | DocProject/Help/*.hhp
181 | DocProject/Help/Html2
182 | DocProject/Help/html
183 |
184 | # Click-Once directory
185 | publish/
186 |
187 | # Publish Web Output
188 | *.[Pp]ublish.xml
189 | *.azurePubxml
190 | # Note: Comment the next line if you want to checkin your web deploy settings,
191 | # but database connection strings (with potential passwords) will be unencrypted
192 | *.pubxml
193 | *.publishproj
194 |
195 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
196 | # checkin your Azure Web App publish settings, but sensitive information contained
197 | # in these scripts will be unencrypted
198 | PublishScripts/
199 |
200 | # NuGet Packages
201 | *.nupkg
202 | # NuGet Symbol Packages
203 | *.snupkg
204 | # The packages folder can be ignored because of Package Restore
205 | **/[Pp]ackages/*
206 | # except build/, which is used as an MSBuild target.
207 | !**/[Pp]ackages/build/
208 | # Uncomment if necessary however generally it will be regenerated when needed
209 | #!**/[Pp]ackages/repositories.config
210 | # NuGet v3's project.json files produces more ignorable files
211 | *.nuget.props
212 | *.nuget.targets
213 |
214 | # Microsoft Azure Build Output
215 | csx/
216 | *.build.csdef
217 |
218 | # Microsoft Azure Emulator
219 | ecf/
220 | rcf/
221 |
222 | # Windows Store app package directories and files
223 | AppPackages/
224 | BundleArtifacts/
225 | Package.StoreAssociation.xml
226 | _pkginfo.txt
227 | *.appx
228 | *.appxbundle
229 | *.appxupload
230 |
231 | # Visual Studio cache files
232 | # files ending in .cache can be ignored
233 | *.[Cc]ache
234 | # but keep track of directories ending in .cache
235 | !?*.[Cc]ache/
236 |
237 | # Others
238 | ClientBin/
239 | ~$*
240 | *~
241 | *.dbmdl
242 | *.dbproj.schemaview
243 | *.jfm
244 | *.pfx
245 | *.publishsettings
246 | orleans.codegen.cs
247 |
248 | # Including strong name files can present a security risk
249 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
250 | #*.snk
251 |
252 | # Since there are multiple workflows, uncomment next line to ignore bower_components
253 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
254 | #bower_components/
255 |
256 | # RIA/Silverlight projects
257 | Generated_Code/
258 |
259 | # Backup & report files from converting an old project file
260 | # to a newer Visual Studio version. Backup files are not needed,
261 | # because we have git ;-)
262 | _UpgradeReport_Files/
263 | Backup*/
264 | UpgradeLog*.XML
265 | UpgradeLog*.htm
266 | ServiceFabricBackup/
267 | *.rptproj.bak
268 |
269 | # SQL Server files
270 | *.mdf
271 | *.ldf
272 | *.ndf
273 |
274 | # Business Intelligence projects
275 | *.rdl.data
276 | *.bim.layout
277 | *.bim_*.settings
278 | *.rptproj.rsuser
279 | *- [Bb]ackup.rdl
280 | *- [Bb]ackup ([0-9]).rdl
281 | *- [Bb]ackup ([0-9][0-9]).rdl
282 |
283 | # Microsoft Fakes
284 | FakesAssemblies/
285 |
286 | # GhostDoc plugin setting file
287 | *.GhostDoc.xml
288 |
289 | # Node.js Tools for Visual Studio
290 | .ntvs_analysis.dat
291 | node_modules/
292 |
293 | # Visual Studio 6 build log
294 | *.plg
295 |
296 | # Visual Studio 6 workspace options file
297 | *.opt
298 |
299 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
300 | *.vbw
301 |
302 | # Visual Studio LightSwitch build output
303 | **/*.HTMLClient/GeneratedArtifacts
304 | **/*.DesktopClient/GeneratedArtifacts
305 | **/*.DesktopClient/ModelManifest.xml
306 | **/*.Server/GeneratedArtifacts
307 | **/*.Server/ModelManifest.xml
308 | _Pvt_Extensions
309 |
310 | # Paket dependency manager
311 | .paket/paket.exe
312 | paket-files/
313 |
314 | # FAKE - F# Make
315 | .fake/
316 |
317 | # JetBrains Rider
318 | .idea/
319 | *.sln.iml
320 |
321 | # CodeRush personal settings
322 | .cr/personal
323 |
324 | # Python Tools for Visual Studio (PTVS)
325 | __pycache__/
326 | *.pyc
327 |
328 | # Cake - Uncomment if you are using it
329 | # tools/**
330 | # !tools/packages.config
331 |
332 | # Tabs Studio
333 | *.tss
334 |
335 | # Telerik's JustMock configuration file
336 | *.jmconfig
337 |
338 | # BizTalk build output
339 | *.btp.cs
340 | *.btm.cs
341 | *.odx.cs
342 | *.xsd.cs
343 |
344 | # OpenCover UI analysis results
345 | OpenCover/
346 |
347 | # Azure Stream Analytics local run output
348 | ASALocalRun/
349 |
350 | # MSBuild Binary and Structured Log
351 | *.binlog
352 |
353 | # NVidia Nsight GPU debugger configuration file
354 | *.nvuser
355 |
356 | # MFractors (Xamarin productivity tool) working folder
357 | .mfractor/
358 |
359 | # Local History for Visual Studio
360 | .localhistory/
361 |
362 | # BeatPulse healthcheck temp database
363 | healthchecksdb
364 |
365 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
366 | MigrationBackup/
367 |
368 | # Ionide (cross platform F# VS Code tools) working folder
369 | .ionide/
370 |
371 | # Fody - auto-generated XML schema
372 | FodyWeavers.xsd
373 |
374 | ##
375 | ## Visual studio for Mac
376 | ##
377 |
378 |
379 | # globs
380 | Makefile.in
381 | *.userprefs
382 | *.usertasks
383 | config.make
384 | config.status
385 | aclocal.m4
386 | install-sh
387 | autom4te.cache/
388 | *.tar.gz
389 | tarballs/
390 | test-results/
391 |
392 | # Mac bundle stuff
393 | *.dmg
394 | *.app
395 |
396 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
397 | # General
398 | .DS_Store
399 | .AppleDouble
400 | .LSOverride
401 |
402 | # Icon must end with two \r
403 | Icon
404 |
405 |
406 | # Thumbnails
407 | ._*
408 |
409 | # Files that might appear in the root of a volume
410 | .DocumentRevisions-V100
411 | .fseventsd
412 | .Spotlight-V100
413 | .TemporaryItems
414 | .Trashes
415 | .VolumeIcon.icns
416 | .com.apple.timemachine.donotpresent
417 |
418 | # Directories potentially created on remote AFP share
419 | .AppleDB
420 | .AppleDesktop
421 | Network Trash Folder
422 | Temporary Items
423 | .apdisk
424 |
425 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
426 | # Windows thumbnail cache files
427 | Thumbs.db
428 | ehthumbs.db
429 | ehthumbs_vista.db
430 |
431 | # Dump file
432 | *.stackdump
433 |
434 | # Folder config file
435 | [Dd]esktop.ini
436 |
437 | # Recycle Bin used on file shares
438 | $RECYCLE.BIN/
439 |
440 | # Windows Installer files
441 | *.cab
442 | *.msi
443 | *.msix
444 | *.msm
445 | *.msp
446 |
447 | # Windows shortcuts
448 | *.lnk
449 |
450 | # JetBrains Rider
451 | .idea/
452 | *.sln.iml
453 |
454 | # Temp files
455 | temp/
456 | dist/
457 |
458 | # Visual Studio Code settings
459 | .vscode/
460 |
--------------------------------------------------------------------------------
/.nuke/build.schema.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "title": "Build Schema",
4 | "$ref": "#/definitions/build",
5 | "definitions": {
6 | "build": {
7 | "type": "object",
8 | "properties": {
9 | "Configuration": {
10 | "type": "string",
11 | "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
12 | "enum": [
13 | "Debug",
14 | "Release"
15 | ]
16 | },
17 | "Continue": {
18 | "type": "boolean",
19 | "description": "Indicates to continue a previously failed build attempt"
20 | },
21 | "CudaVersion": {
22 | "type": "string",
23 | "description": "CUDA Toolkit Version"
24 | },
25 | "Help": {
26 | "type": "boolean",
27 | "description": "Shows the help text for this build assembly"
28 | },
29 | "Host": {
30 | "type": "string",
31 | "description": "Host for execution. Default is 'automatic'",
32 | "enum": [
33 | "AppVeyor",
34 | "AzurePipelines",
35 | "Bamboo",
36 | "Bitrise",
37 | "GitHubActions",
38 | "GitLab",
39 | "Jenkins",
40 | "Rider",
41 | "SpaceAutomation",
42 | "TeamCity",
43 | "Terminal",
44 | "TravisCI",
45 | "VisualStudio",
46 | "VSCode"
47 | ]
48 | },
49 | "NoLogo": {
50 | "type": "boolean",
51 | "description": "Disables displaying the NUKE logo"
52 | },
53 | "Partition": {
54 | "type": "string",
55 | "description": "Partition to use on CI"
56 | },
57 | "Plan": {
58 | "type": "boolean",
59 | "description": "Shows the execution plan (HTML)"
60 | },
61 | "Profile": {
62 | "type": "array",
63 | "description": "Defines the profiles to load",
64 | "items": {
65 | "type": "string"
66 | }
67 | },
68 | "Root": {
69 | "type": "string",
70 | "description": "Root directory during build execution"
71 | },
72 | "Runtime": {
73 | "type": "string",
74 | "description": ".NET Runtime ID"
75 | },
76 | "Skip": {
77 | "type": "array",
78 | "description": "List of targets to be skipped. Empty list skips all dependencies",
79 | "items": {
80 | "type": "string",
81 | "enum": [
82 | "Clean",
83 | "Compile",
84 | "Dev",
85 | "PackProgram",
86 | "PackRelease",
87 | "PackTools",
88 | "Publish",
89 | "Restore"
90 | ]
91 | }
92 | },
93 | "Target": {
94 | "type": "array",
95 | "description": "List of targets to be invoked. Default is '{default_target}'",
96 | "items": {
97 | "type": "string",
98 | "enum": [
99 | "Clean",
100 | "Compile",
101 | "Dev",
102 | "PackProgram",
103 | "PackRelease",
104 | "PackTools",
105 | "Publish",
106 | "Restore"
107 | ]
108 | }
109 | },
110 | "Verbosity": {
111 | "type": "string",
112 | "description": "Logging verbosity during build execution. Default is 'Normal'",
113 | "enum": [
114 | "Minimal",
115 | "Normal",
116 | "Quiet",
117 | "Verbose"
118 | ]
119 | }
120 | }
121 | }
122 | }
123 | }
--------------------------------------------------------------------------------
/.nuke/parameters.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./build.schema.json",
3 | "Solution": "depth-estimate-gui.sln"
4 | }
--------------------------------------------------------------------------------
/GitVersion.yml:
--------------------------------------------------------------------------------
1 | assembly-versioning-scheme: MajorMinorPatchTag
2 | mode: ContinuousDelivery
3 | tag-prefix: 'v'
4 | increment: Patch
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Il Harper
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | > 中文用户可直接左转 [B 站动态](https://t.bilibili.com/587366069405400548)
2 | >
3 | > 如果需要多帧/视频的深度图 或需要 AE 插件的话 可以看看 [Auto Depth](https://www.bilibili.com/video/BV1v44y1Y7va)
4 |
5 |
6 |
7 |

8 |
9 |
Depth Estimate GUI
10 |
11 |
12 |
13 | GUI for generating depth graphics. Use [MiDaS](https://github.com/isl-org/MiDaS) and [monodepth2](https://github.com/nianticlabs/monodepth2). Support Windows, Mac and Linux.
14 |
15 | ## Screenshots
16 |
17 | 
18 |
19 | ## Features
20 |
21 | - [x] Generate depth graphics
22 |
23 | - [x] Use [MiDaS](https://github.com/isl-org/MiDaS) and [monodepth2](https://github.com/nianticlabs/monodepth2)
24 |
25 | - [x] Support common image formats for input/output
26 |
27 | - [x] Support all color maps from [Matplotlib](https://matplotlib.org/stable/tutorials/colors/colormaps.html)
28 |
29 | - [ ] Batch process (TODO)
30 |
31 | ## Matrix
32 |
33 | ### GUI Package Matrix
34 |
35 | Windows x64|macOS x64|Linux x64
36 | -|-|-
37 | `gui-win-x64.zip` (:white_check_mark:)|`gui-osx-x64.zip` (:white_check_mark:)|`gui-linux-x64.zip` (:heavy_check_mark:)
38 |
39 | ### Tools Package Matrix
40 |
41 | |CUDA 10.2|CUDA 11.1|CPU (`cpuonly`)
42 | -|-|-|-
43 | Windows x64|`tools-win-x64-10.2.zip` (:white_check_mark:)|`tools-win-x64-11.1.zip` (:white_check_mark:)|`tools-win-x64-cpuonly.zip` (:white_check_mark:)
44 | macOS x64|:x:|:x:|`tools-osx-x64-cpuonly.zip` (:white_check_mark:)
45 | Linux x64|`tools-linux-x64-10.2.zip` (:heavy_check_mark:)|`tools-linux-x64-11.1.zip` (:heavy_check_mark:)|`tools-linux-x64-cpuonly.zip` (:heavy_check_mark:)
46 |
47 | :white_check_mark:: Tested
48 |
49 | :heavy_check_mark:: Supported
50 |
51 | :x:: Unsupported
52 |
53 | ## Installation
54 |
55 | You need to download 2 packages: **GUI Package** and **Tools Package**. Check the [Matrix](#matrix) section and find the suitable package for your computer.
56 |
57 | If you do not have an NVIDIA graphic card, download the `cpuonly` package. Otherwise, check [CUDA Release Notes](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html) to select CUDA version.
58 |
59 | Go to [Releases](https://github.com/depth-estimate-gui/depth-estimate-gui/releases) to download packages. After downloading these two packages, **unzip** them, **merge** them and then start the `depth-estimate-gui` executable.
60 |
61 | ## BUGs & Issues
62 |
63 | Feel free to [open issues](https://github.com/depth-estimate-gui/depth-estimate-gui/issues/new/choose). Please attach a **log** (`...` -> `Show Log` in editor window) when submitting a bug.
64 |
65 | ## Contributions
66 |
67 | PRs are welcome! Feel free to contribute on this project.
68 |
69 | ## LICENSE
70 |
71 | All files and codes **in this repo** use [MIT LICENSE](https://github.com/depth-estimate-gui/depth-estimate-gui/blob/master/LICENSE). For [MiDaS](https://github.com/isl-org/MiDaS) and [monodepth2](https://github.com/nianticlabs/monodepth2), please check their respective licenses.
72 |
--------------------------------------------------------------------------------
/assets/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilharp/depth-estimate-gui/36b504d37155946afa2249e8435ae440234f5bea/assets/icon.ico
--------------------------------------------------------------------------------
/assets/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilharp/depth-estimate-gui/36b504d37155946afa2249e8435ae440234f5bea/assets/icon.png
--------------------------------------------------------------------------------
/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilharp/depth-estimate-gui/36b504d37155946afa2249e8435ae440234f5bea/assets/logo.png
--------------------------------------------------------------------------------
/assets/sample_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilharp/depth-estimate-gui/36b504d37155946afa2249e8435ae440234f5bea/assets/sample_image.png
--------------------------------------------------------------------------------
/build.cmd:
--------------------------------------------------------------------------------
1 | :; set -eo pipefail
2 | :; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
3 | :; ${SCRIPT_DIR}/build.sh "$@"
4 | :; exit $?
5 |
6 | @ECHO OFF
7 | powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %*
8 |
--------------------------------------------------------------------------------
/build.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding()]
2 | Param(
3 | [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
4 | [string[]]$BuildArguments
5 | )
6 |
7 | Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
8 |
9 | Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
10 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
11 |
12 | ###########################################################################
13 | # CONFIGURATION
14 | ###########################################################################
15 |
16 | $BuildProjectFile = "$PSScriptRoot\build\build.csproj"
17 | $TempDirectory = "$PSScriptRoot\\.nuke\temp"
18 |
19 | $DotNetGlobalFile = "$PSScriptRoot\\global.json"
20 | $DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
21 | $DotNetChannel = "Current"
22 |
23 | $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
24 | $env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
25 | $env:DOTNET_MULTILEVEL_LOOKUP = 0
26 |
27 | ###########################################################################
28 | # EXECUTION
29 | ###########################################################################
30 |
31 | function ExecSafe([scriptblock] $cmd) {
32 | & $cmd
33 | if ($LASTEXITCODE) { exit $LASTEXITCODE }
34 | }
35 |
36 | # If dotnet CLI is installed globally and it matches requested version, use for execution
37 | if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
38 | $(dotnet --version) -and $LASTEXITCODE -eq 0) {
39 | $env:DOTNET_EXE = (Get-Command "dotnet").Path
40 | }
41 | else {
42 | # Download install script
43 | $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
44 | New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
45 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
46 | (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
47 |
48 | # If global.json exists, load expected version
49 | if (Test-Path $DotNetGlobalFile) {
50 | $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
51 | if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
52 | $DotNetVersion = $DotNetGlobal.sdk.version
53 | }
54 | }
55 |
56 | # Install by channel or version
57 | $DotNetDirectory = "$TempDirectory\dotnet-win"
58 | if (!(Test-Path variable:DotNetVersion)) {
59 | ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
60 | } else {
61 | ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
62 | }
63 | $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
64 | }
65 |
66 | Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
67 |
68 | ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
69 | ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
70 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | bash --version 2>&1 | head -n 1
4 |
5 | set -eo pipefail
6 | SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
7 |
8 | ###########################################################################
9 | # CONFIGURATION
10 | ###########################################################################
11 |
12 | BUILD_PROJECT_FILE="$SCRIPT_DIR/build/build.csproj"
13 | TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp"
14 |
15 | DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
16 | DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
17 | DOTNET_CHANNEL="Current"
18 |
19 | export DOTNET_CLI_TELEMETRY_OPTOUT=1
20 | export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
21 | export DOTNET_MULTILEVEL_LOOKUP=0
22 |
23 | ###########################################################################
24 | # EXECUTION
25 | ###########################################################################
26 |
27 | function FirstJsonValue {
28 | perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}"
29 | }
30 |
31 | # If dotnet CLI is installed globally and it matches requested version, use for execution
32 | if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then
33 | export DOTNET_EXE="$(command -v dotnet)"
34 | else
35 | # Download install script
36 | DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
37 | mkdir -p "$TEMP_DIRECTORY"
38 | curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
39 | chmod +x "$DOTNET_INSTALL_FILE"
40 |
41 | # If global.json exists, load expected version
42 | if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
43 | DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")")
44 | if [[ "$DOTNET_VERSION" == "" ]]; then
45 | unset DOTNET_VERSION
46 | fi
47 | fi
48 |
49 | # Install by channel or version
50 | DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
51 | if [[ -z ${DOTNET_VERSION+x} ]]; then
52 | "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
53 | else
54 | "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
55 | fi
56 | export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
57 | fi
58 |
59 | echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)"
60 |
61 | "$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet
62 | "$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"
63 |
--------------------------------------------------------------------------------
/build/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 | dotnet_style_qualification_for_field = false:warning
3 | dotnet_style_qualification_for_property = false:warning
4 | dotnet_style_qualification_for_method = false:warning
5 | dotnet_style_qualification_for_event = false:warning
6 | dotnet_style_require_accessibility_modifiers = never:warning
7 |
8 | csharp_style_expression_bodied_methods = true:silent
9 | csharp_style_expression_bodied_properties = true:warning
10 | csharp_style_expression_bodied_indexers = true:warning
11 | csharp_style_expression_bodied_accessors = true:warning
12 |
--------------------------------------------------------------------------------
/build/BuildBase.cs:
--------------------------------------------------------------------------------
1 | using Nuke.Common;
2 | using Nuke.Common.CI;
3 | using Nuke.Common.Execution;
4 | using Nuke.Common.IO;
5 | using Nuke.Common.Tools.DotNet;
6 | using Nuke.Common.Tools.GitVersion;
7 | using Nuke.Common.Utilities.Collections;
8 | using static Nuke.Common.IO.FileSystemTasks;
9 | using static Nuke.Common.Tools.DotNet.DotNetTasks;
10 |
11 | [CheckBuildProjectConfigurations]
12 | [ShutdownDotNetAfterServerBuild]
13 | partial class Build : NukeBuild
14 | {
15 | public static int Main() => Execute(x => x.Dev);
16 |
17 | [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
18 | readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
19 |
20 | [GitVersion] readonly GitVersion GitVersion;
21 |
22 | AbsolutePath SourceDirectory => RootDirectory / "src";
23 | AbsolutePath DistDirectory => RootDirectory / "dist";
24 | AbsolutePath OutputDirectory => DistDirectory / "depth-estimate-gui";
25 | AbsolutePath ToolsDirectory => OutputDirectory / "tools";
26 |
27 | Target Clean => _ => _
28 | .Before(Restore)
29 | .Executes(() =>
30 | {
31 | SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
32 | EnsureCleanDirectory(DistDirectory);
33 | });
34 |
35 | Target Restore => _ => _
36 | .Executes(() =>
37 | {
38 | DotNetRestore(s => s
39 | .SetProjectFile(SourceDirectory));
40 | });
41 |
42 | Target Compile => _ => _
43 | .DependsOn(Restore)
44 | .Executes(() =>
45 | {
46 | DotNetBuild(s => s
47 | .SetProjectFile(SourceDirectory)
48 | .SetConfiguration(Configuration)
49 | .SetAssemblyVersion(GitVersion.AssemblySemVer)
50 | .SetFileVersion(GitVersion.AssemblySemFileVer)
51 | .SetInformationalVersion(GitVersion.InformationalVersion)
52 | .EnableNoRestore());
53 | });
54 | }
55 |
--------------------------------------------------------------------------------
/build/BuildForDev.cs:
--------------------------------------------------------------------------------
1 | using Nuke.Common;
2 | using Nuke.Common.IO;
3 | using static Nuke.Common.IO.FileSystemTasks;
4 |
5 | // ReSharper disable InvertIf
6 |
7 | partial class Build
8 | {
9 | Target Dev => _ => _
10 | .DependsOn(Compile)
11 | .Executes(() =>
12 | {
13 | Logger.Info("Cleaning output directory.");
14 | EnsureCleanDirectory(OutputDirectory);
15 |
16 | Logger.Info("Packing program.");
17 | ForceCopyDirectoryRecursively(
18 | SourceDirectory / "bin" / Configuration / "net6.0",
19 | OutputDirectory);
20 |
21 | EnsureCleanDataDirectory();
22 |
23 | AbsolutePath localToolsTempDirectory = RootDirectory / "temp" / "tools";
24 | AbsolutePath localCmapTempDirectory = RootDirectory / "temp" / "cmap";
25 |
26 | if (DirectoryExists(localToolsTempDirectory))
27 | {
28 | EnsureCleanDirectory(ToolsDirectory);
29 | ForceCopyDirectoryRecursively(localToolsTempDirectory, ToolsDirectory);
30 | }
31 |
32 | if (DirectoryExists(localCmapTempDirectory))
33 | {
34 | EnsureCleanDirectory(OutputDirectory / "data" / "cmap");
35 | ForceCopyDirectoryRecursively(localCmapTempDirectory, OutputDirectory / "data" / "cmap");
36 | }
37 | });
38 | }
39 |
--------------------------------------------------------------------------------
/build/BuildForRelease.cs:
--------------------------------------------------------------------------------
1 | using System.IO.Compression;
2 | using Nuke.Common;
3 | using Nuke.Common.IO;
4 | using Nuke.Common.Tools.DotNet;
5 | using static Nuke.Common.IO.FileSystemTasks;
6 | using static Nuke.Common.Tools.DotNet.DotNetTasks;
7 |
8 | partial class Build
9 | {
10 | Target Publish => _ => _
11 | .Executes(() =>
12 | {
13 | DotNetPublish(s => s
14 | .SetProject(SourceDirectory)
15 | .SetConfiguration(Configuration)
16 | .SetAssemblyVersion(GitVersion.AssemblySemVer)
17 | .SetFileVersion(GitVersion.AssemblySemFileVer)
18 | .SetInformationalVersion(GitVersion.InformationalVersion)
19 | .SetAuthors("Il Harper")
20 | .SetCopyright("2021 Il Harper")
21 | .SetTitle("Depth Estimate")
22 | .SetDescription("Depth Estimate GUI.")
23 | .SetRepositoryType("git")
24 | .SetRepositoryUrl("https://github.com/depth-estimate-gui/depth-estimate-gui.git")
25 | .SetRuntime(Runtime)
26 | .EnableSelfContained()
27 | .EnablePublishReadyToRun());
28 | // .EnablePublishTrimmed());
29 | });
30 |
31 | Target PackProgram => _ => _
32 | .DependsOn(Publish)
33 | .Executes(() =>
34 | {
35 | Logger.Info("Cleaning output directory.");
36 | EnsureCleanDirectory(OutputDirectory);
37 |
38 | Logger.Info("Packing program.");
39 | ForceCopyDirectoryRecursively(
40 | SourceDirectory / "bin" / Configuration / "net6.0" / Runtime / "publish",
41 | OutputDirectory);
42 |
43 | EnsureCleanDataDirectory();
44 | });
45 |
46 | Target PackRelease => _ => _
47 | .DependsOn(PackProgram)
48 | .Executes(() =>
49 | {
50 | Logger.Info("Compressing dist.");
51 | CompressionTasks.CompressZip(
52 | OutputDirectory,
53 | DistDirectory / "depth-estimate-gui.zip",
54 | compressionLevel: CompressionLevel.SmallestSize);
55 | });
56 | }
57 |
--------------------------------------------------------------------------------
/build/BuildUtils.cs:
--------------------------------------------------------------------------------
1 | using Nuke.Common;
2 | using Nuke.Common.IO;
3 | using Nuke.Common.Tooling;
4 | using static Nuke.Common.IO.FileSystemTasks;
5 | using static Nuke.Common.EnvironmentInfo;
6 |
7 | partial class Build
8 | {
9 | void ForceCopyDirectoryRecursively(string source, string target) =>
10 | CopyDirectoryRecursively(
11 | source,
12 | target,
13 | DirectoryExistsPolicy.Merge,
14 | FileExistsPolicy.OverwriteIfNewer);
15 |
16 | void EnsureCleanDataDirectory()
17 | {
18 | EnsureCleanDirectory(OutputDirectory / "data");
19 | EnsureCleanDirectory(OutputDirectory / "data" / "inputs");
20 | EnsureCleanDirectory(OutputDirectory / "data" / "outputs");
21 | }
22 |
23 | void EnsurePrivilege()
24 | {
25 | if (Platform is not (PlatformFamily.Linux or PlatformFamily.OSX)) return;
26 |
27 | Logger.Info("Configuring privileges.");
28 | ProcessTasks.StartShell(
29 | "sudo chmod -R 777 depth-estimate-gui",
30 | DistDirectory)
31 | .AssertZeroExitCode();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/build/Configuration.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using Nuke.Common.Tooling;
3 |
4 | [TypeConverter(typeof(TypeConverter))]
5 | public class Configuration : Enumeration
6 | {
7 | public static Configuration Debug = new() { Value = nameof(Debug) };
8 | public static Configuration Release = new() { Value = nameof(Release) };
9 |
10 | public static implicit operator string(Configuration configuration) => configuration.Value;
11 | }
12 |
--------------------------------------------------------------------------------
/build/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/build/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/build/PackTools.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Nuke.Common;
6 | using Nuke.Common.IO;
7 | using Nuke.Common.Tooling;
8 | using static Nuke.Common.EnvironmentInfo;
9 | using static Nuke.Common.IO.FileSystemTasks;
10 |
11 | partial class Build
12 | {
13 | Target PackTools => _ => _
14 | .DependsOn(Clean)
15 | .Executes(() =>
16 | {
17 | Logger.Info("Cleaning tools directory.");
18 | EnsureCleanDirectory(ToolsDirectory);
19 |
20 | AbsolutePath tempDirectory = TemporaryDirectory / "tools";
21 | EnsureCleanDirectory(tempDirectory);
22 |
23 | Logger.Info("Ejecting Conda environment.");
24 | ProcessTasks.StartShell(
25 | $"{(Platform is (PlatformFamily.Linux or PlatformFamily.OSX) ? "sudo " : "")}conda create -q -y --copy -p . python=3.7 pytorch torchvision {(CudaVersion == "cpuonly" ? CudaVersion : "cudatoolkit=" + CudaVersion)} opencv matplotlib timm -c pytorch-lts -c conda-forge",
26 | ToolsDirectory)
27 | .AssertZeroExitCode();
28 |
29 | // if (Platform is PlatformFamily.Linux or PlatformFamily.OSX)
30 | // ProcessTasks.StartShell(
31 | // "ln -s ./bin/python ./python",
32 | // ToolsDirectory)
33 | // .AssertZeroExitCode();
34 |
35 | EnsurePrivilege();
36 |
37 | Logger.Info("Downloading core repositories.");
38 |
39 | AbsolutePath monodepthZip = tempDirectory / "monodepth.zip";
40 | AbsolutePath midasZip = tempDirectory / "midas.zip";
41 | AbsolutePath monodepthExtractDir = tempDirectory / "monodepth";
42 | AbsolutePath midasExtractDir = tempDirectory / "midas";
43 | AbsolutePath monodepthTargetDir = ToolsDirectory / "monodepth2";
44 | AbsolutePath midasTargetDir = ToolsDirectory / "midas";
45 |
46 | HttpTasks.HttpDownloadFile(
47 | "https://github.com/nianticlabs/monodepth2/archive/refs/heads/master.zip",
48 | monodepthZip);
49 | CompressionTasks.UncompressZip(monodepthZip, monodepthExtractDir);
50 | ForceCopyDirectoryRecursively(monodepthExtractDir / "monodepth2-master", monodepthTargetDir);
51 |
52 | HttpTasks.HttpDownloadFile(
53 | "https://github.com/isl-org/MiDaS/archive/refs/heads/master.zip",
54 | midasZip);
55 | CompressionTasks.UncompressZip(midasZip, midasExtractDir);
56 | ForceCopyDirectoryRecursively(midasExtractDir / "MiDaS-master", midasTargetDir);
57 |
58 | Logger.Success("Core repositories downloaded.");
59 | Logger.Info("Downloading models.");
60 |
61 | AbsolutePath monodepthModelZip = tempDirectory / "monodepth_model.zip";
62 | AbsolutePath monodepthModelTarget = monodepthTargetDir / "models";
63 | AbsolutePath midasModelTarget = midasTargetDir / "weights" / "dpt_large.pt";
64 |
65 | HttpTasks.HttpDownloadFile(
66 | "https://storage.googleapis.com/niantic-lon-static/research/monodepth2/mono%2Bstereo_1024x320.zip",
67 | monodepthModelZip);
68 | CompressionTasks.UncompressZip(
69 | monodepthModelZip,
70 | monodepthModelTarget);
71 |
72 | HttpTasks.HttpDownloadFile(
73 | "https://github.com/intel-isl/DPT/releases/download/1_0/dpt_large-midas-2f21e586.pt",
74 | midasModelTarget);
75 |
76 | Logger.Success("Model downloaded.");
77 |
78 | Logger.Info("Copying OneKey-Generator scripts.");
79 | AbsolutePath scriptsDir = RootDirectory / "scripts";
80 | CopyFile(scriptsDir / "monodepth2_1kgen.py", monodepthTargetDir / "1kgen.py", FileExistsPolicy.Overwrite);
81 | CopyFile(scriptsDir / "midas_1kgen.py", midasTargetDir / "1kgen.py", FileExistsPolicy.Overwrite);
82 |
83 | Logger.Info("Plotting colormaps.");
84 |
85 | string pathValue = Platform is PlatformFamily.Linux or PlatformFamily.OSX
86 | ? $"{ToolsDirectory / "bin"}:"
87 | : $"{ToolsDirectory};{ToolsDirectory / "Library" / "bin"};{ToolsDirectory / "Scripts"};";
88 | pathValue += Environment.GetEnvironmentVariable("PATH");
89 | IDictionary envOrigin = Environment.GetEnvironmentVariables();
90 | Dictionary env = envOrigin
91 | .Cast()
92 | .ToDictionary(entry => (string)entry.Key, entry => (string)entry.Value);
93 | if (env.ContainsKey("Path"))
94 | env["Path"] = pathValue;
95 | if (env.ContainsKey("PATH"))
96 | env["PATH"] = pathValue;
97 | Logger.Info("Using PATH variable: " + pathValue);
98 |
99 | ProcessTasks.StartProcess(
100 | ToolsDirectory / (Platform == PlatformFamily.Windows ? "python.exe" : "python"),
101 | "cmapgen.py",
102 | scriptsDir,
103 | env)
104 | .AssertZeroExitCode();
105 | AbsolutePath cmapDir = OutputDirectory / "data" / "cmap";
106 | EnsureCleanDirectory(cmapDir);
107 | ForceCopyDirectoryRecursively(scriptsDir / "cmap", cmapDir);
108 |
109 | Logger.Info("Cleaning temporary directory.");
110 | EnsureCleanDirectory(tempDirectory);
111 | Logger.Info("Cleaning conda cache.");
112 | ProcessTasks.StartShell(
113 | $"{(Platform is (PlatformFamily.Linux or PlatformFamily.OSX) ? "sudo " : "")}conda clean -y -a")
114 | .AssertZeroExitCode();
115 |
116 | Logger.Info("Compressing dist.");
117 | // CompressionTasks.CompressZip(
118 | // OutputDirectory,
119 | // DistDirectory / "depth-estimate-gui-tools.zip",
120 | // compressionLevel: CompressionLevel.SmallestSize);
121 | ProcessTasks.StartShell(
122 | $"7z a {DistDirectory / "depth-estimate-gui-tools.7z"} {OutputDirectory} -mx9")
123 | .AssertZeroExitCode();
124 | });
125 | }
126 |
--------------------------------------------------------------------------------
/build/Parameters.cs:
--------------------------------------------------------------------------------
1 | using Nuke.Common;
2 |
3 | partial class Build
4 | {
5 | [Parameter(".NET Runtime ID")]
6 | readonly string Runtime = "win-x64";
7 |
8 | [Parameter("CUDA Toolkit Version")]
9 | readonly string CudaVersion = "11.1";
10 | }
11 |
--------------------------------------------------------------------------------
/build/build.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 | CS0649;CS0169
8 | ..
9 | ..
10 | 1
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/build/build.csproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | DO_NOT_SHOW
3 | DO_NOT_SHOW
4 | DO_NOT_SHOW
5 | DO_NOT_SHOW
6 | Implicit
7 | Implicit
8 | ExpressionBody
9 | 0
10 | NEXT_LINE
11 | True
12 | False
13 | 120
14 | IF_OWNER_IS_SINGLE_LINE
15 | WRAP_IF_LONG
16 | False
17 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
18 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
19 | True
20 | True
21 | True
22 | True
23 | True
24 | True
25 | True
26 | True
27 | True
28 |
--------------------------------------------------------------------------------
/depth-estimate-gui.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30114.105
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "depth-estimate-gui", "src\depth-estimate-gui.csproj", "{A88DE550-F6F7-413C-96EA-FA9F163039D8}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "build", "build\build.csproj", "{0B50DF90-D796-47BE-A93A-C59D3748F1DC}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(SolutionProperties) = preSolution
16 | HideSolutionNode = FALSE
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {A88DE550-F6F7-413C-96EA-FA9F163039D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {A88DE550-F6F7-413C-96EA-FA9F163039D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {A88DE550-F6F7-413C-96EA-FA9F163039D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {A88DE550-F6F7-413C-96EA-FA9F163039D8}.Release|Any CPU.Build.0 = Release|Any CPU
23 | {0B50DF90-D796-47BE-A93A-C59D3748F1DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {0B50DF90-D796-47BE-A93A-C59D3748F1DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {0B50DF90-D796-47BE-A93A-C59D3748F1DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {0B50DF90-D796-47BE-A93A-C59D3748F1DC}.Release|Any CPU.Build.0 = Release|Any CPU
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/lgtm.yml:
--------------------------------------------------------------------------------
1 | extraction:
2 | csharp:
3 | index:
4 | build_command:
5 | - ./build.sh Compile --configuration Release
6 |
--------------------------------------------------------------------------------
/scripts/cmapgen.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from pathlib import Path
3 |
4 | import numpy as np
5 | import matplotlib.pyplot as plt
6 |
7 |
8 | cmaps = [
9 | 'viridis', 'plasma', 'inferno', 'magma', 'cividis',
10 | 'Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds',
11 | 'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu',
12 | 'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', 'YlGn',
13 | 'binary', 'gist_yarg', 'gist_gray', 'gray', 'bone', 'pink',
14 | 'spring', 'summer', 'autumn', 'winter', 'cool', 'Wistia',
15 | 'hot', 'afmhot', 'gist_heat', 'copper',
16 | 'PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu',
17 | 'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic', 'twilight', 'twilight_shifted', 'hsv',
18 | 'Pastel1', 'Pastel2', 'Paired', 'Accent',
19 | 'Dark2', 'Set1', 'Set2', 'Set3',
20 | 'tab10', 'tab20', 'tab20b', 'tab20c',
21 | 'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern',
22 | 'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg',
23 | 'gist_rainbow', 'rainbow', 'jet', 'turbo', 'nipy_spectral',
24 | 'gist_ncar']
25 |
26 |
27 | gradient = np.linspace(0, 1, 256)
28 | gradient = [gradient]*256
29 |
30 |
31 | target_dir = Path(sys.path[0]).resolve() / "cmap"
32 | target_dir.mkdir(exist_ok=True)
33 |
34 |
35 | def plot(item):
36 | plt.imsave(str(target_dir / "{}.png".format(item)), gradient, cmap=item)
37 |
38 |
39 | for cmap_item in cmaps:
40 | plot(cmap_item)
41 | plot("{}_r".format(cmap_item))
42 |
--------------------------------------------------------------------------------
/scripts/midas_1kgen.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import torch
3 | import utils
4 | import cv2
5 | from pathlib import Path
6 |
7 | import matplotlib as mpl
8 | import matplotlib.cm as cm
9 | import numpy as np
10 | import PIL.Image as pil
11 | from torchvision.transforms import Compose
12 | from midas.dpt_depth import DPTDepthModel
13 | from midas.transforms import Resize, NormalizeImage, PrepareForNet
14 |
15 |
16 | def run():
17 | input_name = sys.argv[1]
18 | output_name = sys.argv[2]
19 | colormap_name = sys.argv[3]
20 |
21 | if torch.cuda.is_available():
22 | device = torch.device("cuda")
23 | else:
24 | device = torch.device("cpu")
25 |
26 | root = Path(sys.path[0]).resolve()
27 |
28 | model = DPTDepthModel(
29 | path=str(root / "weights" / "dpt_large.pt"),
30 | backbone="vitl16_384",
31 | non_negative=True,
32 | )
33 | net_w, net_h = 384, 384
34 | resize_mode = "minimal"
35 | normalization = NormalizeImage(
36 | mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])
37 |
38 | transform = Compose(
39 | [
40 | Resize(
41 | net_w,
42 | net_h,
43 | resize_target=None,
44 | keep_aspect_ratio=True,
45 | ensure_multiple_of=32,
46 | resize_method=resize_mode,
47 | image_interpolation_method=cv2.INTER_CUBIC,
48 | ),
49 | normalization,
50 | PrepareForNet(),
51 | ]
52 | )
53 |
54 | model.eval()
55 | model.to(device)
56 |
57 | data_path = root.parent.parent / "data"
58 | input_path = str(data_path / "inputs" / input_name)
59 | output_path = str(data_path / "outputs" / output_name)
60 |
61 | img = utils.read_image(input_path)
62 | img_input = transform({"image": img})["image"]
63 |
64 | with torch.no_grad():
65 | sample = torch.from_numpy(img_input).to(device).unsqueeze(0)
66 | prediction = model.forward(sample)
67 | prediction = (
68 | torch.nn.functional.interpolate(
69 | prediction.unsqueeze(1),
70 | size=img.shape[:2],
71 | mode="bicubic",
72 | align_corners=False,
73 | )
74 | .squeeze()
75 | .cpu()
76 | .numpy()
77 | )
78 |
79 | vmax = np.percentile(prediction, 95)
80 | normalizer = mpl.colors.Normalize(
81 | vmin=prediction.min(), vmax=vmax)
82 | mapper = cm.ScalarMappable(norm=normalizer, cmap=colormap_name)
83 | colormapped_im = (mapper.to_rgba(prediction)[
84 | :, :, :3] * 255).astype(np.uint8)
85 | im = pil.fromarray(colormapped_im)
86 | im.save(output_path)
87 |
88 | print("Done")
89 |
90 |
91 | if __name__ == "__main__":
92 | run()
93 |
--------------------------------------------------------------------------------
/scripts/monodepth2_1kgen.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from pathlib import Path
3 |
4 | import matplotlib as mpl
5 | import matplotlib.cm as cm
6 | import numpy as np
7 | import PIL.Image as pil
8 | import torch
9 | from torchvision import transforms
10 |
11 | import networks
12 |
13 |
14 | def run():
15 | input_name = sys.argv[1]
16 | output_name = sys.argv[2]
17 | colormap_name = sys.argv[3]
18 |
19 | if torch.cuda.is_available():
20 | device = torch.device("cuda")
21 | else:
22 | device = torch.device("cpu")
23 |
24 | root = Path(sys.path[0]).resolve()
25 |
26 | model_path = root / "models"
27 | encoder_path = str(model_path / "encoder.pth")
28 | depth_decoder_path = str(model_path / "depth.pth")
29 |
30 | # LOADING PRETRAINED MODEL
31 | encoder = networks.ResnetEncoder(18, False)
32 | loaded_dict_enc = torch.load(encoder_path, map_location=device)
33 |
34 | # extract the height and width of image that this model was trained with
35 | feed_height = loaded_dict_enc['height']
36 | feed_width = loaded_dict_enc['width']
37 | filtered_dict_enc = {
38 | k: v for k, v in loaded_dict_enc.items() if k in encoder.state_dict()}
39 | encoder.load_state_dict(filtered_dict_enc)
40 | encoder.to(device)
41 | encoder.eval()
42 |
43 | depth_decoder = networks.DepthDecoder(
44 | num_ch_enc=encoder.num_ch_enc, scales=range(4))
45 |
46 | loaded_dict = torch.load(depth_decoder_path, map_location=device)
47 | depth_decoder.load_state_dict(loaded_dict)
48 |
49 | depth_decoder.to(device)
50 | depth_decoder.eval()
51 |
52 | data_path = root.parent.parent / "data"
53 | input_path = str(data_path / "inputs" / input_name)
54 | output_path = str(data_path / "outputs" / output_name)
55 |
56 | with torch.no_grad():
57 | # Load image and preprocess
58 | input_image = pil.open(input_path).convert('RGB')
59 | original_width, original_height = input_image.size
60 | input_image = input_image.resize(
61 | (feed_width, feed_height), pil.LANCZOS)
62 | input_image = transforms.ToTensor()(input_image).unsqueeze(0)
63 |
64 | # PREDICTION
65 | input_image = input_image.to(device)
66 | features = encoder(input_image)
67 | outputs = depth_decoder(features)
68 |
69 | disp = outputs[("disp", 0)]
70 | disp_resized = torch.nn.functional.interpolate(
71 | disp, (original_height, original_width), mode="bilinear", align_corners=False)
72 |
73 | # Saving colormapped depth image
74 | prediction = disp_resized.squeeze().cpu().numpy()
75 | vmax = np.percentile(prediction, 95)
76 | normalizer = mpl.colors.Normalize(
77 | vmin=prediction.min(), vmax=vmax)
78 | mapper = cm.ScalarMappable(norm=normalizer, cmap=colormap_name)
79 | colormapped_im = (mapper.to_rgba(prediction)[
80 | :, :, :3] * 255).astype(np.uint8)
81 | im = pil.fromarray(colormapped_im)
82 | im.save(output_path)
83 |
84 | print('Done')
85 |
86 |
87 | if __name__ == '__main__':
88 | run()
89 |
--------------------------------------------------------------------------------
/src/App.axaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/App.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls.ApplicationLifetimes;
3 | using Avalonia.Markup.Xaml;
4 | using DepthEstimateGui.Windows;
5 |
6 | namespace DepthEstimateGui
7 | {
8 | public class App : Application
9 | {
10 | public override void Initialize()
11 | {
12 | AvaloniaXamlLoader.Load(this);
13 | }
14 |
15 | public override void OnFrameworkInitializationCompleted()
16 | {
17 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
18 | desktop.MainWindow = new MainWindow();
19 |
20 | base.OnFrameworkInitializationCompleted();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Controls/DrawingIcon.axaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
9 |
10 |
11 |
12 |
13 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Controls/DrawingIcon.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls.Primitives;
3 | using Avalonia.Media;
4 |
5 | namespace DepthEstimateGui.Controls
6 | {
7 | public class DrawingIcon : TemplatedControl
8 | {
9 | #region Constructor
10 |
11 | static DrawingIcon()
12 | {
13 | WidthProperty.OverrideDefaultValue(16);
14 | HeightProperty.OverrideDefaultValue(16);
15 | }
16 |
17 | #endregion
18 |
19 | #region Icon
20 |
21 | public static readonly StyledProperty IconProperty =
22 | AvaloniaProperty.Register(nameof(Icon));
23 |
24 | public Drawing Icon
25 | {
26 | get => GetValue(IconProperty);
27 | set => SetValue(IconProperty, value);
28 | }
29 |
30 | #endregion
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Core/ColorMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using Avalonia.Media.Imaging;
6 |
7 | namespace DepthEstimateGui.Core
8 | {
9 | public class ColorMap
10 | {
11 | #region Data
12 |
13 | public ColorMap(Bitmap image, string name)
14 | {
15 | Image = image;
16 | Name = name;
17 | }
18 |
19 | public Bitmap Image { get; }
20 |
21 | public string Name { get; }
22 |
23 | #endregion
24 |
25 | #region Static
26 |
27 | private static List? _mapList;
28 |
29 | public static List MapList
30 | {
31 | get
32 | {
33 | if (_mapList is not null) return _mapList;
34 |
35 | _mapList = Directory.EnumerateFiles(
36 | Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data", "cmap"))
37 | .Select(x => new ColorMap(new(x), Path.GetFileNameWithoutExtension(x)))
38 | .ToList();
39 | return _mapList;
40 | }
41 | }
42 |
43 | #endregion
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Core/Graphic.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using ReactiveUI;
4 |
5 | namespace DepthEstimateGui.Core
6 | {
7 | public partial class Graphic : ReactiveObject, IDisposable
8 | {
9 | public Guid Id = Guid.NewGuid();
10 |
11 | public Graphic(string path)
12 | {
13 | SourceName = path;
14 | _sourceExt = Path.GetExtension(path);
15 | InputPath = GraphicStorage.GetInputFilePath(InputName);
16 | File.Copy(path, InputPath);
17 | }
18 |
19 | public string SourceName { get; }
20 |
21 | private readonly string _sourceExt;
22 |
23 | private string InputName => Id + _sourceExt;
24 |
25 | public string InputPath;
26 |
27 | public void Dispose()
28 | {
29 | _processComplete.Dispose();
30 | }
31 | }
32 |
33 | public static class GraphicStorage
34 | {
35 | private static readonly string InputDir =
36 | Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data", "inputs");
37 |
38 | private static readonly string OutputDir =
39 | Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data", "outputs");
40 |
41 | public static void EnsureDirectoryExists()
42 | {
43 | Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data"));
44 | Directory.CreateDirectory(InputDir);
45 | Directory.CreateDirectory(OutputDir);
46 | }
47 |
48 | public static string GetInputFilePath(string name)
49 | {
50 | EnsureDirectoryExists();
51 | return Path.Combine(InputDir, name);
52 | }
53 |
54 | public static string GetOutputFilePath(string name)
55 | {
56 | EnsureDirectoryExists();
57 | return Path.Combine(OutputDir, name);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/Core/Process.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Reactive.Subjects;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using CliWrap;
10 | using ReactiveUI;
11 |
12 | namespace DepthEstimateGui.Core
13 | {
14 | public partial class Graphic
15 | {
16 | private bool _isProcessing;
17 |
18 | public bool IsProcessing
19 | {
20 | get => _isProcessing;
21 | set => this.RaiseAndSetIfChanged(ref _isProcessing, value);
22 | }
23 |
24 | public void Process(ProcessSettings settings)
25 | {
26 | if (IsProcessing)
27 | throw new InvalidOperationException("Already processing.");
28 |
29 | IsProcessing = true;
30 | Task.Run(() => ProcessIntl(settings));
31 | }
32 |
33 | private readonly Subject _processComplete = new();
34 |
35 | public IObservable ProcessComplete => _processComplete;
36 |
37 | private async Task ProcessIntl(ProcessSettings settings)
38 | {
39 | bool isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT;
40 |
41 | // Prepare paths
42 | string rootPath = AppDomain.CurrentDomain.BaseDirectory;
43 | string toolsPath = Path.Combine(rootPath, "tools");
44 | string pythonPath = Path.Combine(
45 | rootPath,
46 | isWindows ? "tools\\python.exe" : "tools/bin/python");
47 | string corePath = Path.Combine(rootPath, "tools", settings.Core);
48 | string outputName = $"{Id}.{settings.Ext}";
49 |
50 | // Prepare environment variables
51 | string pathValue = isWindows
52 | ? $"{toolsPath};{Path.Combine(toolsPath, "Library", "bin")};{Path.Combine(toolsPath, "Scripts")};"
53 | : $"{Path.Combine(toolsPath, "bin")}:";
54 | pathValue += Environment.GetEnvironmentVariable("PATH");
55 | IDictionary envOrigin = Environment.GetEnvironmentVariables();
56 | Dictionary env = envOrigin
57 | .Cast()
58 | .ToDictionary(entry => (string)entry.Key, entry => (string?)entry.Value);
59 | if (env.ContainsKey("Path"))
60 | env["Path"] = pathValue;
61 | if (env.ContainsKey("PATH"))
62 | env["PATH"] = pathValue;
63 |
64 | GraphicStorage.EnsureDirectoryExists();
65 |
66 | // Start process
67 | StringBuilder output = new();
68 | CommandResult result = await Cli
69 | .Wrap(pythonPath)
70 | .WithArguments(
71 | $"{(isWindows ? "" : "./")}1kgen.py {InputName} {outputName} {settings.ColorMap.Name}")
72 | .WithWorkingDirectory(corePath)
73 | .WithEnvironmentVariables(env)
74 | .WithValidation(CommandResultValidation.None)
75 | .WithStandardOutputPipe(PipeTarget.ToStringBuilder(output))
76 | .WithStandardErrorPipe(PipeTarget.ToStringBuilder(output))
77 | .ExecuteAsync();
78 |
79 | IsProcessing = false;
80 | _processComplete.OnNext(new(GraphicStorage.GetOutputFilePath(outputName), output.ToString(),
81 | result.ExitCode, result.RunTime));
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/Core/ProcessData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using ReactiveUI;
4 |
5 | namespace DepthEstimateGui.Core
6 | {
7 | public class ProcessSettings : ReactiveObject, ICloneable
8 | {
9 | public ProcessSettings(
10 | string core = "MiDaS",
11 | ColorMap? colorMap = null,
12 | string ext = "png")
13 | {
14 | _core = core;
15 | _colorMap = colorMap ?? ColorMap.MapList.Single(x => x.Name == "Greys_r");
16 | _ext = ext;
17 | }
18 |
19 | private string _core;
20 |
21 | public string Core
22 | {
23 | get => _core;
24 | set => this.RaiseAndSetIfChanged(ref _core, value);
25 | }
26 |
27 | private ColorMap _colorMap;
28 |
29 | public ColorMap ColorMap
30 | {
31 | get => _colorMap;
32 | set => this.RaiseAndSetIfChanged(ref _colorMap, value);
33 | }
34 |
35 | private string _ext;
36 |
37 | public string Ext
38 | {
39 | get => _ext;
40 | set => this.RaiseAndSetIfChanged(ref _ext, value);
41 | }
42 |
43 | public object Clone() => new ProcessSettings(Core, ColorMap, Ext);
44 | }
45 |
46 | public class ProcessResult
47 | {
48 | public ProcessResult(
49 | string outputPath,
50 | string log,
51 | int exitCode,
52 | TimeSpan runTime)
53 | {
54 | OutputPath = outputPath;
55 | Log = log;
56 | ExitCode = exitCode;
57 | RunTime = runTime;
58 | }
59 |
60 | public readonly string OutputPath;
61 | public readonly string Log;
62 | public readonly int ExitCode;
63 | public readonly TimeSpan RunTime;
64 |
65 | public string Summary => $"{(ExitCode == 0 ? "Completed" : "Error occurred")} in {RunTime}";
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Avalonia;
3 | using Avalonia.Threading;
4 | using ReactiveUI;
5 |
6 | namespace DepthEstimateGui
7 | {
8 | public static class Program
9 | {
10 | [STAThread]
11 | public static void Main(string[] args)
12 | {
13 | // Magic - github.com/AvaloniaUI/Avalonia/issues/1934
14 | RxApp.MainThreadScheduler = AvaloniaScheduler.Instance;
15 |
16 | // Build Avalonia app
17 | BuildAvaloniaApp()
18 | .StartWithClassicDesktopLifetime(args);
19 | }
20 |
21 | private static AppBuilder BuildAvaloniaApp()
22 | => AppBuilder.Configure()
23 | .UsePlatformDetect()
24 | .UseSkia()
25 | .LogToTrace();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "single": {
4 | "commandName": "Project"
5 | },
6 | "pack": {
7 | "commandName": "Executable",
8 | "executablePath": "..\\..\\..\\..\\dist\\depth-estimate-gui\\depth-estimate-gui.exe"
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Styles/Generic.axaml:
--------------------------------------------------------------------------------
1 |
3 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Utils/FormatFilter.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Avalonia.Controls;
3 |
4 | namespace DepthEstimateGui.Utils
5 | {
6 | public static class FormatFilter
7 | {
8 | public static readonly List PilOpenFormatFilter = new()
9 | {
10 | new()
11 | {
12 | Name = "All Picture Files",
13 | Extensions = new()
14 | {
15 | "png",
16 | "bmp",
17 | "dib",
18 | "jpg",
19 | "jpeg",
20 | "jpe",
21 | "jfif",
22 | "dds",
23 | "tif",
24 | "tiff",
25 | "webp"
26 | }
27 | },
28 | new()
29 | {
30 | Name = "PNG",
31 | Extensions = new()
32 | {
33 | "png"
34 | }
35 | },
36 | new()
37 | {
38 | Name = "Bitmap Files",
39 | Extensions = new()
40 | {
41 | "bmp",
42 | "dib"
43 | }
44 | },
45 | new()
46 | {
47 | Name = "JPEG",
48 | Extensions = new()
49 | {
50 | "jpg",
51 | "jpeg",
52 | "jpe",
53 | "jfif"
54 | }
55 | },
56 | new()
57 | {
58 | Name = "DDS",
59 | Extensions = new()
60 | {
61 | "dds"
62 | }
63 | },
64 | new()
65 | {
66 | Name = "TIFF",
67 | Extensions = new()
68 | {
69 | "tif",
70 | "tiff"
71 | }
72 | },
73 | new()
74 | {
75 | Name = "WEBP",
76 | Extensions = new()
77 | {
78 | "webp"
79 | }
80 | },
81 | new()
82 | {
83 | Name = "All Files",
84 | Extensions = new()
85 | {
86 | "*"
87 | }
88 | }
89 | };
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/Utils/UI/Commands.cs:
--------------------------------------------------------------------------------
1 | using System.Reactive;
2 | using Avalonia.Controls;
3 | using ReactiveUI;
4 |
5 | namespace DepthEstimateGui.Utils.UI
6 | {
7 | public static class Commands
8 | {
9 | public static ReactiveCommand