Skip to content

Commit

Permalink
Merge branch 'fix/mra-exporters-load-performance' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
paulosousadias committed Dec 16, 2024
2 parents 9cda161 + a8a11a5 commit a0f9571
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ public class VideoHudExporter implements MRAExporter {


public VideoHudExporter(IMraLogGroup source) {
this.positions = new CorrectedPosition(source);
if (source.getCorrectedPosition() != null) {
this.positions = source.getCorrectedPosition();
}
else { this.positions = new CorrectedPosition(source); }

this.frameDecoder = new FrameDecoderMotionJPEG();
hud = new MraVehiclePosHud(source, 180, 180);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ public class VideoToPhotosFilter implements MRAExporter{


public VideoToPhotosFilter(IMraLogGroup source) {
this.positions = new CorrectedPosition(source);
if (source.getCorrectedPosition() != null) {
this.positions = source.getCorrectedPosition();
}
else { this.positions = new CorrectedPosition(source); }

this.frameDecoder = new FrameDecoderMotionJPEG();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@
@PluginDescription(name="Export image positions to CSV")
public class ImagePositionsExporter implements MRAExporter {
private CorrectedPosition positions;

public ImagePositionsExporter(IMraLogGroup source) {
positions = new CorrectedPosition(source);
if (source.getCorrectedPosition() != null) {
this.positions = source.getCorrectedPosition();
}
else {
this.positions = new CorrectedPosition(source);
}
}

@Override
Expand Down
15 changes: 15 additions & 0 deletions src/java/pt/lsts/neptus/mra/MRAMenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.lang.reflect.Constructor;
import java.net.URI;
import java.text.Collator;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -76,6 +77,7 @@
import pt.lsts.neptus.gui.PropertiesEditor;
import pt.lsts.neptus.gui.WaitPanel;
import pt.lsts.neptus.i18n.I18n;
import pt.lsts.neptus.mra.api.CorrectedPosition;
import pt.lsts.neptus.mra.exporters.MRAExporter;
import pt.lsts.neptus.mra.importers.IMraLogGroup;
import pt.lsts.neptus.mra.importers.lsf.ConcatenateLsfLog;
Expand Down Expand Up @@ -615,12 +617,25 @@ public void setUpExportersMenu(final IMraLogGroup source) {

//Vector<MRAExporter> exporterList = new Vector<>();

boolean useCP = false;
CorrectedPosition positions;

for (Class<? extends MRAExporter> clazz : exporterMap.values()) {

if (!useCP) {
if (Arrays.toString(clazz.getDeclaredFields()).contains("CorrectedPosition")) {
positions = new CorrectedPosition(source);
source.setCorrectedPosition(positions);
useCP = true;
}
}

Constructor<?>[] constructors = clazz.getConstructors();

boolean added = false;

for (Constructor<?> c : constructors) {

if (c.getParameterTypes().length == 1 && c.getParameterTypes()[0].equals(IMraLogGroup.class)) {
try {
exporters.put(PluginUtils.getPluginI18nName(clazz), clazz.getConstructor(IMraLogGroup.class).newInstance(new Object[] { source }));
Expand Down
4 changes: 4 additions & 0 deletions src/java/pt/lsts/neptus/mra/importers/IMraLogGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.LinkedHashMap;

import pt.lsts.imc.lsf.LsfIndex;
import pt.lsts.neptus.mra.api.CorrectedPosition;

/**
* This interface is used to represent a logical group of log files. For instance, in a mission several log files are produced.
Expand Down Expand Up @@ -85,4 +86,7 @@ public interface IMraLogGroup {
public Collection<Integer> getVehicleSources();

public LsfIndex getLsfIndex();

public void setCorrectedPosition(CorrectedPosition positions);
public CorrectedPosition getCorrectedPosition();
}
8 changes: 8 additions & 0 deletions src/java/pt/lsts/neptus/util/llf/LsfLogSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import pt.lsts.imc.lsf.LsfIndex;
import pt.lsts.imc.lsf.LsfIndexListener;
import pt.lsts.neptus.NeptusLog;
import pt.lsts.neptus.mra.api.CorrectedPosition;
import pt.lsts.neptus.mra.importers.IMraLog;
import pt.lsts.neptus.mra.importers.IMraLogGroup;
import pt.lsts.neptus.mra.importers.lsf.LsfMraLog;
Expand All @@ -66,6 +67,7 @@ public class LsfLogSource implements IMraLogGroup {
LsfIndexListener listener = null;
String[] existingMessages = null;
Collection<Integer> vehicleSources;
CorrectedPosition positions;


public LsfLogSource(String filename, LsfIndexListener listener) throws Exception {
Expand Down Expand Up @@ -278,4 +280,10 @@ public Collection<Integer> getVehicleSources() {
public LsfIndex getLsfIndex() {
return index;
}

@Override
public void setCorrectedPosition(CorrectedPosition newPositions) { positions = newPositions; }

@Override
public CorrectedPosition getCorrectedPosition() { return positions; }
}

0 comments on commit a0f9571

Please sign in to comment.