Skip to content

Commit 010740d

Browse files
committed
Attempted fix for bug where 2 camera got desynchronised
When the event camera has a high amount of events per second the program can't keep up which results in trigger in signals being dropped. This eventually results in the stereo images not being in sync anymore. Implemented fix for this is to minimise the amount of events per second, this can be done with a couple of new configuration values.
1 parent 91e15b5 commit 010740d

23 files changed

Lines changed: 500 additions & 215 deletions

calibrate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def on_mouse(event, x, y, flags, userdata):
346346
fy = camera_matrix_l[1, 1]
347347
cx = camera_matrix_l[0, 2]
348348
cy = camera_matrix_l[1, 2]
349-
Z = 450/1000 # in meters
349+
Z = 430/1000 # in meters
350350

351351
pt = np.array([[[point0_0[0], point0_0[1]]]], dtype=np.float32)
352352
pt_ud = cv2.undistortPoints(pt, camera_matrix_l, dist_coefs_l, P=camera_matrix_l)

example.toml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ marker_length =
3535
#DICT_6X6_50=8, DICT_6X6_100=9, DICT_6X6_250=10, DICT_6X6_1000=11,
3636
#DICT_7X7_50=12, DICT_7X7_100=13, DICT_7X7_250=14, DICT_7X7_1000=15,
3737
#DICT_ARUCO_ORIGINAL = 16
38-
#charuco_dictionary = 8
38+
#opencv_aruco_dictionary = 8
3939
#detection_interval = 2
4040
#minimum_corner_fraction = 0.125
4141

@@ -82,22 +82,37 @@ marker_length =
8282
#minMarkerLengthRatioOriginalImg = 0.0
8383

8484
[recording]
85-
master_worker = 1
85+
master_worker =
86+
#fps = 30
87+
#detection_interval = 2
8688

8789
# Possible workers are: prophesee, basler
8890
[[recording.workers]]
8991
type = "basler"
90-
placement = 1
91-
#cam_uuid = "789" # Optional
92+
placement =
93+
#cam_uuid =
9294

9395
[[recording.workers]]
9496
type = "prophesee"
95-
accumulation_time = 33333
96-
placement = 0
97-
save_event_file = true # Optional
98-
falling_edge_polarity = 1
99-
cam_uuid = "9123" # Optional
97+
placement =
98+
#cam_uuid =
99+
#accumulation_time = 33333
100+
#save_event_file = true
101+
falling_edge_polarity =
102+
#bias_diff =
103+
#bias_diff_on =
104+
#bias_diff_off =
105+
#bias_fo =
106+
#bias_hpf =
107+
#bias_refr =
108+
109+
#enable_erc =
110+
#erc_rate =
111+
112+
#enable_etf =
113+
#etf_mode =
114+
#etf_threshold =
100115

101116
[viewing]
102-
views_horizontal = 3
117+
#views_horizontal = 3
103118

src/cli/board_creation.cpp

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,7 @@ namespace YACCP::CLI {
66

77
subCmd->add_flag("-l, --list", config.showAvailableJobs, "List jobs missing a board image and/or video");
88

9-
subCmd->add_option("-j, --job-id", config.jobId, "Give a specific job ID to create a board for.")
10-
->default_str("Creates a new job");
11-
12-
// subCmd->add_option("-s, --square-length", config.squareLength, "The square length in pixels")
13-
// ->default_val(config.squareLength)
14-
// ->check(::CLI::PositiveNumber);
15-
//
16-
// subCmd
17-
// ->add_option("-m, --marker-length", config.markerLength, "The ArUco marker length in pixels")
18-
// ->default_val(config.markerLength)
19-
// ->check(::CLI::PositiveNumber);
20-
//
21-
// subCmd
22-
// ->add_option("-e, --marker-border",
23-
// config.marginSize,
24-
// "The border size (margins) of the ArUco marker in pixels")
25-
// ->default_str("square-length - marker-length")
26-
// ->check(::CLI::PositiveNumber);
27-
//
28-
// subCmd
29-
// ->add_option("-b, --border-point",
30-
// config.borderBits,
31-
// "The amount of points (pixels) for the border")
32-
// ->default_val(config.borderBits)
33-
// ->check(::CLI::PositiveNumber);
9+
subCmd->add_option("-j, --job-id", config.jobId, "Give a specific job ID to create a board for.");
3410

3511
subCmd
3612
->add_flag("!-i, !--image",
@@ -44,12 +20,6 @@ namespace YACCP::CLI {
4420
"Whether to generate an event video of the generated board")
4521
->default_str("false");
4622

47-
// subCmd->parse_complete_callback([&config] {
48-
// if (!config.marginSize) {
49-
// config.marginSize = config.squareLength - config.markerLength;
50-
// }
51-
// });
52-
5323
return subCmd;
5424
}
5525
} // namespace YACCP::CLI

