diff --git a/src/ch/unizh/ini/jaer/chip/retina/DVS128.java b/src/ch/unizh/ini/jaer/chip/retina/DVS128.java index e3d17182f..251e2d25c 100644 --- a/src/ch/unizh/ini/jaer/chip/retina/DVS128.java +++ b/src/ch/unizh/ini/jaer/chip/retina/DVS128.java @@ -734,7 +734,7 @@ public void setBandwidthTweak(float val) { } bandwidth = val; final float MAX = 300; -// pr.changeByRatioFromPreferred(PotTweakerUtilities.getRatioTweak(val, MAX)); + pr.changeByRatioFromPreferred(PotTweakerUtilities.getRatioTweak(val, MAX)); sf.changeByRatioFromPreferred(PotTweakerUtilities.getRatioTweak(val, MAX)); getSupport().firePropertyChange(DVSTweaks.BANDWIDTH, old, val); } diff --git a/src/ch/unizh/ini/jaer/chip/retina/DVS128andCochleaAMS1b.java b/src/ch/unizh/ini/jaer/chip/retina/DVS128andCochleaAMS1b.java index 49763c5e3..4bf9289f0 100644 --- a/src/ch/unizh/ini/jaer/chip/retina/DVS128andCochleaAMS1b.java +++ b/src/ch/unizh/ini/jaer/chip/retina/DVS128andCochleaAMS1b.java @@ -513,7 +513,7 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { public void setBandwidthTweak(float val) { final float MAX = 300; -// pr.changeByRatioFromPreferred(PotTweakerUtilities.getRatioTweak(val, MAX)); + pr.changeByRatioFromPreferred(PotTweakerUtilities.getRatioTweak(val, MAX)); sf.changeByRatioFromPreferred(PotTweakerUtilities.getRatioTweak(val, MAX)); } diff --git a/src/ch/unizh/ini/jaer/chip/retina/DVSTweaks.java b/src/ch/unizh/ini/jaer/chip/retina/DVSTweaks.java index 6772b1954..a7dff6b22 100644 --- a/src/ch/unizh/ini/jaer/chip/retina/DVSTweaks.java +++ b/src/ch/unizh/ini/jaer/chip/retina/DVSTweaks.java @@ -26,12 +26,6 @@ public interface DVSTweaks { /** * Tweaks front end bandwidth, larger is higher bandwidth. - * - * Adjust the source follower bandwidth by changing PRSf bias current. - * - *

For minimum shot noise under low illumination, the photoreceptor bias should be large and - * the bandwidth should be limited by the source follower buffer. - * See Optimal biasing and physical limits of DVS event noise. * * @param val -1 to 1 range */ diff --git a/src/eu/seebetter/ini/chips/davis/DavisConfig.java b/src/eu/seebetter/ini/chips/davis/DavisConfig.java index 48bd61204..2cb9f450b 100644 --- a/src/eu/seebetter/ini/chips/davis/DavisConfig.java +++ b/src/eu/seebetter/ini/chips/davis/DavisConfig.java @@ -29,7 +29,6 @@ import eu.seebetter.ini.chips.davis.imu.ImuAccelScale; import eu.seebetter.ini.chips.davis.imu.ImuControl; import eu.seebetter.ini.chips.davis.imu.ImuControlPanel; -import javax.swing.UIManager; import net.sf.jaer.biasgen.AddressedIPotArray; import net.sf.jaer.biasgen.Biasgen; import net.sf.jaer.biasgen.BiasgenHardwareInterface; @@ -84,9 +83,7 @@ public class DavisConfig extends Biasgen implements DavisDisplayConfigInterface, // subclasses for controlling aspects of camera protected DavisConfig.VideoControl videoControl; protected ImuControl imuControlGUI; - EngineeringFormat eng = new EngineeringFormat(); - - private boolean dualUserFriendlyAndBiasCurrentsViewEnabled = false; + EngineeringFormat eng=new EngineeringFormat(); public DavisConfig(final Chip chip) { super(chip); @@ -408,10 +405,9 @@ public String processRemoteControlCommand(final RemoteControlCommand command, fi } private ParameterControlPanel videoParameterControlPanel; - private JPanel userFriendlyControls, combinedBiasShiftedSourcePanel; + private JPanel userFriendlyControls; private JPanel configPanel; private JTabbedPane configTabbedPane; - private JPanel dualViewPanel; // threshold for triggering a new frame snapshot automatically private int autoShotThreshold; @@ -436,44 +432,12 @@ public JPanel buildControlPanel() { configPanel = new JPanel(); configPanel.setLayout(new BorderLayout()); - makeConfigTabbedPane(); - - // only select panel after all added - configPanel.add(configTabbedPane, BorderLayout.CENTER); - - setBatchEditOccurring(false); - return configPanel; - } - - /** - * Sets dual view of user friendly and bias currents - */ - void setDualView(boolean selected) { - if (selected) { - makeDualViewPanel(); - configPanel.removeAll(); - configPanel.add(dualViewPanel, BorderLayout.CENTER); - } else { - makeConfigTabbedPane(); - configPanel.removeAll(); - configPanel.add(configTabbedPane, BorderLayout.CENTER); - } - configPanel.validate(); - } - - private void makeDualViewPanel() { - dualViewPanel = new JPanel(); - dualViewPanel.setLayout(new BorderLayout()); - dualViewPanel.add(userFriendlyControls, BorderLayout.WEST); // removes it from configTabbedPane - dualViewPanel.add(combinedBiasShiftedSourcePanel, BorderLayout.EAST); // removes it from configTabbedPane - } - - private void makeConfigTabbedPane() { configTabbedPane = new JTabbedPane(); userFriendlyControls = new DavisUserControlPanel(getChip()); configTabbedPane.addTab("User-Friendly Controls", userFriendlyControls); + // biasgen - combinedBiasShiftedSourcePanel = new JPanel(); + final JPanel combinedBiasShiftedSourcePanel = new JPanel(); combinedBiasShiftedSourcePanel .add(new JLabel("Low-level control of on-chip bias currents and voltages.

