Skip to content

Commit e16d17d

Browse files
committed
st1002: implementation of Range Image Local Set
This required ST 1202 transformations, which in turn required ST 1010 SDCC. Includes usual javadoc, unit tests and a generator example.
1 parent be4ac43 commit e16d17d

File tree

129 files changed

+10496
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+10496
-4
lines changed

.github/workflows/jdk11.yml

+15
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,26 @@ jobs:
7474
with:
7575
file: ./st0903vtrack/target/site/jacoco/jacoco.xml
7676
flags: unittests-st0903-vtrack
77+
- name: Upload ST 1002 implementation test results to Codecov
78+
uses: codecov/[email protected]
79+
with:
80+
file: ./st1002/target/site/jacoco/jacoco.xml
81+
flags: unittests-st1002
82+
- name: Upload ST 1010 implementation test results to Codecov
83+
uses: codecov/[email protected]
84+
with:
85+
file: ./st1010/target/site/jacoco/jacoco.xml
86+
flags: unittests-st1010
7787
- name: Upload ST 1108 implementation test results to Codecov
7888
uses: codecov/[email protected]
7989
with:
8090
file: ./st1108/target/site/jacoco/jacoco.xml
8191
flags: unittests-st1108
92+
- name: Upload ST 1202 implementation test results to Codecov
93+
uses: codecov/[email protected]
94+
with:
95+
file: ./st1202/target/site/jacoco/jacoco.xml
96+
flags: unittests-st1202
8297
- name: Upload ST 1206 implementation test results to Codecov
8398
uses: codecov/[email protected]
8499
with:

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ The table below lists the status of currently-supported standards:
4949
| ST 0808 | Ancillary Text Metadata Sets | Implemented as of ST 0808.2. Local Set support only, no universal set support. Deprecated by MISB. | |
5050
| ST 0809 | Meteorological Metadata Local Set | Implemented as of ST 0809.2. No interoperability testing. | |
5151
| ST 0903 | Video Moving Target Indicator and Track Metadata | VMTI and VTrack Local Sets implemented as of ST 0903.5. We also support pre-ST0903.4 files. | |
52+
| ST 1002 | Range Motion Imagery | Partly implemented as of ST 1002.2. No interoperability testing. | |
53+
| ST 1010 | Generalized Standard Deviation and Correlation Coefficient Metadata | Partly implemented as of ST 1010.3. No support for ST 1201 formatted standard deviation values. | |
5254
| ST 1108 | Motion Imagery Interpretability and Quality Metadata | Implemented as of ST 1108.3. ST 1108.2 and earlier is also supported. No interoperability testing. | |
5355
| ST 1201 | Floating Point to Integer Mapping | Fully implemented per ST 1201.5. | |
56+
| ST 1202 | Generalized Transformation Parameters | Mostly implemented as of ST 1202.2. | |
5457
| ST 1204 | Motion Imagery Identification System (MIIS) Core Identifier | Implemented as of ST 1204.3. | |
5558
| ST 1206 | Synthetic Aperture Radar (SAR) Motion Imagery Metadata | Implemented as of ST 1206.1. Unit tests only, no interoperability testing. | |
5659
| ST 1301 | Motion Imagery Identification System (MIIS) - Augmentation Identifiers | Implemented as of ST 1301.2. Validated with CMITT. | |

