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
Admin message
Maintenance on Monday 31.3. at 13:00. ETA 60 - 90 minutes.
Show more breadcrumbs
Nicolas Pope
ftl
Commits
2c378133
Commit
2c378133
authored
6 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
All force no stereo
parent
b9af9f0f
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
cv-node/include/ftl/local.hpp
+3
-2
3 additions, 2 deletions
cv-node/include/ftl/local.hpp
cv-node/src/calibrate.cpp
+17
-12
17 additions, 12 deletions
cv-node/src/calibrate.cpp
cv-node/src/local.cpp
+8
-7
8 additions, 7 deletions
cv-node/src/local.cpp
cv-node/src/main.cpp
+6
-3
6 additions, 3 deletions
cv-node/src/main.cpp
with
34 additions
and
24 deletions
cv-node/include/ftl/local.hpp
+
3
−
2
View file @
2c378133
...
...
@@ -11,8 +11,8 @@ namespace cv {
namespace
ftl
{
class
LocalSource
{
public:
LocalSource
(
bool
flip
=
false
);
LocalSource
(
const
std
::
string
&
vid
,
bool
flip
=
false
);
LocalSource
(
bool
flip
=
false
,
bool
nostereo
=
false
);
LocalSource
(
const
std
::
string
&
vid
,
bool
flip
=
false
,
bool
nostereo
=
false
);
bool
left
(
cv
::
Mat
&
m
);
bool
right
(
cv
::
Mat
&
m
);
...
...
@@ -30,6 +30,7 @@ class LocalSource {
bool
stereo_
;
//float fps_;
bool
flip_
;
bool
nostereo_
;
cv
::
VideoCapture
*
camera_a_
;
cv
::
VideoCapture
*
camera_b_
;
};
...
...
This diff is collapsed.
Click to expand it.
cv-node/src/calibrate.cpp
+
17
−
12
View file @
2c378133
...
...
@@ -321,15 +321,18 @@ bool Calibrate::_recalibrate(vector<vector<Point2f>> *imagePoints,
//view = _nextImage(cam);
LOG
(
INFO
)
<<
"Grabbing calibration image..."
;
if
(
view
[
0
].
empty
()
||
view
[
1
].
empty
()
||
imagePoints
[
0
].
size
()
>=
(
size_t
)
settings_
.
nrFrames
)
{
if
(
view
[
0
].
empty
()
||
(
local_
->
isStereo
()
&&
view
[
1
].
empty
()
)
||
imagePoints
[
0
].
size
()
>=
(
size_t
)
settings_
.
nrFrames
)
{
settings_
.
outputFileName
=
FTL_CONFIG_ROOT
"/cam0.xml"
;
bool
r
=
runCalibrationAndSave
(
settings_
,
imageSize
[
0
],
cameraMatrix
[
0
],
distCoeffs
[
0
],
imagePoints
[
0
],
grid_width
,
release_object
);
settings_
.
outputFileName
=
FTL_CONFIG_ROOT
"/cam1.xml"
;
r
&=
runCalibrationAndSave
(
settings_
,
imageSize
[
1
],
cameraMatrix
[
1
],
distCoeffs
[
1
],
imagePoints
[
1
],
grid_width
,
release_object
);
if
(
local_
->
isStereo
())
{
settings_
.
outputFileName
=
FTL_CONFIG_ROOT
"/cam1.xml"
;
r
&=
runCalibrationAndSave
(
settings_
,
imageSize
[
1
],
cameraMatrix
[
1
],
distCoeffs
[
1
],
imagePoints
[
1
],
grid_width
,
release_object
);
}
if
(
!
r
&&
view
[
0
].
empty
())
{
LOG
(
ERROR
)
<<
"Not enough frames to calibrate"
;
...
...
@@ -351,7 +354,7 @@ bool Calibrate::_recalibrate(vector<vector<Point2f>> *imagePoints,
bool
found1
,
found2
;
found1
=
findChessboardCorners
(
view
[
0
],
settings_
.
boardSize
,
pointBuf
[
0
],
chessBoardFlags
);
found2
=
findChessboardCorners
(
view
[
1
],
settings_
.
boardSize
,
pointBuf
[
1
],
chessBoardFlags
);
found2
=
!
local_
->
isStereo
()
||
findChessboardCorners
(
view
[
1
],
settings_
.
boardSize
,
pointBuf
[
1
],
chessBoardFlags
);
if
(
found1
&&
found2
)
// If done with success,
{
...
...
@@ -360,23 +363,25 @@ bool Calibrate::_recalibrate(vector<vector<Point2f>> *imagePoints,
cvtColor
(
view
[
0
],
viewGray
,
COLOR_BGR2GRAY
);
cornerSubPix
(
viewGray
,
pointBuf
[
0
],
Size
(
winSize
,
winSize
),
Size
(
-
1
,
-
1
),
TermCriteria
(
TermCriteria
::
EPS
+
TermCriteria
::
COUNT
,
30
,
0.0001
));
imagePoints
[
0
].
push_back
(
pointBuf
[
0
]);
if
(
local_
->
isStereo
())
{
cvtColor
(
view
[
1
],
viewGray
,
COLOR_BGR2GRAY
);
cornerSubPix
(
viewGray
,
pointBuf
[
1
],
Size
(
winSize
,
winSize
),
Size
(
-
1
,
-
1
),
TermCriteria
(
TermCriteria
::
EPS
+
TermCriteria
::
COUNT
,
30
,
0.0001
));
imagePoints
[
0
].
push_back
(
pointBuf
[
0
]);
imagePoints
[
1
].
push_back
(
pointBuf
[
1
]);
imagePoints
[
1
].
push_back
(
pointBuf
[
1
]);
}
// Draw the corners.
drawChessboardCorners
(
view
[
0
],
settings_
.
boardSize
,
Mat
(
pointBuf
[
0
]),
found1
);
drawChessboardCorners
(
view
[
1
],
settings_
.
boardSize
,
Mat
(
pointBuf
[
1
]),
found2
);
if
(
local_
->
isStereo
())
drawChessboardCorners
(
view
[
1
],
settings_
.
boardSize
,
Mat
(
pointBuf
[
1
]),
found2
);
}
else
{
LOG
(
WARNING
)
<<
"No calibration pattern found"
;
}
imshow
(
"Left"
,
view
[
0
]);
imshow
(
"Right"
,
view
[
1
]);
if
(
local_
->
isStereo
())
imshow
(
"Right"
,
view
[
1
]);
char
key
=
(
char
)
waitKey
(
settings_
.
delay
);
if
(
key
==
27
)
...
...
This diff is collapsed.
Click to expand it.
cv-node/src/local.cpp
+
8
−
7
View file @
2c378133
...
...
@@ -13,22 +13,23 @@ using cv::Rect;
using
std
::
string
;
using
namespace
std
::
chrono
;
LocalSource
::
LocalSource
(
bool
flip
)
:
timestamp_
(
0.0
),
flip_
(
flip
)
{
LocalSource
::
LocalSource
(
bool
flip
,
bool
nostereo
)
:
timestamp_
(
0.0
),
flip_
(
flip
)
,
nostereo_
(
nostereo
)
{
// Use cameras
camera_a_
=
new
VideoCapture
((
flip
)
?
1
:
0
);
camera_b_
=
new
VideoCapture
((
flip
)
?
0
:
1
);
if
(
!
nostereo
)
camera_b_
=
new
VideoCapture
((
flip
)
?
0
:
1
);
else
camera_b_
=
nullptr
;
if
(
!
camera_a_
->
isOpened
())
{
delete
camera_a_
;
delete
camera_b_
;
if
(
camera_b_
)
delete
camera_b_
;
camera_a_
=
nullptr
;
camera_b_
=
nullptr
;
LOG
(
FATAL
)
<<
"No cameras found"
;
return
;
}
if
(
!
camera_b_
->
isOpened
())
{
delete
camera_b_
;
if
(
!
camera_b_
||
!
camera_b_
->
isOpened
())
{
if
(
camera_b_
)
delete
camera_b_
;
camera_b_
=
nullptr
;
stereo_
=
false
;
LOG
(
WARNING
)
<<
"Not able to find second camera for stereo"
;
...
...
@@ -37,7 +38,7 @@ LocalSource::LocalSource(bool flip) : timestamp_(0.0), flip_(flip) {
}
}
LocalSource
::
LocalSource
(
const
string
&
vid
,
bool
flip
)
:
timestamp_
(
0.0
),
flip_
(
flip
)
{
LocalSource
::
LocalSource
(
const
string
&
vid
,
bool
flip
,
bool
nostereo
)
:
timestamp_
(
0.0
),
flip_
(
flip
)
,
nostereo_
(
nostereo
)
{
if
(
vid
==
""
)
{
LOG
(
FATAL
)
<<
"No video file specified"
;
camera_a_
=
nullptr
;
...
...
@@ -191,6 +192,6 @@ double LocalSource::getTimestamp() const {
}
bool
LocalSource
::
isStereo
()
const
{
return
stereo_
;
return
stereo_
&&
!
nostereo_
;
}
This diff is collapsed.
Click to expand it.
cv-node/src/main.cpp
+
6
−
3
View file @
2c378133
...
...
@@ -20,6 +20,7 @@ static string OPTION_config;
static
bool
OPTION_display
=
false
;
static
bool
OPTION_calibrate
=
false
;
static
bool
OPTION_flip
=
false
;
static
bool
OPTION_nostereo
=
false
;
void
handle_options
(
char
***
argv
,
int
*
argc
)
{
while
(
*
argc
>
0
)
{
...
...
@@ -44,6 +45,8 @@ void handle_options(char ***argv, int *argc) {
OPTION_display
=
true
;
}
else
if
(
cmd
.
find
(
"--flip"
)
==
0
)
{
OPTION_flip
=
true
;
}
else
if
(
cmd
.
find
(
"--no-stereo"
)
==
0
)
{
OPTION_nostereo
=
true
;
}
(
*
argc
)
--
;
...
...
@@ -64,10 +67,10 @@ int main(int argc, char **argv) {
if
(
argc
)
{
// Load video file
lsrc
=
new
LocalSource
(
argv
[
0
],
OPTION_flip
);
lsrc
=
new
LocalSource
(
argv
[
0
],
OPTION_flip
,
OPTION_nostereo
);
}
else
{
// Use cameras
lsrc
=
new
LocalSource
(
OPTION_flip
);
lsrc
=
new
LocalSource
(
OPTION_flip
,
OPTION_nostereo
);
}
auto
sync
=
new
SyncSource
();
// TODO Pass protocol object
...
...
@@ -108,7 +111,7 @@ int main(int argc, char **argv) {
cv
::
imshow
(
"Left"
,
l
);
if
(
lsrc
->
isStereo
())
cv
::
imshow
(
"Right"
,
r
);
if
(
cv
::
waitKey
(
100
00
)
==
27
){
if
(
cv
::
waitKey
(
100
)
==
27
){
//exit if ESC is pressed
break
;
}
...
...
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