These are only for experts!")); combinedBiasShiftedSourcePanel.setLayout(new BoxLayout(combinedBiasShiftedSourcePanel, BoxLayout.Y_AXIS)); @@ -481,37 +445,44 @@ private void makeConfigTabbedPane() { combinedBiasShiftedSourcePanel.add(new ShiftedSourceControlsCF(ssp)); combinedBiasShiftedSourcePanel.add(new ShiftedSourceControlsCF(ssn)); configTabbedPane.addTab("Bias Current Config", combinedBiasShiftedSourcePanel); + // Multiplexer final JPanel muxPanel = new JPanel(); muxPanel.setLayout(new BoxLayout(muxPanel, BoxLayout.Y_AXIS)); configTabbedPane.addTab("Multiplexer Config", muxPanel); SPIConfigValue.addGUIControls(muxPanel, muxControl); + // DVS final JPanel dvsPanel = new JPanel(); dvsPanel.setLayout(new BoxLayout(dvsPanel, BoxLayout.Y_AXIS)); configTabbedPane.addTab("DVS Config", dvsPanel); SPIConfigValue.addGUIControls(dvsPanel, dvsControl); + // APS final JPanel apsPanel = new JPanel(); apsPanel.setLayout(new BoxLayout(apsPanel, BoxLayout.Y_AXIS)); configTabbedPane.addTab("APS Config", apsPanel); SPIConfigValue.addGUIControls(apsPanel, apsControl); + // IMU final JPanel imuControlPanel = new JPanel(); imuControlPanel.add(new JLabel("Low-level control of integrated inertial measurement unit.")); imuControlPanel.setLayout(new BoxLayout(imuControlPanel, BoxLayout.Y_AXIS)); imuControlPanel.add(new ImuControlPanel(this)); configTabbedPane.addTab("IMU Config", imuControlPanel); + // External Input final JPanel extPanel = new JPanel(); extPanel.setLayout(new BoxLayout(extPanel, BoxLayout.Y_AXIS)); configTabbedPane.addTab("External Input Config", extPanel); SPIConfigValue.addGUIControls(extPanel, extInControl); + // Chip config final JPanel chipPanel = new JPanel(); chipPanel.setLayout(new BoxLayout(chipPanel, BoxLayout.Y_AXIS)); configTabbedPane.addTab("Chip Config", chipPanel); SPIConfigValue.addGUIControls(chipPanel, chipControl); + // Autoexposure if (getChip() instanceof DavisBaseCamera) { final JPanel autoExposurePanel = new JPanel(); @@ -521,6 +492,7 @@ private void makeConfigTabbedPane() { autoExposurePanel.add(new ParameterControlPanel(((DavisBaseCamera) getChip()).getAutoExposureController())); configTabbedPane.addTab("APS Autoexposure Control", autoExposurePanel); } + // Video Control final JPanel videoControlPanel = new JPanel(); videoControlPanel.add(new JLabel("Controls display of APS video frame data")); @@ -528,15 +500,19 @@ private void makeConfigTabbedPane() { videoParameterControlPanel = new ParameterControlPanel(getVideoControl()); videoControlPanel.add(videoParameterControlPanel); configTabbedPane.addTab("Video Control", videoControlPanel); + getVideoControl().addObserver(videoParameterControlPanel); getVideoControl().getContrastContoller().addObserver(videoParameterControlPanel); - // make special dual view panel for seeing effect of userFriendlyControls on bias currents + // only select panel after all added + configPanel.add(configTabbedPane, BorderLayout.CENTER); + try { configTabbedPane.setSelectedIndex(getChip().getPrefs().getInt("DavisBaseCamera.bgTabbedPaneSelectedIndex", 0)); } catch (final IndexOutOfBoundsException e) { configTabbedPane.setSelectedIndex(0); } + // add listener to store last selected tab configTabbedPane.addMouseListener(new MouseAdapter() { @Override @@ -544,6 +520,9 @@ public void mouseClicked(final MouseEvent evt) { tabbedPaneMouseClicked(evt); } }); + + setBatchEditOccurring(false); + return configPanel; } @Override @@ -674,7 +653,7 @@ public void setBandwidthTweak(float val) { // log.info("tweak bandwidth by " + val); bandwidth = val; final float MAX = 30; -// pr.changeByRatioFromPreferred(PotTweakerUtilities.getRatioTweak(val, MAX)); + pr.changeByRatioFromPreferred(PotTweakerUtilities.getRatioTweak(val, MAX)); sf.changeByRatioFromPreferred(PotTweakerUtilities.getRatioTweak(val, MAX)); getChip().getSupport().firePropertyChange(DVSTweaks.BANDWIDTH, old, val); } @@ -978,7 +957,7 @@ public float getPhotoreceptorSourceFollowerBandwidthHz() { // computed based on Davis240/346 C1=132fF and estimated SF bias current float iSf = sf.getCurrent(), iPr = pr.getCurrent(); if (iSf > iPr * .5) { - log.info(String.format("Source follower bias current (%sA) is larger than half of Photoreceptor bias current (%sA); cannot estimate cutoff frequency from SF current alone", eng.format(iSf), eng.format(iPr))); + log.info(String.format("Source follower bias current (%sA) is larger than half of Photoreceptor bias current (%sA); cannot estimate cutoff frequency from SF current alone",eng.format(iSf),eng.format(iPr))); return Float.NaN; } // TODO note from IMU we have temperature, could account for it in thermal voltage @@ -1312,19 +1291,4 @@ public static SPIConfigValue getConfigValueByName(final List con return null; } - - /** - * @return the dualUserFriendlyAndBiasCurrentsViewEnabled - */ - public boolean isDualUserFriendlyAndBiasCurrentsViewEnabled() { - return dualUserFriendlyAndBiasCurrentsViewEnabled; - } - - /** - * @param dualUserFriendlyAndBiasCurrentsViewEnabled the - * dualUserFriendlyAndBiasCurrentsViewEnabled to set - */ - public void setDualUserFriendlyAndBiasCurrentsViewEnabled(boolean dualUserFriendlyAndBiasCurrentsViewEnabled) { - this.dualUserFriendlyAndBiasCurrentsViewEnabled = dualUserFriendlyAndBiasCurrentsViewEnabled; - } } diff --git a/src/eu/seebetter/ini/chips/davis/DavisUserControlPanel.form b/src/eu/seebetter/ini/chips/davis/DavisUserControlPanel.form index dee6803a1..585e2656c 100644 --- a/src/eu/seebetter/ini/chips/davis/DavisUserControlPanel.form +++ b/src/eu/seebetter/ini/chips/davis/DavisUserControlPanel.form @@ -32,14 +32,20 @@ - + + + + + + + + + + + + - - - - - @@ -51,17 +57,14 @@ - + - - - - + - + @@ -71,13 +74,9 @@ - - - - - + - + @@ -89,7 +88,7 @@ - + @@ -166,48 +165,72 @@ - - - - + - - - - + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + @@ -234,29 +257,14 @@ - + + + + - - - - - - - - - - - - - - - - - - @@ -266,30 +274,22 @@ - - - - + - + + + - - - - - - - - + - + @@ -352,7 +352,7 @@ - + @@ -406,9 +406,6 @@ - - - @@ -416,11 +413,11 @@ - - + + - + @@ -461,7 +458,7 @@ - + @@ -508,7 +505,7 @@ - + @@ -517,9 +514,6 @@ - - - @@ -859,16 +853,6 @@ - - - - - - - - - - diff --git a/src/eu/seebetter/ini/chips/davis/DavisUserControlPanel.java b/src/eu/seebetter/ini/chips/davis/DavisUserControlPanel.java index 42f8faacd..c99ceb47e 100644 --- a/src/eu/seebetter/ini/chips/davis/DavisUserControlPanel.java +++ b/src/eu/seebetter/ini/chips/davis/DavisUserControlPanel.java @@ -373,10 +373,10 @@ private void initComponents() { dvsContSp = new javax.swing.JSpinner(); captureEventsCB = new javax.swing.JCheckBox(); bwPanel = new javax.swing.JPanel(); + bandwidthTweaker = new net.sf.jaer.biasgen.PotTweaker(); bwEstimatePanel = new javax.swing.JPanel(); bwEstLabel = new javax.swing.JLabel(); bwEstTF = new javax.swing.JTextField(); - bandwidthTweaker = new net.sf.jaer.biasgen.PotTweaker(); thrPanel = new javax.swing.JPanel(); thresholdTweaker = new net.sf.jaer.biasgen.PotTweaker(); onOffBalanceTweaker = new net.sf.jaer.biasgen.PotTweaker(); @@ -416,7 +416,6 @@ private void initComponents() { imuPanel = new javax.swing.JPanel(); imuVisibleCB = new javax.swing.JCheckBox(); imuEnabledCB = new javax.swing.JCheckBox(); - toggleDualViewJB = new javax.swing.JToggleButton(); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); @@ -429,9 +428,7 @@ private void initComponents() { .addGap(0, 100, Short.MAX_VALUE) ); - setLayout(new java.awt.BorderLayout()); - - dvsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DVS Events", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N + dvsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DVS", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N dvsPanel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N displayEventsCheckBox.setText("Display events"); @@ -485,25 +482,42 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { dvsPanel.add(captureEventsCB); bwPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - bwPanel.setPreferredSize(new java.awt.Dimension(500, 139)); + + bandwidthTweaker.setToolTipText("Adjust the photoreceptor and source follower bandwidth by changing Pr and PRSf bias currents\n

