Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Pope
ftl
Commits
6263dcc5
Commit
6263dcc5
authored
5 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Switch reconstruct to use new configure code
parent
0cc07689
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
reconstruct/CMakeLists.txt
+2
-2
2 additions, 2 deletions
reconstruct/CMakeLists.txt
reconstruct/src/main.cpp
+5
-88
5 additions, 88 deletions
reconstruct/src/main.cpp
with
7 additions
and
90 deletions
reconstruct/CMakeLists.txt
+
2
−
2
View file @
6263dcc5
...
...
@@ -4,14 +4,14 @@ include_directories(${PROJECT_SOURCE_DIR}/reconstruct/include)
set
(
REPSRC
../common/cpp/src/config.cpp
src/main.cpp
)
add_executable
(
ftl-reconstruct
${
REPSRC
}
)
add_dependencies
(
ftl-reconstruct ftlnet
)
add_dependencies
(
ftl-reconstruct ftlcommon
)
#target_include_directories(cv-node PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries
(
ftl-reconstruct Threads::Threads ZLIB::ZLIB
${
OpenCV_LIBS
}
glog::glog ftlnet ftlrender
)
target_link_libraries
(
ftl-reconstruct
ftlcommon
Threads::Threads ZLIB::ZLIB
${
OpenCV_LIBS
}
glog::glog ftlnet ftlrender
)
This diff is collapsed.
Click to expand it.
reconstruct/src/main.cpp
+
5
−
88
View file @
6263dcc5
...
...
@@ -6,13 +6,12 @@
#include
<glog/logging.h>
#include
<ftl/config.h>
#include
<ftl/configuration.hpp>
#include
<zlib.h>
// #include <lz4.h>
#include
<string>
#include
<map>
#include
<vector>
#include
<fstream>
#include
<thread>
#include
<chrono>
#include
<mutex>
...
...
@@ -33,90 +32,17 @@
using
ftl
::
net
::
Universe
;
using
ftl
::
Display
;
using
ftl
::
config
;
using
std
::
string
;
using
std
::
vector
;
using
std
::
map
;
using
cv
::
Mat
;
using
json
=
nlohmann
::
json
;
using
std
::
ifstream
;
using
std
::
this_thread
::
sleep_for
;
using
std
::
chrono
::
milliseconds
;
using
std
::
mutex
;
using
std
::
unique_lock
;
// Store loaded configuration
static
json
config
;
/**
* Find and load a JSON configuration file
*/
static
bool
findConfiguration
(
const
string
&
file
)
{
ifstream
i
;
if
(
file
!=
""
)
i
.
open
(
file
);
if
(
!
i
.
is_open
())
i
.
open
(
"./config.json"
);
if
(
!
i
.
is_open
())
i
.
open
(
FTL_LOCAL_CONFIG_ROOT
"/config.json"
);
if
(
!
i
.
is_open
())
i
.
open
(
FTL_GLOBAL_CONFIG_ROOT
"/config.json"
);
if
(
!
i
.
is_open
())
return
false
;
i
>>
config
;
config
=
config
[
"representation"
];
return
true
;
}
/**
* Generate a map from command line option to value
*/
map
<
string
,
string
>
read_options
(
char
***
argv
,
int
*
argc
)
{
map
<
string
,
string
>
opts
;
while
(
*
argc
>
0
)
{
string
cmd
((
*
argv
)[
0
]);
if
(
cmd
[
0
]
!=
'-'
)
break
;
size_t
p
;
if
((
p
=
cmd
.
find
(
"="
))
==
string
::
npos
)
{
opts
[
cmd
.
substr
(
2
)]
=
"true"
;
}
else
{
opts
[
cmd
.
substr
(
2
,
p
-
2
)]
=
cmd
.
substr
(
p
+
1
);
}
(
*
argc
)
--
;
(
*
argv
)
++
;
}
return
opts
;
}
/**
* Put command line options into json config. If config element does not exist
* or is of a different type then report an error.
*/
static
void
process_options
(
const
map
<
string
,
string
>
&
opts
)
{
for
(
auto
opt
:
opts
)
{
if
(
opt
.
first
==
"config"
)
continue
;
if
(
opt
.
first
==
"version"
)
{
std
::
cout
<<
"FTL Vision Node - v"
<<
FTL_VERSION
<<
std
::
endl
;
std
::
cout
<<
FTL_VERSION_LONG
<<
std
::
endl
;
exit
(
0
);
}
try
{
auto
ptr
=
json
::
json_pointer
(
"/"
+
opt
.
first
);
// TODO(nick) Allow strings without quotes
auto
v
=
json
::
parse
(
opt
.
second
);
if
(
v
.
type
()
!=
config
.
at
(
ptr
).
type
())
{
LOG
(
ERROR
)
<<
"Incorrect type for argument "
<<
opt
.
first
;
continue
;
}
config
.
at
(
ptr
)
=
v
;
}
catch
(...)
{
LOG
(
ERROR
)
<<
"Unrecognised option: "
<<
opt
.
first
;
}
}
}
static
void
run
(
const
string
&
file
)
{
static
void
run
()
{
Universe
net
(
config
[
"net"
]);
Mat
rgb
,
depth
,
Q
;
mutex
m
;
...
...
@@ -188,16 +114,7 @@ static void run(const string &file) {
}
int
main
(
int
argc
,
char
**
argv
)
{
argc
--
;
argv
++
;
// Process Arguments
auto
options
=
read_options
(
&
argv
,
&
argc
);
if
(
!
findConfiguration
(
options
[
"config"
]))
{
LOG
(
FATAL
)
<<
"Could not find any configuration!"
;
}
process_options
(
options
);
run
((
argc
>
0
)
?
argv
[
0
]
:
""
);
ftl
::
configure
(
argc
,
argv
,
"representation"
);
// TODO(nick) change to "reconstruction"
run
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment