Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 73 additions & 4 deletions cpp_tools/atis3-bridge/atis-bridge-sdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ class atis3Bridge : public RFModule, public Thread {
yInfo() << "--file <str>\t: (optional) provide file path otherwise search for camera to connect";
yInfo() << "--limit <int>\t: (optional) provide a hard limit on event rate (in 10^6 events/s)";
yInfo() << "--s <int>\t: camera sensitivity (0->100)";
yInfo() << "--refr_filter <float>\t: temporal filter (seconds) to limit event rate";
yInfo() << "--sppt_filter <float>\t: spatial filter (seconds) to limit event rate";
yInfo() << "--hpf <float>\t: high-pass filter bias (0->100)";
yInfo() << "--print_biases\t: show ALL camera biases";
return false;
}

Expand Down Expand Up @@ -114,6 +118,7 @@ class atis3Bridge : public RFModule, public Thread {
buffer.emplace_back();

Biases &bias = cam.biases();

int bias_pol = 0;
if(rf.check("polarity"))
bias_pol = rf.find("polarity").asInt32();
Expand All @@ -130,6 +135,12 @@ class atis3Bridge : public RFModule, public Thread {
if(bias_sens < 0) bias_sens = 1;
if(bias_sens > 99) bias_sens = 99;

int hpf = 0;
if (rf.check("hpf"))
hpf = rf.find("hpf").asInt32();
if(hpf < 0) hpf = 1;
if(hpf > 99) hpf = 99;

Comment on lines +138 to +143
#if defined MetavisionSDK_FOUND

const I_HW_Identification::SensorInfo si = cam.get_device().get_facility<I_HW_Identification>()->get_sensor_info();
Expand All @@ -153,12 +164,25 @@ class atis3Bridge : public RFModule, public Thread {
if(bias_pol) {
yWarning() << "polarity bias not implemented for VGA";
}
if(hpf) {
int bias_hpf = (int)(1400 + ((hpf*0.01)*(1499-1400)));
yInfo() << "After calculation:" << bias_hpf;
bias_control->set("bias_hpf", bias_hpf);
bias_vals = bias_control->get_all_biases();
Comment on lines +167 to +171
yInfo() << " Biases:" << bias_vals["bias_hpf"] << "[hpf]";
}
} else { //gen4
if(bias_sens) {
I_LL_Biases* bias_control = bias.get_facility();
bias_control->set("bias_diff_on", 1.4*(100-bias_sens));
bias_control->set("bias_diff_off", 1.4*(100-bias_sens));
}
if(bias_pol) {
yWarning() << "polarity bias not implemented for Gen4";
}
if(hpf) {
yWarning() << "high-pass filter bias not implemented for Gen4";
}
Comment on lines +183 to +185
}
#else
if(!grayscale_port.open(getName("/img:o"))) {
Expand All @@ -172,6 +196,10 @@ class atis3Bridge : public RFModule, public Thread {
cam.set_exposure_frame_callback(10, [this](timestamp ts, const cv::Mat &image){this->frameToPort(ts, image);});
#endif

if(rf.check("print_biases")) {
show_biases();
}
Comment on lines +199 to +201

cam.cd().add_callback([this](const EventCD *ev_begin, const EventCD *ev_end) {
this->fill_buffer(ev_begin, ev_end);
});
Expand All @@ -180,15 +208,30 @@ class atis3Bridge : public RFModule, public Thread {
yInfo() << "[" << geo.width() << "x" << geo.height() << "]";

double nf_param = 0.0;
double sppt_filter = 0.0;
if(rf.check("refr_filter")) nf_param = rf.find("refr_filter").asFloat64();
if(rf.check("filter")) nf_param = rf.find("filter").asFloat64();
if(rf.check("f")) nf_param = rf.find("f").asFloat64();
if(nf_param > 0.0)

Comment on lines 210 to +214
if(rf.check("sppt_filter")) sppt_filter = rf.find("sppt_filter").asFloat64();

if(nf_param > 0.0 || sppt_filter > 0.0)
{
yInfo() << "[FILTER] ON. Maximum 1 event per pixel per" << nf_param << "seconds";
nf.initialise(geo.width(), geo.height());
nf.use_temporal_filter(nf_param);

if(nf_param > 0.0) {
yInfo() << "[REFR FILTER] ON";
yInfo() << " refractory filter:" << nf_param << "seconds";
nf.use_temporal_filter(nf_param);
}

if(sppt_filter > 0.0) {
yInfo() << "[SPPT FILTER] ON";
yInfo() << " support filter:" << sppt_filter << "seconds";
nf.use_spatial_filter(sppt_filter);
}
}


//set the module name used to name ports
if(gen3) {
setName((rf.check("name", Value("/atis3")).asString()).c_str());
Expand Down Expand Up @@ -379,6 +422,32 @@ class atis3Bridge : public RFModule, public Thread {
cv::waitKey(10);

}

void show_biases()
{
#if defined MetavisionSDK_FOUND
try {
Biases &bias = cam.biases();
I_LL_Biases* bias_control = bias.get_facility();

if(!bias_control) {
yWarning() << "Bias control facility is not available for this camera.";
return;
}

std::map<std::string, int> bias_vals = bias_control->get_all_biases();

yInfo() << "Camera biases:";
for(const auto& b : bias_vals) {
yInfo() << " " << b.first << "=" << b.second;
}

} catch(const std::exception& e) {
yWarning() << "Could not read camera biases:" << e.what();
}
#endif

}
};

int main(int argc, char * argv[])
Expand Down