Limited to changing fine current value. For more control, adjust these currents directly."); + bandwidthTweaker.setLessDescription("Slower"); + bandwidthTweaker.setMinimumSize(new java.awt.Dimension(80, 30)); + bandwidthTweaker.setMoreDescription("Faster"); + bandwidthTweaker.setName("Adjusts pixel bandwidth"); // NOI18N + bandwidthTweaker.setPreferredSize(new java.awt.Dimension(250, 47)); + bandwidthTweaker.setTweakDescription(""); + bandwidthTweaker.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + bandwidthTweakerStateChanged(evt); + } + }); bwEstLabel.setText("Estimated maximum pixel bandwidth"); bwEstLabel.setToolTipText(" Estimated DVS cutoff frequency based solely on source follower bias current.

Does not account for finite photoreceptor bandwidth either from photoreceptor bias or low photocurrent."); bwEstTF.setEditable(false); bwEstTF.setColumns(12); - bwEstTF.setToolTipText(" Estimated DVS cutoff frequency based solely on source follower bias current.\n

Does not account for finite photoreceptor bandwidth either from photoreceptor bias or low photocurrent.\n

Assumes source follower runs in subthreshold, so will only be valid for bias curreents below the specific current"); + bwEstTF.setToolTipText(" Estimated DVS cutoff frequency based solely on source follower bias current.