api/src/main/java/org/jmisb/api/common/KlvParseException.java

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
/** Indicates an error occurred during metadata parsing. */
66
public class KlvParseException extends Exception {
7+
/** Internal store for inner exception. */
78
private final byte[] buffer;
89

910
/**

examples/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ This example considered complete. See [its README](parserplugin/README.md) for m
5252
It does a console dump of the raw KLV in a file to standard output. In this context, "raw" is the de-multiplexed stream content.
5353
This example is considered complete. See [its README](rawklv/README.md) for more information.
5454

55+
## rangeimagegenerator
56+
57+
It generates a test file with video and ST 1002 Range Image KLV metadata. This example is a work-in-progress.
58+
5559
## systemout
5660

5761
It does a console dump of the KLV metadata in a file to standard output (`System.out` in Java, hence the name).

examples/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<module>rawklv</module>
2424
<module>annotations</module>
2525
<module>timetransfer</module>
26+
<module>rangeimagegenerator</module>
2627
</modules>
2728

2829
<dependencyManagement>

examples/rangeimagegenerator/pom.xml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>org.jmisb</groupId>
6+
<artifactId>examples</artifactId>
7+
<version>2.0.0-SNAPSHOT</version>
8+
</parent>
9+
<artifactId>rangeimagegenerator</artifactId>
10+
<packaging>jar</packaging>
11+
<name>Range image generator example</name>
12+
<description>Example code that generates ST 1002 range image test files.</description>
13+
<properties>
14+
<main.class>org.jmisb.examples.rangeimagegenerator.GeneratorCLI</main.class>
15+
</properties>
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.jmisb</groupId>
19+
<artifactId>jmisb-api-ffmpeg</artifactId>
20+
<version>${project.version}</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.slf4j</groupId>
24+
<artifactId>slf4j-simple</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>commons-cli</groupId>
28+
<artifactId>commons-cli</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.jmisb</groupId>
32+
<artifactId>st1002</artifactId>
33+
<version>${project.version}</version>
34+
</dependency>
35+
</dependencies>
36+
<build>
37+
<plugins>
38+
<plugin>
39+
<groupId>com.theoryinpractise</groupId>
40+
<artifactId>googleformatter-maven-plugin</artifactId>
41+
</plugin>
42+
<plugin>
43+
<groupId>org.apache.maven.plugins</groupId>
44+
<artifactId>maven-shade-plugin</artifactId>
45+
</plugin>
46+
</plugins>
47+
</build>
48+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module org.jmisb.examples.rangeimagegenerator {
2+
requires org.jmisb.api.ffmpeg;
3+
requires org.jmisb.api;
4+
requires org.jmisb.core;
5+
requires org.jmisb.st1002;
6+
requires org.jmisb.st1010;
7+
requires org.jmisb.st1202;
8+
requires commons.cli;
9+
requires java.desktop;
10+
requires org.slf4j;
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
package org.jmisb.examples.rangeimagegenerator;
2+
3+
import java.awt.image.BufferedImage;
4+
import java.io.File;
5+
import java.io.IOException;
6+
import java.util.Map;
7+
import java.util.SortedMap;
8+
import java.util.TreeMap;
9+
import java.util.UUID;
10+
import javax.imageio.ImageIO;
11+
import org.jmisb.api.common.KlvParseException;
12+
import org.jmisb.api.klv.st1204.CoreIdentifier;
13+
import org.jmisb.api.video.CodecIdentifier;
14+
import org.jmisb.api.video.IVideoFileOutput;
15+
import org.jmisb.api.video.KlvFormat;
16+
import org.jmisb.api.video.MetadataFrame;
17+
import org.jmisb.api.video.VideoFileOutput;
18+
import org.jmisb.api.video.VideoFrame;
19+
import org.jmisb.api.video.VideoOutputOptions;
20+
import org.jmisb.core.video.TimingUtils;
21+
import org.jmisb.st1002.GeneralizedTransformation;
22+
import org.jmisb.st1002.IRangeImageMetadataValue;
23+
import org.jmisb.st1002.RangeImageCompressionMethod;
24+
import org.jmisb.st1002.RangeImageEnumerations;
25+
import org.jmisb.st1002.RangeImageLocalSet;
26+
import org.jmisb.st1002.RangeImageMetadataKey;
27+
import org.jmisb.st1002.RangeImageSource;
28+
import org.jmisb.st1002.RangeImageryDataType;
29+
import org.jmisb.st1002.ST1002PrecisionTimeStamp;
30+
import org.jmisb.st1002.ST1002VersionNumber;
31+
import org.jmisb.st1002.SinglePointRangeMeasurement;
32+
import org.jmisb.st1002.SinglePointRangeMeasurementColumn;
33+
import org.jmisb.st1002.SinglePointRangeMeasurementRow;
34+
import org.jmisb.st1010.SDCC;
35+
import org.jmisb.st1202.Denominator_X;
36+
import org.jmisb.st1202.Denominator_Y;
37+
import org.jmisb.st1202.GeneralizedTransformationLocalSet;
38+
import org.jmisb.st1202.GeneralizedTransformationParametersKey;
39+
import org.jmisb.st1202.IGeneralizedTransformationMetadataValue;
40+
import org.jmisb.st1202.SDCC_FLP;
41+
import org.jmisb.st1202.ST1202DocumentVersion;
42+
import org.jmisb.st1202.TransformationEnumeration;
43+
import org.jmisb.st1202.X_Numerator_Constant;
44+
import org.jmisb.st1202.X_Numerator_X;
45+
import org.jmisb.st1202.X_Numerator_Y;
46+
import org.jmisb.st1202.Y_Numerator_Constant;
47+
import org.jmisb.st1202.Y_Numerator_X;
48+
import org.jmisb.st1202.Y_Numerator_Y;
49+
import org.slf4j.Logger;
50+
import org.slf4j.LoggerFactory;
51+
52+
public class Generator {
53+
54+
private static Logger LOG = LoggerFactory.getLogger(Generator.class);
55+
private final int width = 1280;
56+
private final int height = 960;
57+
private final int bitRate = 500_000;
58+
private final int gopSize = 30;
59+
private final double frameRate = 15.0;
60+
private final double frameDuration = 1.0 / frameRate;
61+
private final int duration = 60;
62+
private KlvFormat klvFormat = KlvFormat.Synchronous;
63+
private CodecIdentifier codec = CodecIdentifier.H264;
64+
private String filename = "rangeimage.ts";
65+
66+
public Generator() throws KlvParseException {}
67+
68+
public void setKlvFormat(KlvFormat klvFormat) {
69+
this.klvFormat = klvFormat;
70+
}
71+
72+
public void setCodec(CodecIdentifier codec) {
73+
this.codec = codec;
74+
}
75+
76+
public void setOutputFile(String filename) {
77+
this.filename = filename;
78+
}
79+
80+
public void generate() throws KlvParseException {
81+
showConfiguration();
82+
CoreIdentifier coreIdentifier = new CoreIdentifier();
83+
coreIdentifier.setMinorUUID(UUID.randomUUID());
84+
coreIdentifier.setVersion(1);
85+
86+
try (IVideoFileOutput output =
87+
new VideoFileOutput(
88+
new VideoOutputOptions(
89+
width, height, bitRate, frameRate, gopSize, klvFormat, codec))) {
90+
output.open(filename);
91+
92+
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
93+
try {
94+
image = ImageIO.read(new File("test1280.jpg"));
95+
} catch (IOException e) {
96+
// TODO: log
97+
}
98+
99+
final long numFrames = duration * Math.round(frameRate);
100+
long startTime = System.currentTimeMillis();
101+
double pts = 1000.0 * System.currentTimeMillis(); // Close enough for this.
102+
for (long i = 0; i < numFrames; ++i) {
103+
output.addVideoFrame(new VideoFrame(image, pts * 1.0e-6));
104+
SortedMap<RangeImageMetadataKey, IRangeImageMetadataValue> values = new TreeMap<>();
105+
values.put(
106+
RangeImageMetadataKey.PrecisionTimeStamp,
107+
new ST1002PrecisionTimeStamp((long) pts));
108+
values.put(RangeImageMetadataKey.DocumentVersion, new ST1002VersionNumber(2));
109+
values.put(
110+
RangeImageMetadataKey.RangeImageEnumerations,
111+
new RangeImageEnumerations(
112+
RangeImageCompressionMethod.NO_COMPRESSION,
113+
RangeImageryDataType.PERSPECTIVE,
114+
RangeImageSource.RANGE_SENSOR));
115+
values.put(
116+
RangeImageMetadataKey.SinglePointRangeMeasurement,
117+
new SinglePointRangeMeasurement(8000));
118+
values.put(
119+
RangeImageMetadataKey.SinglePointRangeMeasurementRowCoordinate,
120+
new SinglePointRangeMeasurementRow(403));
121+
values.put(
122+
RangeImageMetadataKey.SinglePointRangeMeasurementColumnCoordinate,
123+
new SinglePointRangeMeasurementColumn(803));
124+
Map<GeneralizedTransformationParametersKey, IGeneralizedTransformationMetadataValue>
125+
st1202values = new TreeMap<>();
126+
st1202values.put(
127+
GeneralizedTransformationParametersKey.X_Numerator_x, new X_Numerator_X(0));
128+
st1202values.put(
129+
GeneralizedTransformationParametersKey.X_Numerator_y, new X_Numerator_Y(0));
130+
st1202values.put(
131+
GeneralizedTransformationParametersKey.X_Numerator_Constant,
132+
new X_Numerator_Constant(0));
133+
st1202values.put(
134+
GeneralizedTransformationParametersKey.Y_Numerator_x, new Y_Numerator_X(0));
135+
st1202values.put(
136+
GeneralizedTransformationParametersKey.Y_Numerator_y, new Y_Numerator_Y(0));
137+
st1202values.put(
138+
GeneralizedTransformationParametersKey.Y_Numerator_Constant,
139+
new Y_Numerator_Constant(0));
140+
st1202values.put(
141+
GeneralizedTransformationParametersKey.Denominator_x, new Denominator_X(0));
142+
st1202values.put(
143+
GeneralizedTransformationParametersKey.Denominator_y, new Denominator_Y(0));
144+
st1202values.put(
145+
GeneralizedTransformationParametersKey.DocumentVersion,
146+
new ST1202DocumentVersion(2));
147+
SDCC sdcc = new SDCC();
148+
sdcc.setValues(
149+
new double[][] {
150+
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
151+
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
152+
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
153+
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
154+
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
155+
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
156+
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
157+
{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
158+
});
159+
st1202values.put(GeneralizedTransformationParametersKey.SDCC, new SDCC_FLP(sdcc));
160+
st1202values.put(
161+
GeneralizedTransformationParametersKey.TransformationEnumeration,
162+
TransformationEnumeration.CHILD_PARENT);
163+
values.put(
164+
RangeImageMetadataKey.GeneralizedTransformationLocalSet,
165+
new GeneralizedTransformation(
166+
new GeneralizedTransformationLocalSet(st1202values)));
167+
RangeImageLocalSet localSet = new RangeImageLocalSet(values);
168+
output.addMetadataFrame(new MetadataFrame(localSet, pts));
169+
pts += frameDuration * 1.0e6;
170+
long elapsedTime = System.currentTimeMillis() - startTime;
171+
long requiredElapsedTime = (long) ((i + 1) * frameDuration * 1000.0);
172+
long waitTime = requiredElapsedTime - elapsedTime;
173+
if (waitTime > 0) {
174+
TimingUtils.shortWait(waitTime);
175+
}
176+
}
177+
178+
} catch (IOException e) {
179+
LOG.error("Failed to write file", e);
180+
}
181+
}
182+
183+
private void showConfiguration() {
184+
System.out.println("Generating with configuration:");
185+
System.out.println(toString());
186+
}
187+
188+
@Override
189+
public String toString() {
190+
return "Generator{"
191+
+ "width="
192+
+ width
193+
+ ", height="
194+
+ height
195+
+ ", bitRate="
196+
+ bitRate
197+
+ ", gopSize="
198+
+ gopSize
199+
+ ", frameRate="
200+
+ frameRate
201+
+ ", frameDuration="
202+
+ frameDuration
203+
+ ", duration="
204+
+ duration
205+
+ ",\nklvFormat="
206+
+ klvFormat
207+
+ ",\nfilename="
208+
+ filename
209+
+ '}';
210+
}
211+
}

0 commit comments

Comments
 (0)