src/config/board.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ namespace YACCP::Config {
1818

1919
std::string boardTypeToString(const BoardTypes boardType) {
2020
for (const auto& [key, value] : boardTypesMap) {
21-
if (value == boardType) return key;
21+
if (value == boardType) {
22+
return key;
23+
}
2224
}
2325
throw std::runtime_error("unknown board enum type");
2426
}
@@ -29,11 +31,11 @@ namespace YACCP::Config {
2931
const auto* boardTbl{tbl["board"].as_table()};
3032
if (!boardTbl) throw std::runtime_error("Missing [board] table");
3133

32-
const BoardTypes type{stringToBoardType(requireVariable<std::string>(*boardTbl, "type", "board"))};
34+
config.boardType = stringToBoardType(requireVariable<std::string>(*boardTbl, "type", "board"));
3335
config.boardSize.width = (*boardTbl)["squares_x"].value_or(GlobalVariables::boardWidth);
3436
config.boardSize.height = (*boardTbl)["squares_y"].value_or(GlobalVariables::boardHeight);
3537

36-
switch (type) {
38+
switch (config.boardType) {
3739
case BoardTypes::charuco:
3840
config.squarePixelLength = (*boardTbl)["square_pixel_length"].value_or(
3941
GlobalVariables::squarePixelLength);
@@ -52,4 +54,4 @@ namespace YACCP::Config {
5254
break;
5355
}
5456
}
55-
} // YACCP::Config
57+
} // YACCP::Config

src/config/board.hpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,26 @@ namespace YACCP::Config {
1919
};
2020

2121
struct BoardConfig {
22+
BoardTypes boardType{};
2223
cv::Size boardSize{};
23-
float squareLength{};
24-
float markerLength{};
2524
int squarePixelLength{};
2625
int markerPixelLength{};
2726
int marginSize{};
2827
int borderBits{};
28+
float squareLength{};
29+
float markerLength{};
2930
};
3031

32+
BoardTypes stringToBoardType(std::string board);
33+
34+
std::string boardTypeToString(BoardTypes boardType);
35+
36+
void parseBoardConfig(const toml::table& tbl, BoardConfig& config, bool boardCreation);
37+
3138

3239
inline void to_json(nlohmann::json& j, const BoardConfig& b) {
3340
j = {
41+
{"boardType", boardTypeToString(b.boardType)},
3442
{
3543
"boardSize",
3644
{
@@ -49,6 +57,7 @@ namespace YACCP::Config {
4957

5058

5159
inline void from_json(const nlohmann::json& j, BoardConfig& b) {
60+
b.boardType = stringToBoardType(j.at("boardType").get<std::string>());
5261
j.at("boardSize").at("width").get_to(b.boardSize.width);
5362
j.at("boardSize").at("height").get_to(b.boardSize.height);
5463
j.at("squareLength").get_to(b.squareLength);
@@ -58,13 +67,6 @@ namespace YACCP::Config {
5867
j.at("marginSize").get_to(b.marginSize);
5968
j.at("borderBits").get_to(b.borderBits);
6069
}
61-
62-
63-
BoardTypes stringToBoardType(std::string board);
64-
65-
std::string boardTypeToString(BoardTypes boardType);
66-
67-
void parseBoardConfig(const toml::table& tbl, BoardConfig& config, bool boardCreation);
6870
} // YACCP::Config
6971

7072
#endif //YACCP_SRC_CONFIG_BOARD_HPP

src/config/detection.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ namespace YACCP::Config {
88
const auto* detectionTbl{tbl["detection"].as_table()};
99
if (!detectionTbl) return;
1010

11-
config.openCvDictionaryId = (*detectionTbl)["charuco_dictionary"].value_or(GlobalVariables::charucoDictionary);
12-
config.detectionInterval = (*detectionTbl)["detection_interval"].value_or(GlobalVariables::detectionInterval);
11+
config.openCvArucoDictionaryId = (*detectionTbl)["opencv_aruco_dictionary"].value_or(GlobalVariables::charucoDictionary);
1312
config.cornerMin = (*detectionTbl)["minimum_corner_fraction"].value_or(GlobalVariables::minCornerFraction);
1413

1514
// Load custom charuco parameters if set, otherwise load defaults.

src/config/detection.hpp

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace cv::aruco {
1616

1717

1818
inline void from_json(const nlohmann::json& j, CharucoParameters& p) {
19-
j.at("minMarkers").get_to(p.minMarkers);
20-
j.at("tryRefineMarkers").get_to(p.tryRefineMarkers);
19+
(void)j.at("minMarkers").get_to(p.minMarkers);
20+
(void)j.at("tryRefineMarkers").get_to(p.tryRefineMarkers);
2121
}
2222

2323

@@ -60,45 +60,44 @@ namespace cv::aruco {
6060

6161

6262
inline void from_json(const nlohmann::json& j, DetectorParameters& p) {
63-
j.at("adaptiveThreshWinSizeMin").get_to(p.adaptiveThreshWinSizeMin);
64-
j.at("adaptiveThreshWinSizeMax").get_to(p.adaptiveThreshWinSizeMax);
65-
j.at("adaptiveThreshWinSizeStep").get_to(p.adaptiveThreshWinSizeStep);
66-
j.at("adaptiveThreshConstant").get_to(p.adaptiveThreshConstant);
67-
j.at("minMarkerPerimeterRate").get_to(p.minMarkerPerimeterRate);
68-
j.at("maxMarkerPerimeterRate").get_to(p.maxMarkerPerimeterRate);
69-
j.at("polygonalApproxAccuracyRate").get_to(p.polygonalApproxAccuracyRate);
70-
j.at("minCornerDistanceRate").get_to(p.minCornerDistanceRate);
71-
j.at("minDistanceToBorder").get_to(p.minDistanceToBorder);
72-
j.at("minMarkerDistanceRate").get_to(p.minMarkerDistanceRate);
73-
j.at("cornerRefinementMethod").get_to(p.cornerRefinementMethod);
74-
j.at("cornerRefinementWinSize").get_to(p.cornerRefinementWinSize);
75-
j.at("cornerRefinementMaxIterations").get_to(p.cornerRefinementMaxIterations);
76-
j.at("cornerRefinementMinAccuracy").get_to(p.cornerRefinementMinAccuracy);
77-
j.at("markerBorderBits").get_to(p.markerBorderBits);
78-
j.at("perspectiveRemovePixelPerCell").get_to(p.perspectiveRemovePixelPerCell);
79-
j.at("perspectiveRemoveIgnoredMarginPerCell").get_to(p.perspectiveRemoveIgnoredMarginPerCell);
80-
j.at("maxErroneousBitsInBorderRate").get_to(p.maxErroneousBitsInBorderRate);
81-
j.at("minOtsuStdDev").get_to(p.minOtsuStdDev);
82-
j.at("errorCorrectionRate").get_to(p.errorCorrectionRate);
83-
j.at("aprilTagQuadDecimate").get_to(p.aprilTagQuadDecimate);
84-
j.at("aprilTagQuadSigma").get_to(p.aprilTagQuadSigma);
85-
j.at("aprilTagMinClusterPixels").get_to(p.aprilTagMinClusterPixels);
86-
j.at("aprilTagMaxNmaxima").get_to(p.aprilTagMaxNmaxima);
87-
j.at("aprilTagCriticalRad").get_to(p.aprilTagCriticalRad);
88-
j.at("aprilTagMaxLineFitMse").get_to(p.aprilTagMaxLineFitMse);
89-
j.at("aprilTagMinWhiteBlackDiff").get_to(p.aprilTagMinWhiteBlackDiff);
90-
j.at("aprilTagDeglitch").get_to(p.aprilTagDeglitch);
91-
j.at("detectInvertedMarker").get_to(p.detectInvertedMarker);
92-
j.at("useAruco3Detection").get_to(p.useAruco3Detection);
93-
j.at("minSideLengthCanonicalImg").get_to(p.minSideLengthCanonicalImg);
94-
j.at("minMarkerLengthRatioOriginalImg").get_to(p.minMarkerLengthRatioOriginalImg);
63+
(void)j.at("adaptiveThreshWinSizeMin").get_to(p.adaptiveThreshWinSizeMin);
64+
(void)j.at("adaptiveThreshWinSizeMax").get_to(p.adaptiveThreshWinSizeMax);
65+
(void)j.at("adaptiveThreshWinSizeStep").get_to(p.adaptiveThreshWinSizeStep);
66+
(void)j.at("adaptiveThreshConstant").get_to(p.adaptiveThreshConstant);
67+
(void)j.at("minMarkerPerimeterRate").get_to(p.minMarkerPerimeterRate);
68+
(void)j.at("maxMarkerPerimeterRate").get_to(p.maxMarkerPerimeterRate);
69+
(void)j.at("polygonalApproxAccuracyRate").get_to(p.polygonalApproxAccuracyRate);
70+
(void)j.at("minCornerDistanceRate").get_to(p.minCornerDistanceRate);
71+
(void)j.at("minDistanceToBorder").get_to(p.minDistanceToBorder);
72+
(void)j.at("minMarkerDistanceRate").get_to(p.minMarkerDistanceRate);
73+
(void)j.at("cornerRefinementMethod").get_to(p.cornerRefinementMethod);
74+
(void)j.at("cornerRefinementWinSize").get_to(p.cornerRefinementWinSize);
75+
(void)j.at("cornerRefinementMaxIterations").get_to(p.cornerRefinementMaxIterations);
76+
(void)j.at("cornerRefinementMinAccuracy").get_to(p.cornerRefinementMinAccuracy);
77+
(void)j.at("markerBorderBits").get_to(p.markerBorderBits);
78+
(void)j.at("perspectiveRemovePixelPerCell").get_to(p.perspectiveRemovePixelPerCell);
79+
(void)j.at("perspectiveRemoveIgnoredMarginPerCell").get_to(p.perspectiveRemoveIgnoredMarginPerCell);
80+
(void)j.at("maxErroneousBitsInBorderRate").get_to(p.maxErroneousBitsInBorderRate);
81+
(void)j.at("minOtsuStdDev").get_to(p.minOtsuStdDev);
82+
(void)j.at("errorCorrectionRate").get_to(p.errorCorrectionRate);
83+
(void)j.at("aprilTagQuadDecimate").get_to(p.aprilTagQuadDecimate);
84+
(void)j.at("aprilTagQuadSigma").get_to(p.aprilTagQuadSigma);
85+
(void)j.at("aprilTagMinClusterPixels").get_to(p.aprilTagMinClusterPixels);
86+
(void)j.at("aprilTagMaxNmaxima").get_to(p.aprilTagMaxNmaxima);
87+
(void)j.at("aprilTagCriticalRad").get_to(p.aprilTagCriticalRad);
88+
(void)j.at("aprilTagMaxLineFitMse").get_to(p.aprilTagMaxLineFitMse);
89+
(void)j.at("aprilTagMinWhiteBlackDiff").get_to(p.aprilTagMinWhiteBlackDiff);
90+
(void)j.at("aprilTagDeglitch").get_to(p.aprilTagDeglitch);
91+
(void)j.at("detectInvertedMarker").get_to(p.detectInvertedMarker);
92+
(void)j.at("useAruco3Detection").get_to(p.useAruco3Detection);
93+
(void)j.at("minSideLengthCanonicalImg").get_to(p.minSideLengthCanonicalImg);
94+
(void)j.at("minMarkerLengthRatioOriginalImg").get_to(p.minMarkerLengthRatioOriginalImg);
9595
}
9696
}
9797

9898
namespace YACCP::Config {
9999
struct DetectionConfig {
100-
int openCvDictionaryId{};
101-
int detectionInterval{};
100+
int openCvArucoDictionaryId{};
102101
float cornerMin{};
103102

104103
cv::aruco::CharucoParameters charucoParameters{};
@@ -108,8 +107,7 @@ namespace YACCP::Config {
108107

109108
inline void to_json(nlohmann::json& j, const DetectionConfig& d) {
110109
j = {
111-
{"openCvDictionaryId", d.openCvDictionaryId},
112-
// DetectionInterval is a user variable and not needed to recreate an experiment.
110+
{"openCvDictionaryId", d.openCvArucoDictionaryId},
113111
{"cornerMin", d.cornerMin},
114112
{"charucoParameters", d.charucoParameters},
115113
{"detectorParameters", d.detectorParameters},
@@ -118,10 +116,10 @@ namespace YACCP::Config {
118116

119117

120118
inline void from_json(const nlohmann::json& j, DetectionConfig& d) {
121-
j.at("openCvDictionaryId").get_to(d.openCvDictionaryId);
122-
j.at("cornerMin").get_to(d.cornerMin);
123-
j.at("charucoParameters").get_to(d.charucoParameters);
124-
j.at("detectorParameters").get_to(d.detectorParameters);
119+
(void)j.at("openCvDictionaryId").get_to(d.openCvArucoDictionaryId);
120+
(void)j.at("cornerMin").get_to(d.cornerMin);
121+
(void)j.at("charucoParameters").get_to(d.charucoParameters);
122+
(void)j.at("detectorParameters").get_to(d.detectorParameters);
125123
}
126124

127125

0 commit comments

Comments
 (0)