Does not account for finite photoreceptor bandwidth either from photoreceptor bias or low photocurrent."); + bwEstTF.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + bwEstTFActionPerformed(evt); + } + }); javax.swing.GroupLayout bwEstimatePanelLayout = new javax.swing.GroupLayout(bwEstimatePanel); bwEstimatePanel.setLayout(bwEstimatePanelLayout); bwEstimatePanelLayout.setHorizontalGroup( bwEstimatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(bwEstimatePanelLayout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap(147, Short.MAX_VALUE) .addComponent(bwEstLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(bwEstTF, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(182, 182, 182)) + .addComponent(bwEstTF, javax.swing.GroupLayout.PREFERRED_SIZE, 354, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(104, 104, 104)) ); bwEstimatePanelLayout.setVerticalGroup( bwEstimatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -514,44 +528,36 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addContainerGap()) ); - bandwidthTweaker.setToolTipText("Adjust the source follower bandwidth by changing PRSf bias current.\n

\nFor minimum shot noise under low illumination, the photoreceptor bias should be large and the bandwidth should be limited\nby the source follower buffer. See Optimal biasing and physical limits of DVS event noise. "); - bandwidthTweaker.setLessDescription("Slower"); - bandwidthTweaker.setMinimumSize(new java.awt.Dimension(80, 30)); - bandwidthTweaker.setMoreDescription("Faster"); - bandwidthTweaker.setName("Adjusts maximum photoreceptor bandwidth"); // NOI18N - bandwidthTweaker.setPreferredSize(new java.awt.Dimension(250, 47)); - bandwidthTweaker.setTweakDescription(""); - bandwidthTweaker.addChangeListener(new javax.swing.event.ChangeListener() { - public void stateChanged(javax.swing.event.ChangeEvent evt) { - bandwidthTweakerStateChanged(evt); - } - }); - javax.swing.GroupLayout bwPanelLayout = new javax.swing.GroupLayout(bwPanel); bwPanel.setLayout(bwPanelLayout); bwPanelLayout.setHorizontalGroup( bwPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(bwPanelLayout.createSequentialGroup() .addContainerGap() - .addGroup(bwPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(bwEstimatePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 481, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(bandwidthTweaker, javax.swing.GroupLayout.PREFERRED_SIZE, 481, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(bwEstimatePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(bwPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(bwPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(bandwidthTweaker, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap())) ); bwPanelLayout.setVerticalGroup( bwPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, bwPanelLayout.createSequentialGroup() - .addContainerGap(16, Short.MAX_VALUE) - .addComponent(bandwidthTweaker, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addContainerGap(80, Short.MAX_VALUE) .addComponent(bwEstimatePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) + .addGroup(bwPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(bwPanelLayout.createSequentialGroup() + .addGap(20, 20, 20) + .addComponent(bandwidthTweaker, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(42, Short.MAX_VALUE))) ); dvsPanel.add(bwPanel); thrPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - thrPanel.setPreferredSize(new java.awt.Dimension(500, 202)); thresholdTweaker.setToolTipText("Adjusts DVS event temporal contrast thresholds magnitude
\nby changing current ratios diffOn/diff and diffOff/diff. \n

Limited to only adjusting fine current value;
\nwhen this limit is reached, user must manually change the coarse current value."); thresholdTweaker.setLessDescription("Lower & More events"); @@ -581,7 +587,7 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) { jPanel4.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); - jLabel9.setText("Est. DVS thresholds:"); + jLabel9.setText("Estimated DVS thresholds:"); jLabel9.setToolTipText("Displays computed values of DVS event temporal contrast thresholds
\nbased on paper\nTemperature and\n Parasitic Photocurrent
Effects in Dynamic Vision Sensors,
Y Nozaki, T\nDelbruck.
IEEE Trans. on Electron Devices, 2018
"); jPanel4.add(jLabel9); @@ -618,18 +624,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { thrPanel.setLayout(thrPanelLayout); thrPanelLayout.setHorizontalGroup( thrPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, thrPanelLayout.createSequentialGroup() + .addGroup(thrPanelLayout.createSequentialGroup() .addContainerGap() - .addGroup(thrPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(thrPanelLayout.createSequentialGroup() + .addGroup(thrPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(thresholdTweaker, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(onOffBalanceTweaker, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, thrPanelLayout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) - .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, thrPanelLayout.createSequentialGroup() - .addGroup(thrPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addComponent(onOffBalanceTweaker, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 472, Short.MAX_VALUE) - .addComponent(thresholdTweaker, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGap(0, 0, Short.MAX_VALUE))) - .addGap(231, 231, 231)) + .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 731, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) ); thrPanelLayout.setVerticalGroup( thrPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -646,7 +649,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { dvsPanel.add(thrPanel); refrPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - refrPanel.setPreferredSize(new java.awt.Dimension(500, 118)); maxFiringRateTweaker.setToolTipText("Adjusts the refractory period after each event by changing Refr bias.\n

