Skip to content

Commit

Permalink
added paused check so that frames are not turned off if paused
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobi Delbruck authored and Tobi Delbruck committed Apr 4, 2024
1 parent 2a06123 commit 19cbe8d
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/net/sf/jaer/graphics/DavisRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public class DavisRenderer extends AEChipRenderer {
private int framesRenderedSinceApsFrame = 0; // to deactivate frames after some time with none
private static final int NUM_RENDERED_FRAMES_WITH_NO_APS_FRAME_TO_DEACTIVATE_FRAMES = 360;
private boolean renderedApsFrame = false;
private int lastTimestampFrameEndWeSentPropertyChangeFor=0; // saves the time we sent propertyChange for a new frame to not send it multiple times during pause if the packet has a frame end in it
private int lastTimestampFrameEndWeSentPropertyChangeFor = 0; // saves the time we sent propertyChange for a new frame to not send it multiple times during pause if the packet has a frame end in it

public DavisRenderer(final AEChip chip) {
super(chip);
Expand Down Expand Up @@ -254,7 +254,7 @@ public synchronized void render(final EventPacket pkt) {
}
}
}
packet=pkt;
packet = pkt;
if (pkt.isEmpty()) {
return;
}
Expand Down Expand Up @@ -347,21 +347,23 @@ protected void renderApsDvsEvents(final EventPacket pkt) {
}
}
}
if (renderedApsFrame) {
framesRenderedSinceApsFrame = 0;
} else if (isDisplayFrames()) {
framesRenderedSinceApsFrame++;
}
if (framesRenderedSinceApsFrame > NUM_RENDERED_FRAMES_WITH_NO_APS_FRAME_TO_DEACTIVATE_FRAMES) {
if (isDisplayFrames()) {
log.warning(String.format("No APS frames for last %,d>%,d NUM_RENDERED_FRAMES_WITH_NO_APS_FRAME_TO_DEACTIVATE_FRAMES rendered frames, disabling frames",
framesRenderedSinceApsFrame, NUM_RENDERED_FRAMES_WITH_NO_APS_FRAME_TO_DEACTIVATE_FRAMES));
setDisplayFrames(false);
if (chip.getAeViewer() != null && !chip.getAeViewer().isPaused()) {
if (renderedApsFrame) {
framesRenderedSinceApsFrame = 0;
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(chip.getAeViewer(), "Disabled APS frame rendering because there appear to be no frames");
});
} else if (isDisplayFrames()) {
framesRenderedSinceApsFrame++;
}
if (framesRenderedSinceApsFrame > NUM_RENDERED_FRAMES_WITH_NO_APS_FRAME_TO_DEACTIVATE_FRAMES) {
if (isDisplayFrames()) {
log.warning(String.format("No APS frames for last %,d>%,d NUM_RENDERED_FRAMES_WITH_NO_APS_FRAME_TO_DEACTIVATE_FRAMES rendered frames, disabling frames",
framesRenderedSinceApsFrame, NUM_RENDERED_FRAMES_WITH_NO_APS_FRAME_TO_DEACTIVATE_FRAMES));
setDisplayFrames(false);
framesRenderedSinceApsFrame = 0;
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(chip.getAeViewer(), "Disabled APS frame rendering because there appear to be no frames");
});

}
}
}
}
Expand Down Expand Up @@ -528,7 +530,7 @@ protected void endFrame(final int ts) {
}
if (timestampFrameEnd != lastTimestampFrameEndWeSentPropertyChangeFor) {
getSupport().firePropertyChange(DavisRenderer.EVENT_NEW_FRAME_AVAILBLE, null, this);
lastTimestampFrameEndWeSentPropertyChangeFor=timestampFrameEnd;
lastTimestampFrameEndWeSentPropertyChangeFor = timestampFrameEnd;
}
}

Expand Down

0 comments on commit 19cbe8d

Please sign in to comment.