Skip to content

Commit

Permalink
trail filter: fixed unintialized variable bug and handle gen3 cams
Browse files Browse the repository at this point in the history
  • Loading branch information
berndpfrommer committed Jan 22, 2025
1 parent 70606da commit 07d1c27
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
6 changes: 3 additions & 3 deletions include/metavision_driver/metavision_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class MetavisionWrapper

struct TrailFilter
{
bool enabled;
std::string type;
uint32_t threshold;
bool enabled{false};
std::string type{"INVALID"};
uint32_t threshold{5000};
};

typedef std::map<std::string, std::map<std::string, int>> HardwarePinConfig;
Expand Down
2 changes: 1 addition & 1 deletion launch/driver_node.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def launch_setup(context, *args, **kwargs):
"erc_mode": "enabled",
"erc_rate": 100000000,
"trail_filter": False,
"trail_filter_type": "stc_trail_cut",
"trail_filter_type": "stc_cut_trail",
"trail_filter_threshold": 5000,
# 'roi': [0, 0, 100, 100],
# valid: 'external', 'loopback', 'disabled'
Expand Down
27 changes: 16 additions & 11 deletions src/metavision_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,19 +458,24 @@ void MetavisionWrapper::activateTrailFilter()
Metavision::I_EventTrailFilterModule * i_trail_filter =
cam_.get_device().get_facility<Metavision::I_EventTrailFilterModule>();

const auto it = trailFilterMap.find(trailFilter_.type);
if (it == trailFilterMap.end()) {
BOMB_OUT_CERR("unknown trail filter type " << trailFilter_.type);
}

// Set filter type
if (!i_trail_filter->set_type(it->second)) {
LOG_WARN_NAMED("cannot set type of trail filter!")
if (!i_trail_filter) {
LOG_WARN_NAMED("this camera does not support trail filtering!");
return;
}
if (!i_trail_filter->set_threshold(trailFilter_.threshold)) {
LOG_WARN_NAMED("cannot set threshold of trail filter!")
if (trailFilter_.enabled) {
const auto it = trailFilterMap.find(trailFilter_.type);
if (it == trailFilterMap.end()) {
LOG_WARN_NAMED("unknown trail filter type: " << trailFilter_.type);
} else {
// Set filter type
if (!i_trail_filter->set_type(it->second)) {
LOG_WARN_NAMED("cannot set type of trail filter!")
}
if (!i_trail_filter->set_threshold(trailFilter_.threshold)) {
LOG_WARN_NAMED("cannot set threshold of trail filter!")
}
}
}

i_trail_filter->enable(trailFilter_.enabled);
}

Expand Down

0 comments on commit 07d1c27

Please sign in to comment.