This current sets the rate at which the reset switch voltage is recharged.\n

Limited to changing fine current value. For more control, adjust these currents directly."); maxFiringRateTweaker.setLessDescription("Slower"); @@ -677,7 +679,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { refrEstimatePanelLayout.setHorizontalGroup( refrEstimatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(refrEstimatePanelLayout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(229, 229, 229) .addComponent(refrPerLabel) .addGap(5, 5, 5) .addComponent(refrPerTF, javax.swing.GroupLayout.PREFERRED_SIZE, 348, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -699,10 +701,10 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { refrPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(refrPanelLayout.createSequentialGroup() .addGap(0, 0, 0) - .addGroup(refrPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(refrEstimatePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 481, Short.MAX_VALUE) - .addComponent(maxFiringRateTweaker, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap(17, Short.MAX_VALUE)) + .addGroup(refrPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(maxFiringRateTweaker, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(refrEstimatePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) ); refrPanelLayout.setVerticalGroup( refrPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -716,7 +718,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { dvsPanel.add(refrPanel); - apsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Frames", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N + apsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Image Sensor", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N apsPanel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel1.setText("Target Frame rate (Hz)"); @@ -972,15 +974,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(imuVisibleCB, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)) ); - toggleDualViewJB.setMnemonic('D'); - toggleDualViewJB.setText("Dual view"); - toggleDualViewJB.setToolTipText("Toggles dual view of user-friendly and low level bias currents (to learn effects)"); - toggleDualViewJB.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - toggleDualViewJBActionPerformed(evt); - } - }); - javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( @@ -988,14 +981,12 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(dvsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 569, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dvsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 789, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(apsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(imuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(toggleDualViewJB)))) - .addContainerGap(2379, Short.MAX_VALUE)) + .addComponent(imuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(2159, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -1003,20 +994,24 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(apsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(jPanel2Layout.createSequentialGroup() - .addComponent(toggleDualViewJB) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(imuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGap(27, 27, 27) + .addComponent(imuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(dvsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 532, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(158, Short.MAX_VALUE)) ); - apsPanel.getAccessibleContext().setAccessibleName("Frames"); - jScrollPane1.setViewportView(jPanel2); - add(jScrollPane1, java.awt.BorderLayout.CENTER); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 835, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 735, Short.MAX_VALUE) + ); }// //GEN-END:initComponents private void offThrTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_offThrTFActionPerformed @@ -1027,17 +1022,9 @@ private void refrPerTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR // TODO add your handling code here: }//GEN-LAST:event_refrPerTFActionPerformed - private void toggleDualViewJBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toggleDualViewJBActionPerformed - boolean oldState=!toggleDualViewJB.isSelected(); - // fire a propoerty change that the biasgen (DavisConfig) can respond to by toggling the dual view - getConfig().setDualView(toggleDualViewJB.isSelected()); - }//GEN-LAST:event_toggleDualViewJBActionPerformed - - private void bandwidthTweakerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_bandwidthTweakerStateChanged - getDvsTweaks().setBandwidthTweak(bandwidthTweaker.getValue()); - setEstimatedBandwidth(); - setFileModified(); - }//GEN-LAST:event_bandwidthTweakerStateChanged + private void bwEstTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bwEstTFActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_bwEstTFActionPerformed private void glShutterCBActionPerformed(final java.awt.event.ActionEvent evt) {// GEN-FIRST:event_glShutterCBActionPerformed ((DavisBaseCamera) chip).getDavisConfig().setGlobalShutter(glShutterCB.isSelected()); @@ -1061,6 +1048,11 @@ private void autoContrastCBActionPerformed(final java.awt.event.ActionEvent evt) contrastController.setUseAutoContrast(autoContrastCB.isSelected()); }// GEN-LAST:event_autoContrastCBActionPerformed + private void bandwidthTweakerStateChanged(final javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_bandwidthTweakerStateChanged + getDvsTweaks().setBandwidthTweak(bandwidthTweaker.getValue()); + setEstimatedBandwidth(); + setFileModified(); + }// GEN-LAST:event_bandwidthTweakerStateChanged private void setEstimatedThresholdValues() { final float onThresholdLogE = apsDvsTweaks.getOnThresholdLogE(); @@ -1240,7 +1232,6 @@ private void imuEnabledCBActionPerformed(final java.awt.event.ActionEvent evt) { private javax.swing.JButton snapshotButton; private javax.swing.JPanel thrPanel; private net.sf.jaer.biasgen.PotTweaker thresholdTweaker; - private javax.swing.JToggleButton toggleDualViewJB; // End of variables declaration//GEN-END:variables /** diff --git a/src/net/sf/jaer/eventprocessing/filter/EventRateEstimator.java b/src/net/sf/jaer/eventprocessing/filter/EventRateEstimator.java index c6562b1c0..8d9cd29da 100644 --- a/src/net/sf/jaer/eventprocessing/filter/EventRateEstimator.java +++ b/src/net/sf/jaer/eventprocessing/filter/EventRateEstimator.java @@ -4,7 +4,6 @@ */ package net.sf.jaer.eventprocessing.filter; -import java.beans.PropertyChangeEvent; import net.sf.jaer.Description; import net.sf.jaer.DevelopmentStatus; import net.sf.jaer.aemonitor.AEConstants; @@ -12,7 +11,7 @@ import net.sf.jaer.event.BasicEvent; import net.sf.jaer.event.EventPacket; import net.sf.jaer.eventprocessing.EventFilter2D; -import net.sf.jaer.graphics.AEViewer; +import net.sf.jaer.util.filter.LowpassFilter; /** * Estimates event rate from the input stream. @@ -40,20 +39,16 @@ public class EventRateEstimator extends EventFilter2D { private float maxRate = getFloat("maxRate", 10e6f); private float filteredRate = 0, instantaneousRate = 0; private float eventRateTauMs = getFloat("eventRateTauMs", 100); - private float biasChangePauseS = getFloat("biasChangePauseS", .5f); /* Event rate estimates are sent to observers this many times per tau */ protected int UPDATE_RATE_TAU_DIVIDER = 1; private int numEventsSinceLastUpdate = 0; private int numEventsInLastPacket = 0; - private boolean biasChanged=false; - private long biasChangedTimeMs=0; public EventRateEstimator(AEChip chip) { super(chip); // filter.setTauMs(eventRateTauMs); setPropertyTooltip("eventRateTauMs", "lowpass filter time constant in ms for measuring event rate"); setPropertyTooltip("maxRate", "maximum estimated rate, which is used for zero ISIs between packets"); - setPropertyTooltip("biasChangePauseS", "time in seconds to pause measurement after detected change of any bias (0 to disable)"); } @Override @@ -61,16 +56,6 @@ synchronized public EventPacket filterPacket(EventPacket0) { - final long timeSinceBiasChangeMs = System.currentTimeMillis() - biasChangedTimeMs; - if (timeSinceBiasChangeMs < 1000 * this.biasChangePauseS) { - lastComputeTimestamp = in.getLastTimestamp(); -// System.out.println(String.format("timeSinceBiasChangeMs=%d < %.0f",timeSinceBiasChangeMs,1000*this.biasChangePauseS)); - return in; - } else { - biasChanged = false; - } - } numEventsInLastPacket = 0; for (BasicEvent e : in) { addEvent(e, in); @@ -130,10 +115,6 @@ public void resetFilter() { @Override public void initFilter() { resetFilter(); - if (chip.getAeViewer() != null) { - chip.getAeViewer().getSupport().addPropertyChangeListener(AEViewer.EVENT_CHIP, this); - chip.getBiasgen().getSupport().addPropertyChangeListener(this); - } } @Override @@ -141,14 +122,6 @@ public String toString() { return super.toString() + " rate=" + filteredRate; } - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getSource() instanceof AEChip) { - biasChanged = true; - biasChangedTimeMs=System.currentTimeMillis(); - } - } - public float getEventRateTauMs() { return eventRateTauMs; } @@ -210,20 +183,4 @@ public void setMaxRate(float maxRate) { public int getNumEventsInLastPacket() { return numEventsInLastPacket; } - - /** - * @return the biasChangePauseS - */ - public float getBiasChangePauseS() { - return biasChangePauseS; - } - - /** - * @param biasChangePauseS the biasChangePauseS to set - */ - synchronized public void setBiasChangePauseS(float biasChangePauseS) { - this.biasChangePauseS = biasChangePauseS; - putFloat("biasChangePauseS",biasChangePauseS); -// log.info(String.format("Set biasChangePauseS=%.3fs",this.biasChangePauseS)); - } } diff --git a/src/net/sf/jaer/eventprocessing/filter/Info.java b/src/net/sf/jaer/eventprocessing/filter/Info.java index 96e787316..c96fee8f7 100644 --- a/src/net/sf/jaer/eventprocessing/filter/Info.java +++ b/src/net/sf/jaer/eventprocessing/filter/Info.java @@ -85,7 +85,6 @@ public class Info extends EventFilter2D implements FrameAnnotater, PropertyChang // volatile private float eventRateMeasured = 0; // volatile, also shared private boolean addedViewerPropertyChangeListener = false; // need flag because viewer doesn't exist on creation private boolean eventRate = getBoolean("eventRate", true); - private boolean eventRatePerPixel = getBoolean("eventRatePerPixel", false); private volatile boolean resetTimeEnabled = false; // user for doResetTime private boolean resetTimeOnRewind = getBoolean("resetTimeOnRewind", false); @@ -392,7 +391,6 @@ public Info(AEChip chip) { setPropertyTooltip("eventRateScaleMax", "scale event rates to this maximum"); setPropertyTooltip("timeScaling", "shows time scaling relative to real time"); setPropertyTooltip("eventRate", "shows average event rate"); - setPropertyTooltip("eventRatePerPixel", "shows average event rate per pixel (selected) or total (unselected). Set eventRateScaleMax to scale bars."); setPropertyTooltip("eventRateSigned", "uses signed event rate for ON positive and OFF negative"); setPropertyTooltip("eventRateTauMs", "lowpass time constant in ms for filtering event rate"); setPropertyTooltip("showRateTrace", "shows a historical trace of event rate"); @@ -800,8 +798,7 @@ private void drawEventRateBars(GLAutoDrawable drawable) { // and multiply by number of pixels to get string length in screen pixels. float sw = (glut.glutBitmapLength(font, s) / w) * sx; glut.glutBitmapString(font, s); - float rate=isEventRatePerPixel()? perPixelRate:totalRate; - gl.glRectf(xpos + sw, bary + barh, xpos + sw + ((rate * sx) / getEventRateScaleMax()), bary); + gl.glRectf(xpos + sw, bary + barh, xpos + sw + ((totalRate * sx) / getEventRateScaleMax()), bary); } gl.glPopMatrix(); @@ -1062,19 +1059,4 @@ public void setMeasureSparsity(boolean measureSparsity) { putBoolean("measureSparsity", measureSparsity); } - /** - * @return the eventRatePerPixel - */ - public boolean isEventRatePerPixel() { - return eventRatePerPixel; - } - - /** - * @param eventRatePerPixel the eventRatePerPixel to set - */ - public void setEventRatePerPixel(boolean eventRatePerPixel) { - this.eventRatePerPixel = eventRatePerPixel; - putBoolean("eventRatePerPixel", eventRatePerPixel); - } - } diff --git a/src/net/sf/jaer/util/textio/DavisTextInputReader.java b/src/net/sf/jaer/util/textio/DavisTextInputReader.java index 1a5acd051..435d2774b 100644 --- a/src/net/sf/jaer/util/textio/DavisTextInputReader.java +++ b/src/net/sf/jaer/util/textio/DavisTextInputReader.java @@ -21,14 +21,18 @@ import com.jogamp.opengl.GL2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.util.gl2.GLUT; -import java.awt.Cursor; import java.beans.PropertyChangeListener; import java.io.BufferedReader; import java.io.EOFException; import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.util.HashMap; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.stream.Stream; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.filechooser.FileFilter; @@ -65,7 +69,7 @@ public class DavisTextInputReader extends AbstractDavisTextIo implements Propert private BufferedReader dvsReader = null; private int lastTimestampRead = Integer.MIN_VALUE, lastPacketLastTimestamp = Integer.MIN_VALUE; private boolean noEventsReadYet = true; // set false when new file is opened - private int numEventsThisPacket = 0, numEventsInFile = 0; + private int numEventsThisPacket=0, numEventsInFile=0; private ApsDvsEventPacket outputPacket = null; int maxX = chip.getSizeX(), maxY = chip.getSizeY(); private boolean weWereNeverEnabled = true; // Tobi added this hack to work around the problem that if we are included in FilterChain but not enabled, @@ -76,8 +80,7 @@ public class DavisTextInputReader extends AbstractDavisTextIo implements Propert private int previousTimestamp = 0; private boolean openFileAndRecordAedat = false; protected boolean flipPolarity = getBoolean("flipPolarity", false); - final int SPECIAL_COL = 4; // location of special flag (0 normal, 1 special) - private HashMap previousFilesLinesMap = new HashMap(); + final int SPECIAL_COL=4; // location of special flag (0 normal, 1 special) public DavisTextInputReader(AEChip chip) { super(chip); @@ -87,7 +90,6 @@ public DavisTextInputReader(AEChip chip) { setPropertyTooltip("checkNonMonotonicTimestamps", "Checks to ensure timestamps are read in monotonically increasing order."); setPropertyTooltip("openFileAndRecordAedat", "Opens text file and re-records it as an AEDAT file with same name but .aedat2 extension."); setPropertyTooltip("flipPolarity", "Reading polarity: Unselected ON:1 or +1, OFF, 0 or -1. Selected flips ON and OFF so that ON is 0 or -1, OFF is 1 or +1."); - previousFilesLinesMap = (HashMap) getObject("previousFilesLinesMap", new HashMap()); chip.getSupport().addPropertyChangeListener(this); } @@ -125,7 +127,7 @@ public synchronized void setFilterEnabled(boolean yes) { private void setViewerToFilterInputViewMode() { getChip().getAeViewer().setPlayMode(AEViewer.PlayMode.FILTER_INPUT); // TODO may not work - weWereNeverEnabled = false; + weWereNeverEnabled = false; } /** @@ -142,28 +144,15 @@ public BufferedReader openReader(File f) throws IOException { long lineCount; // https://stackoverflow.com/questions/1277880/how-can-i-get-the-count-of-line-in-a-file-in-an-efficient-way BufferedReader reader = new BufferedReader(new FileReader(f)); - if (previousFilesLinesMap.containsKey(f.getAbsolutePath())) { - numEventsInFile = previousFilesLinesMap.get(f.getAbsolutePath()); - log.info(String.format("%,d events previously in file %s",numEventsInFile,f.getAbsolutePath())); - } else { - log.info("counting events in file.... please wait"); - long t0 = System.currentTimeMillis(); - - numEventsInFile = 0; - final int DOT_COUNT = 300000; - while (reader.readLine() != null) { - numEventsInFile++; - if (numEventsInFile % DOT_COUNT == 0) { - System.out.print('.'); - } - } - previousFilesLinesMap.put(f.getAbsolutePath(), numEventsInFile); - putObject("previousFilesLinesMap", previousFilesLinesMap); - long t1 = System.currentTimeMillis(); - float dtS = (t1 - t0) / 1000f; - float linesPerSec = numEventsInFile / dtS; - log.info(String.format("Counted %,d events in %.1fs (%.2gHz) in file %s", numEventsInFile, dtS, linesPerSec, f)); + log.info("counting events in file...."); + numEventsInFile = 0; + while (reader.readLine() != null) { + numEventsInFile++; } + reader.close(); + log.info(String.format("%s has %,d events",f,numEventsInFile)); + reader = new BufferedReader(new FileReader(f)); + lastFile = f; setEventsProcessed(0); noEventsReadYet = true; lastLineNumber = 0; @@ -171,11 +160,10 @@ public BufferedReader openReader(File f) throws IOException { lastTimestampRead = Integer.MIN_VALUE; log.info("Opened text input file " + f.toString() + " with text format"); setViewerToFilterInputViewMode(); - lastFile = f; return reader; } - @Override + @Override public void annotate(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glPushMatrix(); @@ -188,7 +176,7 @@ public void annotate(GLAutoDrawable drawable) { filePercent); glut.glutBitmapString(GLUT.BITMAP_HELVETICA_18, s); gl.glPopMatrix(); - getChip().getAeViewer().getAePlayer().setFractionalPosition(filePercent / 100); + getChip().getAeViewer().getAePlayer().setFractionalPosition(filePercent/100); } private float getFilePercent() { @@ -227,13 +215,10 @@ public String getDescription() { if (dvsReader != null) { doCloseFile(); } - setCursor(new Cursor(Cursor.WAIT_CURSOR)); dvsReader = openReader(c.getSelectedFile()); } catch (IOException ex) { JOptionPane.showMessageDialog(null, ex.toString(), "Couldn't open input file", JOptionPane.WARNING_MESSAGE, null); - } finally { - setCursor(Cursor.getDefaultCursor()); } } @@ -257,7 +242,7 @@ synchronized public void doRewind() { try { dvsReader = openReader(lastFile); } catch (IOException ex) { - log.warning("coud not open file "+lastFile +": "+ex.toString()); + Logger.getLogger(DavisTextInputReader.class.getName()).log(Level.SEVERE, null, ex); } } } @@ -354,14 +339,15 @@ private void parseEvent(String line, OutputEventIterator outItr) throws IOExcept return; } String[] split = useCSV ? line.split(",") : line.split(" "); // split by comma or space - if (split == null || (!isSpecialEvents() && split.length != 4) || (isSpecialEvents() && split.length != 5)) { + if (split == null || (!isSpecialEvents() && split.length != 4) || (isSpecialEvents() && split.length!=5)) { log.warning(String.format("Line #%d does not have enough tokens, needs 4 without and 5 with specialEvents:\n\"%s\"", lastLineNumber, line)); - if (errorCount++ > MAX_ERRORS) { - log.warning(String.format("Gave up after %d errors, closing file", errorCount)); + if(errorCount++>MAX_ERRORS){ + log.warning(String.format("Gave up after %d errors, closing file",errorCount)); doCloseFile(); } return; } + int ix, iy, ip, it; if (timestampLast) { @@ -391,7 +377,7 @@ private void parseEvent(String line, OutputEventIterator outItr) throws IOExcept byte pol = Byte.parseByte(split[ip]); if (x < 0 || x >= maxX || y < 0 || y >= maxY) { log.warning(String.format("address outside of AEChip allowed range: x=%d y=%d, ignoring. %s ", x, y, pol, lineinfo(line))); - if (errorCount++ > MAX_ERRORS) { + if (errorCount++ > MAX_ERRORS) { throw new IOException(String.format("Generated more than %d errors reading file; giving up and closing file.", errorCount)); } } @@ -407,10 +393,10 @@ private void parseEvent(String line, OutputEventIterator outItr) throws IOExcept } else { if (pol < 0 || pol > 1) { log.warning(String.format("polarity %d is not valid (check useSignedPolarity flag), ignoring. %s", pol, lineinfo(line))); - if (errorCount++ > MAX_ERRORS) { - throw new IOException(String.format("Generated more than %d errors reading file; giving up and closing file.", errorCount)); - } - } else if (pol == 1) { + if (errorCount++ > MAX_ERRORS) { + throw new IOException(String.format("Generated more than %d errors reading file; giving up and closing file.", errorCount)); + } + } else if (pol == 1) { polType = Polarity.On; } } @@ -425,15 +411,15 @@ private void parseEvent(String line, OutputEventIterator outItr) throws IOExcept if (flipPolarity) { e.flipPolarity(); } - e.setType(polType == Polarity.Off ? (byte) 0 : (byte) 1); + e.setType(polType==Polarity.Off? (byte)0:(byte)1); e.setDvsType(); - if (isSpecialEvents()) { - int specialFlag = Integer.parseInt(split[SPECIAL_COL]); - if (specialFlag == 0) { + if(isSpecialEvents()){ + int specialFlag=Integer.parseInt(split[SPECIAL_COL]); + if(specialFlag==0){ e.setSpecial(false); - } else if (specialFlag == 1) { + }else if(specialFlag==1){ e.setSpecial(true); - } else { + }else{ log.warning(String.format("Line #%d has Unknown type of special event, must be 0 (normal) or 1 (special):\n\"%s\"", lastLineNumber, line)); errorCount++; if (errorCount++ > MAX_ERRORS) {