Skip to content

Commit

Permalink
Merge origin/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobi Delbruck authored and Tobi Delbruck committed May 8, 2020
2 parents ae803ab + ce436b0 commit 3e5899d
Show file tree
Hide file tree
Showing 4 changed files with 2,957 additions and 2,878 deletions.
45 changes: 37 additions & 8 deletions src/ch/unizh/ini/jaer/projects/minliu/HWCornerPointRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLException;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.logging.Level;
import net.sf.jaer.Description;
import net.sf.jaer.DevelopmentStatus;
import net.sf.jaer.chip.AEChip;
import net.sf.jaer.event.BasicEvent;
import net.sf.jaer.event.EventPacket;
import net.sf.jaer.event.PolarityEvent;
import net.sf.jaer.event.PolarityEvent.Polarity;
import net.sf.jaer.eventio.AEInputStream;
import static net.sf.jaer.eventprocessing.EventFilter.log;
import net.sf.jaer.eventprocessing.EventFilter2D;
import net.sf.jaer.eventprocessing.FilterChain;
import net.sf.jaer.eventprocessing.filter.HashHeatNoiseFilter;
Expand All @@ -46,7 +51,7 @@
@Description("<html>This is the a viwer for demo FPGA eFAST as demonstrated in CVPR2019 EventVision Workshop. The java version of eFAST is also implemented here.<br>"
+ "Liu, M., and Kao, W., and Delbruck, T. (2019). <a href=\"http://openaccess.thecvf.com/content_CVPRW_2019/papers/EventVision/Liu_Live_Demonstration_A_Real-Time_Event-Based_Fast_Corner_Detection_Demo_Based_CVPRW_2019_paper.pdf\">Live Demonstration: A Real-Time Event-Based Fast Corner Detection Demo Based on FPGA</a>.<br>.")
@DevelopmentStatus(DevelopmentStatus.Status.Experimental)
public class HWCornerPointRenderer extends EventFilter2D implements FrameAnnotater {
public class HWCornerPointRenderer extends EventFilter2D implements FrameAnnotater, PropertyChangeListener {

private ArrayList<BasicEvent> cornerEvents = new ArrayList(1000);
private double[][][] sae_ = null;
Expand Down Expand Up @@ -74,6 +79,10 @@ public class HWCornerPointRenderer extends EventFilter2D implements FrameAnnotat

private int subsample = getInt("subsample", 3);

private int evCounter = 0;
private int evCounterThreshold = getInt("evCounterThreshold", 1000);
private boolean addPropertyChangeListener = false;

public enum CalcMethod {
HW_EFAST, SW_EFAST
};
Expand All @@ -97,7 +106,7 @@ public HWCornerPointRenderer(AEChip chip) {
setPropertyTooltip(strDenoise, "enDeoiseCorners", "enable to denoise the corners");
setPropertyTooltip(strDenoise, "enShowOriginalCorners", "enable to show the original corners before denoise");
setPropertyTooltip(strDenoise, "subsample", "subsample value to determine the area for non-maximum supression");
setPropertyTooltip(strDenoise, "threshold", "threshold for non-maximum supression");
setPropertyTooltip(strDenoise, "threshold", "threshold for non-maximum supression");
}

@Override
Expand All @@ -106,6 +115,13 @@ synchronized public EventPacket<?> filterPacket(EventPacket<?> in) {
int wrongCornerNum = 0;
int falseNegativeNum = 0;
int falsePositiveNum = 0;

// Bind property change events. This code should be put after AEViewer is constructed and only bind one time.
if(chip.getAeViewer() != null && !addPropertyChangeListener)
{
addPropertyChangeListener = true;
chip.getAeViewer().getSupport().addPropertyChangeListener(AEInputStream.EVENT_REWOUND, this);
}

for(int xIdx = 0; xIdx < 100; xIdx++)
{
Expand Down Expand Up @@ -222,6 +238,7 @@ public void resetFilter() {
if (sae_ == null) {
return; // on reset maybe chip is not set yet
}

for (double[][] b : sae_) {
for (double[] row : b) {
Arrays.fill(row, (double) 0);
Expand All @@ -245,7 +262,7 @@ synchronized public void annotate(GLAutoDrawable drawable) {
} catch (final GLException e) {
e.printStackTrace();
}
gl.glColor4f(1f, 0, 0, .2f);
gl.glColor4f(1f, 0, 0, 0.6f);
for (BasicEvent e : cornerEvents) {
gl.glPushMatrix();
DrawGL.drawBox(gl, e.x, e.y, 4, 4, 0);
Expand All @@ -261,10 +278,10 @@ boolean FastDetectorisFeature(PolarityEvent ein) {
int pix_y = ein.y;
int timesmp = ein.timestamp;
Polarity polarity = ein.polarity;
if (polarity.equals(Polarity.Off)) {
found_streak = false;
return found_streak;
}
// if (polarity.equals(Polarity.Off)) {
// found_streak = false;
// return found_streak;
// }

final int max_scale = 1;
// only check if not too close to border
Expand All @@ -275,7 +292,7 @@ boolean FastDetectorisFeature(PolarityEvent ein) {
return found_streak;
}

final int pol = polarity.equals(Polarity.Off) ? 0 : 0;
final int pol = polarity.equals(Polarity.Off) ? 0 : 1;

// update SAE
sae_[pol][pix_x][pix_y] = timesmp;
Expand Down Expand Up @@ -455,4 +472,16 @@ public void setSubsample(int subsample) {
putInt("sliceMaxValue", subsample);
getSupport().firePropertyChange("subsample", old, this.subsample);
}

public int getEvCounterThreshold() {
return evCounterThreshold;
}

public void setEvCounterThreshold(int evCounterThreshold) {
int old = this.evCounterThreshold;
this.evCounterThreshold = evCounterThreshold;
putInt("evCounterThreshold", evCounterThreshold);
getSupport().firePropertyChange("evCounterThreshold", old, this.evCounterThreshold);
}

}
13 changes: 12 additions & 1 deletion src/ch/unizh/ini/jaer/projects/minliu/PatchMatchFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ public enum SliceMethod {
public static final String EVENT_NEW_SLICES = "eventNewSlices";

TobiLogger sadValueLogger = new TobiLogger("sadvalues", "sadvalue,scale"); // TODO debug

private boolean calcOFonCornersEnabled = getBoolean("calcOFonCornersEnabled", false);

public PatchMatchFlow(AEChip chip) {
super(chip);
Expand Down Expand Up @@ -282,6 +284,7 @@ public PatchMatchFlow(AEChip chip) {
setPropertyTooltip(patchTT, "scalesToCompute", "Scales to compute, e.g. 1,2; blank for all scales. 0 is full resolution, 1 is subsampled 2x2, etc");
setPropertyTooltip(patchTT, "defaults", "Sets reasonable defaults");
setPropertyTooltip(patchTT, "enableImuTimesliceLogging", "Logs IMU and rate gyro");
setPropertyTooltip(patchTT, "calcOFonCornersEnabled", "Calculate OF based on corners or not");

String patchDispTT = "0b: Block matching display";
setPropertyTooltip(patchDispTT, "showSlices", "enables displaying the entire bitmaps slices (the current slices)");
Expand Down Expand Up @@ -1088,7 +1091,7 @@ synchronized private boolean accumulateEvent(PolarityEvent e) {
}
// detect if keypoint here
boolean isCorner = ((e.getAddress() & 1) == 1);
if (!isCorner) {
if (calcOFonCornersEnabled && !isCorner) {
return false;
}

Expand Down Expand Up @@ -2858,4 +2861,12 @@ public void setShowSlicesScale(int showSlicesScale) {
this.showSlicesScale = showSlicesScale;
}

public boolean isCalcOFonCornersEnabled() {
return calcOFonCornersEnabled;
}

public void setCalcOFonCornersEnabled(boolean calcOFonCornersEnabled) {
this.calcOFonCornersEnabled = calcOFonCornersEnabled;
putBoolean("calcOFonCornersEnabled", calcOFonCornersEnabled);
}
}
Loading

0 comments on commit 3e5899d

Please sign in to comment.