./sbeval/ 0040755 0041014 0010236 00000000000 07754516653 012074 5 ustar over nlpiruid ./sbeval/ComparisonManager.java 0100755 0041014 0010236 00000027526 07754734774 016366 0 ustar over nlpiruid import java.util.*;
import java.io.*;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.parsers.*;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import org.xml.sax.*;
/**
* This class is the main in processing the comparison of a system's shot boundaries segmentations and some references.
* It permit to launch the parsing of Xml files without worrying about parsing errors
* and also to process the comparison of system's parsed segmentations with reference segmentations.
*
* @author
* This software was produced by NIST, an agency of the
* U.S. government, and by statute is not subject to copyright in the
* United States. Recipients of this software assume all
* responsibilities associated with its operation, modification and
* maintenance.
*
*/
public class ComparisonManager{
/**
* The Hashtable containing the file names of the reference.
* The key is the video name and value is the file name.
*
*/
private Hashtable referenceFilenames;
/**
* The Hashtable containing the reference segmentations.
* The key is the video name and value is the segmentation.
*
*/
private Hashtable referenceSegmentations = new Hashtable();
/**
* The Hashtable containing the system results.
* The key is the system ID and value is a systemResult instance.
*
*/
private Hashtable systemResults;
public ComparisonManager(){}
/**
* Launch the parsing of the file containing the mapping between a video file name
* and an Xml segmentation reference file.
*
* @param File referenceFileNamesFile name of the file containing this informations
*/
public void parseReferenceFileNames(File referenceFileNamesFile){
//Test the existence of the file
if (!referenceFileNamesFile.exists()){
System.err.println("The Reference Mapping Information (file:video) File \""+referenceFileNamesFile.getAbsolutePath()+"\""+
System.getProperty("line.separator")+" does not EXISTS");
System.exit(1);
}
System.out.println(System.getProperty("line.separator")+"Parsing Reference Mapping Information...");
// Use the validating parser
SAXParserFactory factory = SAXParserFactory.newInstance();
//factory.setValidating(true);
try {
Writer out = new OutputStreamWriter(System.out, "UTF8");
// Set up output stream
out = new OutputStreamWriter(System.out, "UTF8");
shotResultContentHandler resultHandler = new shotResultContentHandler(out);
// Parse the input
SAXParser saxParser = factory.newSAXParser();
if(referenceFileNamesFile == null || resultHandler == null){
System.out.println("NULL");
System.exit(0);
}
saxParser.parse(referenceFileNamesFile, resultHandler);
this.referenceFilenames = resultHandler.getReferenceFileNames();
//System.out.println(this.referenceFilenames);
} catch (SAXParseException spe) {
// Error generated by the parser
System.out.println("\n** Parsing error"
+ ", line " + spe.getLineNumber()
+ ", uri " + spe.getSystemId());
System.out.println(" " + spe.getMessage() );
// Use the contained exception, if any
Exception x = spe;
if (spe.getException() != null)
x = spe.getException();
x.printStackTrace();
System.exit(1);
} catch (SAXException sxe) {
// Error generated by this application
// (or a parser-initialization error)
Exception x = sxe;
if (sxe.getException() != null)
x = sxe.getException();
x.printStackTrace();
System.exit(1);
} catch (ParserConfigurationException pce) {
// Parser with specified options can't be built
pce.printStackTrace();
System.exit(1);
} catch (IOException ioe) {
// I/O error
ioe.printStackTrace();
System.exit(1);
}
}
/**
* Launch the parsing of the file containing the Xml reference segmentations.
*
*/
public void parseReference(String referencePath){
// Use the validating parser
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(true);
try {
Writer out = new OutputStreamWriter(System.out, "UTF8");
// Set up output stream
out = new OutputStreamWriter(System.out, "UTF8");
shotResultContentHandler resultHandler = new shotResultContentHandler(out);
// Parse the input
SAXParser saxParser = factory.newSAXParser();
if(resultHandler == null){
System.out.println("NULL");
System.exit(0);
}
//For each systemResult in systemResults Hashtable retrieve all videoNames
//and then find out the reference.xml matching file to parse
Hashtable xmlRefFiles = new Hashtable();//key=.xml, value==video.mpg
Enumeration e = systemResults.elements();
while(e.hasMoreElements()){
systemResult s = (systemResult) e.nextElement();
Enumeration n = s.getSegmentationsVideoNames().elements();
while(n.hasMoreElements()){
String someVideo = (String) n.nextElement();
if (referenceFilenames.containsKey(someVideo))
xmlRefFiles.put(referenceFilenames.get(someVideo), someVideo);
}
}
//Now we have to parse and then get
//by getRefSegmentation() from ContentHandler all reference Segmentations
e = xmlRefFiles.keys();
System.out.println(System.getProperty("line.separator")+"Parsing Reference Segmentation...");
while(e.hasMoreElements()){
String xmlFile = (String) e.nextElement();
File toParse = new File(referencePath+System.getProperty("file.separator")+xmlFile);
//Test the existence of the file
if (!toParse.exists()){
System.err.println("The specified file \""+toParse.getAbsolutePath()+"\""+
System.getProperty("line.separator")+" does not EXISTS");
System.exit(1);
}
saxParser.parse(toParse, resultHandler);
this.referenceSegmentations.put((String) xmlRefFiles.get(xmlFile), resultHandler.getRefSegmentation());
}
//System.out.println(this.referenceSegmentations);
} catch (SAXParseException spe) {
// Error generated by the parser
System.out.println("\n** Parsing error"
+ ", line " + spe.getLineNumber()
+ ", uri " + spe.getSystemId());
System.out.println(" " + spe.getMessage() );
// Use the contained exception, if any
Exception x = spe;
if (spe.getException() != null)
x = spe.getException();
x.printStackTrace();
System.exit(1);
} catch (SAXException sxe) {
// Error generated by this application
// (or a parser-initialization error)
Exception x = sxe;
if (sxe.getException() != null)
x = sxe.getException();
x.printStackTrace();
System.exit(1);
} catch (ParserConfigurationException pce) {
// Parser with specified options can't be built
pce.printStackTrace();
} catch (IOException ioe) {
// I/O error
ioe.printStackTrace();
System.exit(1);
}
}
/**
* Launch the parsing of the file containing the results per system results.
*
* @param systemResultsFile name of the file containing this information.
*/
public void parseResults(File systemResultsFile){
//Test the existence of the file
if (!systemResultsFile.exists()){
System.err.println("The specified file \""+systemResultsFile.getAbsolutePath()+"\""+
System.getProperty("line.separator")+" does not EXISTS");
System.exit(1);
}
System.out.println(System.getProperty("line.separator")+"Parsing Submission...");
// Use the validating parser
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(true);
try {
Writer out = new OutputStreamWriter(System.out, "UTF8");
// Set up output stream
out = new OutputStreamWriter(System.out, "UTF8");
shotResultContentHandler resultHandler = new shotResultContentHandler(out);
// Parse the input
SAXParser saxParser = factory.newSAXParser();
if(systemResultsFile == null || resultHandler == null){
System.out.println("NULL");
System.exit(0);
}
saxParser.parse(systemResultsFile, resultHandler);
this.systemResults = resultHandler.getSystemResults();
//System.out.println(this.systemResults);
} catch (SAXParseException spe) {
// Error generated by the parser
System.out.println("\n** Parsing error"
+ ", line " + spe.getLineNumber()
+ ", uri " + spe.getSystemId());
System.out.println(" " + spe.getMessage() );
// Use the contained exception, if any
Exception x = spe;
if (spe.getException() != null)
x = spe.getException();
x.printStackTrace();
System.exit(1);
} catch (SAXException sxe) {
// Error generated by this application
// (or a parser-initialization error)
Exception x = sxe;
if (sxe.getException() != null)
x = sxe.getException();
x.printStackTrace();
System.exit(1);
} catch (ParserConfigurationException pce) {
// Parser with specified options can't be built
pce.printStackTrace();
} catch (IOException ioe) {
// I/O error
ioe.printStackTrace();
System.exit(1);
}
}
/**
* Process the comparison between the reference segmentations and each system segmentation.
*
*/
public void processComparison() throws Exception{
System.out.println(System.getProperty("line.separator")+"Processing comparison...");
Enumeration e = systemResults.elements();
while(e.hasMoreElements()){
systemResult aSystemResult = (systemResult) e.nextElement();
aSystemResult.processComparison(referenceSegmentations);
aSystemResult.save();
}
System.out.println();
}
/**
* Main entry point to the program.
*
*/
public static void main(String argv[]){
if ((argv.length < 1) || (argv.length > 5)) {
System.err.println("Usage: java ComparisonManager [systemSeg_file.xml] [-shortGradual] [-referenceDir]");
System.err.println("Example: java ComparisonManager ./mySys.xml -shortGradual5 -referenceDir/home/myAccount/sb/ref/");
System.exit(1);
}
else{
String referencePath = ".";
for(int i=1; i < argv.length; i++){
if(argv[i].startsWith("-shortGradual"))
Transition.setShortGradualThreshold(Integer.parseInt(argv[i].substring(1+argv[i].lastIndexOf("l"))));
if(argv[i].startsWith("-referenceDir"))
referencePath = argv[i].substring(13);
}
ComparisonManager c = new ComparisonManager();
c.parseResults(new File(argv[0]));
c.parseReferenceFileNames(new File(referencePath+System.getProperty("file.separator")+"shotBoundaryReferenceFiles.xml"));
c.parseReference(referencePath);
try{
c.processComparison();
}
catch(Exception e){ e.printStackTrace(); }
}
}
}
./sbeval/IntervalComparator.java 0100755 0041014 0010236 00000004115 07754734774 016562 0 ustar over nlpiruid import java.util.*;
/**
* A class that implements the java.util.Comparator interface to compare two transitions regarding their limits.
* It compares the transitions regarding their pre-frame and then if needed their post-frame.
*
* @author
* This software was produced by NIST, an agency of the
* U.S. government, and by statute is not subject to copyright in the
* United States. Recipients of this software assume all
* responsibilities associated with its operation, modification and
* maintenance.
*
*/
public class IntervalComparator implements Comparator{
/**
* The unique instance of this class.
*
* @see #getInstance()
*/
private static IntervalComparator myInstance = null;
/**
* Private constructor.
*
*/
private IntervalComparator(){}
/**
* Returns the unique instance of this class.
*
*/
public static IntervalComparator getInstance(){
if(myInstance == null)
myInstance = new IntervalComparator();
return myInstance;
}
/**
* Compares its two arguments for ordering them. Uses the pre-frame and if needed the post-frame to check the equality.
*
* @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
* @exception ClassCastException Thrown if one of the arguments is not a transition instance.
*/
public int compare(Object o1, Object o2) throws ClassCastException{
if((o1 instanceof Transition) && (o2 instanceof Transition)){
Transition t1 = (Transition)o1;
Transition t2 = (Transition)o2;
if(t1.intersection(t2) != null){
return 0;
}
else if(t1.pre < t2.pre)
return -1;
else
return 1;
/*if(t1.pre < t2.pre)
return -1;
else if(t1.pre == t2.pre){
if(t1.post == t2.post)
return 0;
else if(t1.post < t2.post)
return -1;
else
return 1;
}
else return 1;*/
}
else throw new ClassCastException("Instance Problem for IntervalComparator");
}
}
./sbeval/Segmentation.java 0100755 0041014 0010236 00000032352 07754734774 015407 0 ustar over nlpiruid import java.util.*;
/**
* This class represents a segmentation related to a video file
* used in shot boundary detection task programs of TREC 2001.
*
* @author
* This software was produced by NIST, an agency of the
* U.S. government, and by statute is not subject to copyright in the
* United States. Recipients of this software assume all
* responsibilities associated with its operation, modification and
* maintenance.
*
*/
public class Segmentation{
/**
* The video name the segmentation is related to.
*
* @see #getVideoName()
*/
private String videoName;
/**
* This object is containing all the transitions of the segmentation.
*
* @see #getElements()
*/
private TreeSet transitionSet;
private Vector dropped;
/**
* The number of frames of the video.
*
* @see #getElements()
*/
private int totalFrameNumber = 0;
/**
* Constructs Segmentation object with an ordering comparator for its set of transitions
*
* @param videoName The video name the segmentation is related to.
* @param orderingComparator The comparator used to order transitions in the set of transitions
*/
public Segmentation(String videoName, Comparator orderingComparator){
this(videoName, orderingComparator, 0);
//this.videoName = videoName;
//this.transitionSet = new TreeSet(orderingComparator);
//this.dropped = new Vector();
}
/**
* Constructs Segmentation object with an ordering comparator for
* its set of transitions.
*
* @param videoName The video name the segmentation is related to.
* @param orderingComparator The comparator used to order transitions in the set of trnasitions.
* @param totalFrameNumber The number of frames of the video.
*/
public Segmentation(String videoName, Comparator orderingComparator, int totalFrameNumber){
this.totalFrameNumber = totalFrameNumber;
this.videoName = videoName;
this.transitionSet = new TreeSet(orderingComparator);
this.dropped = new Vector();
}
/**
* Process the comparison between the current assumed reference
* segmentation and the given system segmentation.
*
* @param sysId The system Id of the given system segmentation.
* @param systemSegmentation The system segmentation to be compared with.
* @param shortGradualThreshold The threshold below which short gradual
* transition can match an abrupt tansition.
* @return an object representing all the results (measures...) of the comparison.
* @exception TransitionDefinitionException if the definition of a
* transition is not correct (pre-frame >= post-frame).
*/
public comparisonResult processComparison(String sysId,
Segmentation systemSegmentation
) throws TransitionDefinitionException{
//**********************************unchanged
comparisonResult result = new comparisonResult(sysId, this.videoName,
this.totalFrameNumber);
int insertedTransCount = 0;
int deletedTransCount = 0;
int insertedTransCountCut = 0;
int deletedTransCountCut = 0;
int insertedTransCountGradual = 0;
int deletedTransCountGradual = 0;
int frameNumCount = 0;
int frameRecallDenCount = 0;
int framePrecisionDenCount = 0;
String nl = System.getProperty("line.separator");
String insertionsSection = nl+""+nl+nl;
String cutMatchSection = nl;
String gradualMatchSection = nl;
String deletionsSection = nl+""+nl+nl;
//*********************************** unchanged
// For each transition within the Reference Segmentation (this)
// detection of insertion or match.
// 1-Ensure that the transition are in time sequence
// ensured only if the comparator for the TreeSet is the appropriate one
// 2-Verify that cut are considered as 2 frames transition before overlapping test !!!!!!!!!!
// verified cause as is: cut overlappings are enabled cause of ref-cut expansion
Iterator referenceIterator = this.transitionSet.iterator();
while(referenceIterator.hasNext()){
Transition aReferenceTransition = (Transition) referenceIterator.next();
// Expanding the reference transition
if(aReferenceTransition.getType().equals("CUT")){
if(aReferenceTransition.getPre() < 5)
aReferenceTransition.reset(0, aReferenceTransition.getPost() + 5);
else
aReferenceTransition.reset(aReferenceTransition.getPre() - 5, aReferenceTransition.getPost() + 5);
}
Iterator systemIterator = systemSegmentation.getElements();
Transition bestMatch = null;
double bestMatchFrameRecall = 0.0;
double bestMatchFramePrecision = 0.0;
int bestOverlap = 0;
while(systemIterator.hasNext()){
Transition aSystemTransition = (Transition) systemIterator.next();
// Expanding the systemTransition if it is a CUT
// dont forget to reset it to normal values after the loop
if(aSystemTransition.getType().equals("CUT")){
if(aSystemTransition.getPre() == 0){
aSystemTransition.reset(0, aSystemTransition.getPost() + 1);
}
else
aSystemTransition.reset(aSystemTransition.getPre() - 1, aSystemTransition.getPost() + 1);
}
Transition intersection = null;
if(aSystemTransition.matched == false &&
(intersection = aSystemTransition.intersection(aReferenceTransition)) != null &&
aSystemTransition.sameType(aReferenceTransition)){
int intersectionLength = intersection.length();
if(intersectionLength > bestOverlap){
//Re-init previous bestMatch matched value
if(bestMatch != null)
bestMatch.matched = false;
bestMatch = aSystemTransition;
aSystemTransition.matched = true;
aReferenceTransition.matched = true;
bestOverlap = intersectionLength;
bestMatchFrameRecall = (double) bestOverlap / (double) aReferenceTransition.length();
bestMatchFramePrecision = (double) bestOverlap / (double) bestMatch.length();
}
else if(intersectionLength > 0 && intersectionLength == bestOverlap){
double candidateFramePrecision = (double) intersectionLength / (double) aSystemTransition.length();
if(candidateFramePrecision > bestMatchFramePrecision){
//Re-init previous bestMatch matched value
if(bestMatch != null)
bestMatch.matched = false;
bestMatch = aSystemTransition;
aSystemTransition.matched = true;
aReferenceTransition.matched = true;
bestOverlap = intersection.length();
}
//if still equal : you arrived after so nothing
}
}
// Reseting the system transition size
// if it is a CUT (previously expanded)
if(aSystemTransition.isCut()){
if(aSystemTransition.getPre() == 0){
aSystemTransition.reset(aSystemTransition.getPost() - 2, aSystemTransition.getPost() - 1);
}
else aSystemTransition.reset(aSystemTransition.getPre() + 1, aSystemTransition.getPost() - 1);
}
}//End LOOP over system transitions
// Reseting the reference transition size
// if it is a CUT (previously expanded)
if(aReferenceTransition.isCut()){
if(aReferenceTransition.getPre() == 0)
aReferenceTransition.reset(aReferenceTransition.getPost() - 6, aReferenceTransition.getPost() - 5);
else
aReferenceTransition.reset(aReferenceTransition.getPre() + 5, aReferenceTransition.getPost() - 5);
}
// Persistance for aReferenceTransition
// either deletion or match
if(!aReferenceTransition.matched){
deletionsSection += aReferenceTransition.refToString();
deletedTransCount++;
if(aReferenceTransition.isCut())
deletedTransCountCut++;
else
deletedTransCountGradual++;
}
else{
if((aReferenceTransition.isCut() && bestMatch.isCut()) ||
(aReferenceTransition.isCut() && bestMatch.isShortGradual()) ||
(aReferenceTransition.isGradual() && bestMatch.isCut())){
cutMatchSection += nl + "" + nl + aReferenceTransition.refToString() +
bestMatch.sysToString() +"";
}
else{
frameNumCount += bestMatch.intersection(aReferenceTransition).length();
frameRecallDenCount += aReferenceTransition.length();
framePrecisionDenCount += bestMatch.length();
gradualMatchSection += nl + "" + nl +
aReferenceTransition.refToString() +
bestMatch.sysToString() +
"";
}
}
// RE INIT matching info
aReferenceTransition.matched = false;
}
// Enumeration of system transitions to fill in the insertion section
Iterator systemIterator = systemSegmentation.getElements();
while(systemIterator.hasNext()){
Transition aSystemTransition = (Transition) systemIterator.next();
if(!aSystemTransition.matched){
insertionsSection += aSystemTransition.sysToString();
insertedTransCount++;
if(aSystemTransition.isCut()) insertedTransCountCut++;
else insertedTransCountGradual++;
}
}
insertionsSection += nl+""+nl;
deletionsSection += nl+""+nl;
result.setResults(systemSegmentation.droppedToString(),
this.getTransitionCount(),
insertedTransCount,
deletedTransCount,
cutMatchSection,
this.getCutFrameCount(),
insertedTransCountCut,
deletedTransCountCut,
gradualMatchSection,
insertedTransCountGradual,
deletedTransCountGradual,
frameNumCount,
frameRecallDenCount,
framePrecisionDenCount,
insertionsSection,
deletionsSection);
return result;
}
/**
* Returns the number of Cut transitions within the segmentation.
*
* @return the number of Cut transitions within the segmentation.
*/
public int getCutFrameCount(){
int toReturn = 0;
Iterator i = this.transitionSet.iterator();
while(i.hasNext()){
Transition t = (Transition) i.next();
if(t.isCut()) toReturn++;
}
return toReturn;
}
/**
* Returns an iterator on the transitions within the segmentation.
*
* @return an iterator on the transitions within the segmentation.
*/
public Iterator getElements(){
return this.transitionSet.iterator();
}
/**
* Add a given transition to the segmentation.
*
* @param aTransition the transition to be added to the segmentation.
*/
public void add(Transition aTransition){
boolean foundInDropped = false;
Enumeration enumDropped = this.dropped.elements();
while(enumDropped.hasMoreElements() && !foundInDropped){
Transition t = (Transition) enumDropped.nextElement();
if(t.intersection(aTransition) != null)
foundInDropped = true;
}
if(!transitionSet.contains(aTransition) && !foundInDropped){
transitionSet.add(aTransition);
}
else{
this.dropped.add(aTransition);
//On the way to find the removed transition that intersects
//Only justification to keep TreeSet structure is for the ordering in iteration
//in processing comparison so in order to get ordered output files
//Again: iteration over the treeSet ! after the ones in contains() and add() !!
Transition movedToDropped = null;
Iterator setIterator = this.transitionSet.iterator();boolean found = false;
while(setIterator.hasNext() && !found){
Transition t = (Transition) setIterator.next();
if(t.intersection(aTransition) != null){
movedToDropped = t;
found = true;
}
}
if(movedToDropped != null){ this.dropped.add(movedToDropped);}
this.transitionSet.remove(aTransition);
}
}
/**
* Returns the video name the segmentation is related to.
*
* @return the video name the segmentation is related to.
*/
public String getVideoName(){
return videoName;
}
/**
* Returns the number of transitions within the segmentation.
*
* @return the number of transitions within the segmentation.
*/
public int getTransitionCount(){
return transitionSet.size();
}
public int getDroppedCount(){
return this.dropped.size();
}
public String droppedToString(){
String nl = System.getProperty("line.separator");
StringBuffer toReturn = new StringBuffer();
Enumeration enumDropped = this.dropped.elements();
while(enumDropped.hasMoreElements()){
Transition s = (Transition) enumDropped.nextElement();
toReturn.append(s.toString("droppedTrans"));
}
return toReturn.toString();
}
/**
* Returns an Xml string representing the segmentation in a pre-defined format.
*
* @return an Xml string representing the segmentation.
*/
public String toString(){
String toReturn = ""+System.getProperty("line.separator");
Iterator e = transitionSet.iterator();
while(e.hasNext()){
Transition s = (Transition) e.next();
toReturn += s.toString();
}
toReturn += ""+System.getProperty("line.separator");
return toReturn;
}
}//END CLASS
./sbeval/Transition.java 0100755 0041014 0010236 00000016476 07754734774 015115 0 ustar over nlpiruid import java.lang.Math;
/**
* This class represents a shot transition.
* A shot boundary or transition is defined by its pre frame and its post frame.
* These frames are respectively the last and first frame before and after the
* beginning of the transition. The transition could be a short one
* (CUT) with its post right after the pre frame or
* a gradual one with at least one frame within the transition effect.
*
* @author
* This software was produced by NIST, an agency of the
* U.S. government, and by statute is not subject to copyright in the
* United States. Recipients of this software assume all
* responsibilities associated with its operation, modification and
* maintenance.
*
*/
public class Transition implements Cloneable{
private final static String[] types = {"CUT", "GRAD"};
private static int shortGradualThreshold = 5;
/**
* The pre frame: the last frame of a previous shot without any content of the transition effect.
*
* @see #getPre()
*/
public int pre;
/**
* The post frame: the first frame of the following shot without any content of the transition effect.
*
* @see #getPost()
*/
public int post;
/**
* The type of transition: could take the value "cut" and anything else stands for a gradual transition.
*
*/
public String type;
/**
* Indicates wether the transition has matched with another one during a comparison.
*
*/
public boolean matched = false;
public Object clone(){
int apre = pre;
int apost = post;
//String type = type
try{
Transition aClone = new Transition(apre, apost, type);
return aClone;
}catch(TransitionDefinitionException e){
System.out.println("CLONING PROBLEM");
return null;
}
}
/**
* Constructs Transition object with the given parameters.
*
* @param pre The pre frame of the transition.
* @param post The post frame of the transition.
* @param type The type of trnasition.
* @exception TransitionDefinitionException Thrown if the pre frame is not strictly less than the post frame.
*/
public Transition(int pre, int post, String type)throws TransitionDefinitionException{
if((pre >-1) && (post >-1) && (pre < post)){
this.pre = pre;
this.post = post;
if(type.compareToIgnoreCase("CUT") == 0)
if(pre != post-1)
throw new TransitionDefinitionException("Transition definition error: CUT definition not respected");
else
this.type = "CUT";
else
this.type = type;
}
else throw new TransitionDefinitionException("Transition definition error: pre and post not well ordered");
}
/**
* Set the threshold for short gradual and cut confusion
*
*/
public static void setShortGradualThreshold(int value){
Transition.shortGradualThreshold = value;
}
/**
* Get the threshold for short gradual and cut confusion
*
*/
public static int getShortGradualThreshold(){
return shortGradualThreshold;
}
/**
* Return true if the transition is a short gradual ie length less than
* the threshold.
*
*/
public boolean isShortGradual(){
return(this.type.compareToIgnoreCase("CUT") != 0 &&
this.length() <= Transition.shortGradualThreshold);
}
/**
* Returns true if the transition is a CUT
*
*/
public boolean isCut(){
return (this.type.compareToIgnoreCase("CUT") == 0);
}
/**
* Returns true if the transition is a CUT
*
*/
public boolean isGradual(){
return (this.type.compareToIgnoreCase("CUT") != 0);
}
/**
* Gets the pre frame.
*
*/
public int getPre(){
return this.pre;
}
/**
* Gets the post frame.
*
*/
public int getPost(){
return this.post;
}
/**
* Gets the type.
*
*/
public String getType(){
return this.type;
}
/**
* Returns true if the given transition has the same type as the current instance
* regarding the setted confusions between types.
*
*/
public boolean sameType(Transition t){
return ((this.type.compareToIgnoreCase("CUT") == 0 && t.getType().compareToIgnoreCase("CUT") == 0) ||
(this.type.compareToIgnoreCase("CUT") != 0 && t.getType().compareToIgnoreCase("CUT") != 0) ||
(this.type.compareToIgnoreCase("CUT") == 0 && t.isShortGradual()) ||
(t.type.compareToIgnoreCase("CUT") == 0 && this.isShortGradual()));
}
/**
* Sets the pre frame value.
*
*/
public void setPre(int newPre) throws TransitionDefinitionException{
if((newPre >-1) && (newPre < post)){
this.pre = newPre;
}
else throw new TransitionDefinitionException("Transition definition error: pre and post not well ordered");
}
/**
* Sets the post frame value.
*
*/
public void setPost(int newPost) throws TransitionDefinitionException{
if(newPost > pre){
this.post = newPost;
}
else throw new TransitionDefinitionException("Transition definition error: pre and post not well ordered");
}
/**
* Sets the post frame value.
*
*/
public void reset(int newPre, int newPost) throws TransitionDefinitionException{
if((newPre >-1) && (newPre < newPost)){
this.pre = newPre;
this.post = newPost;
}
else throw new TransitionDefinitionException("Transition definition error: pre and post not well ordered "+
newPre+" "+newPost);
}
/**
* Returns the length of the transition (post - pre - 1).
*
*/
public int length(){
return (this.post - this.pre -1);
}
/**
* Returns a transition representing the intersection with the given transition.
*
*/
public Transition intersection(Transition t){
try{
return (new Transition(Math.max(this.pre, t.pre),
Math.min(this.post, t.post), "INT"));
}
catch(Exception e){
return null;
}
}
/**
* Returns true if there is an intersection with the given transition.
*
*/
public boolean intersected(Transition t){
return (Math.max(this.pre, t.pre) < Math.min(this.post, t.post));
}
/**
* Returns an Xml style string of transition.
*
*/
public String toString(){
return ""+System.getProperty("line.separator");
}
/**
* Returns an Xml style string of transition.
*
*/
public String toString(String tag){
return "<"+tag+" type=\""+this.type+"\" pre=\""+this.pre+"\" post=\""+this.post+"\"/>"+System.getProperty("line.separator");
}
/**
* Returns an Xml style string of transition with the Xml element name equal to "sysTrans".
*
*/
public String sysToString(){
return ""+System.getProperty("line.separator");
}
/**
* Returns an Xml style string of transition with the Xml element name euqal to "refTrans".
*
*/
public String refToString(){
return ""+System.getProperty("line.separator");
}
}
./sbeval/TransitionDefinitionException.java 0100755 0041014 0010236 00000000767 07754734774 021001 0 ustar over nlpiruid /**
* Thrown when attempts to define a transition with uncorrect values.
*
* @author
* This software was produced by NIST, an agency of the
* U.S. government, and by statute is not subject to copyright in the
* United States. Recipients of this software assume all
* responsibilities associated with its operation, modification and
* maintenance.
*
*/
public class TransitionDefinitionException extends Exception{
TransitionDefinitionException(String why){
super(why);
}
} ./sbeval/comparisonResult.java 0100755 0041014 0010236 00000030227 07754734774 016322 0 ustar over nlpiruid import java.io.*;
/**
* This class represents the result of a comparison between a system result for one video and the reference.
* used in shot boundary detection task programs of TREC 2001.
*
* @author
* This software was produced by NIST, an agency of the
* U.S. government, and by statute is not subject to copyright in the
* United States. Recipients of this software assume all
* responsibilities associated with its operation, modification and
* maintenance.
*
*/
public class comparisonResult {
/**
* The output Xml file.
*
*/
private File outputXmlFile = null;
/**
* The file writer.
*
*/
private FileWriter out = null;
/**
* The system ID for the one the comparison result is created.
*
*/
public String sysId = null;
/**
* The video name for the one the comparison result is created.
*
*/
public String videoName = null;
/**
* The total frame count in the related video.
*
*/
public double totalFrameCount = 0;
/**
* The number of frames of all the gradual-gradual intersections
*
*/
public int gradualFrameCount = 0;
/**
* The number of frames of the matching reference gradual transitions
*
*/
public int gradualRecallFrameCount = 0;
/**
* The number of frames of the matching system transitions
*
*/
public int gradualPrecisionFrameCount = 0;
/**
* The number of matching reference transition
*
*/
public int referenceMatchingCount = 0;
/**
* The number of matching cut reference transition
* po
*/
public int referenceCutMatchingCount = 0;
/**
* The number of matching gradual reference transition
* po
*/
public int referenceGradMatchingCount = 0;
/**
* The number of matching system transitions
*
*/
public int systemMatchingCount = 0;
/**
* The number of matching cut system transitions
* po
*/
public int systemCutMatchingCount = 0;
/**
* The number of matching gradual system transitions
* po
*/
public int systemGradMatchingCount = 0;
/**
* Constructs comparisonResult object with the given parameters.
* It creates a directory and a file for the storage of the results.
*
* @param sysId The system ID for the one the comparison's been done.
* @param videoName The video name.
* @param totalFrameCount The total frame count in the given video.
*/
public comparisonResult(String sysId, String videoName, int totalFrameCount){
File sysIdDir = new File(System.getProperty("user.dir")+System.getProperty("file.separator")+
"ComparisonResult"+System.getProperty("file.separator")+
sysId+System.getProperty("file.separator"));
sysIdDir.mkdir();
this.outputXmlFile = new File(sysIdDir, sysId+"_"+videoName.substring(0, videoName.indexOf("."))+".xml");
try{
this.out = new FileWriter(outputXmlFile);
}
catch(IOException i){
System.out.println("A problem occured while preparing to write results");
}
this.totalFrameCount = (double) totalFrameCount;
this.sysId = sysId;
this.videoName = videoName;
}
/**
* Given the parameter, this method writes in the file the results.
*
* @param refTransCount The transitions count in the reference for the related video.
* @param insertedTransCount The inserted transitions count for the comparison.
* @param deletedTransCount The deleted transitions count for the comparison.
* @param cutMatchSection A ready to write XML formatted section for the CUT matching transition results.
* @param cutTransCount The CUT transitions count in the reference for the related video.
* @param insertedTransCountCut The inserted CUT transitions count for the comparison.
* @param deletedTransCountCut The deleted CUT transitions count for the comparison.
* @param gradualMatchSection A ready to write XML formatted section for the GRADUAL matching transition results.
* @param insertedTransCountGradual The inserted GRADUAL transitions count for the comparison.
* @param deletedTransCountGradual The deleted GRADUAL transitions count for the comparison.
* @param insertionsSection A ready to write XML formatted section for the insertion results.
* @param deletionsSection A ready to write XML formatted section for the deletion results.
*/
public void setResults(String droppedSection,
int refTransCount,
int insertedTransCount,
int deletedTransCount,
String cutMatchSection,
int cutTransCount,
int insertedTransCountCut,
int deletedTransCountCut,
String gradualMatchSection,
int insertedTransCountGradual,
int deletedTransCountGradual,
int frameNumCount,
int frameRecallDenCount,
int framePrecisionDenCount,
String insertionsSection,
String deletionsSection){
try{
String nl = System.getProperty("line.separator");
this.referenceMatchingCount = refTransCount-deletedTransCount;
this.referenceCutMatchingCount = cutTransCount-deletedTransCountCut;
this.referenceGradMatchingCount = this.referenceMatchingCount-this.referenceCutMatchingCount;
this.systemMatchingCount = refTransCount - deletedTransCount;
this.systemCutMatchingCount = cutTransCount - deletedTransCountCut;
this.systemGradMatchingCount = this.systemMatchingCount - this.systemCutMatchingCount;
//this.systemMatchingCount = refTransCount - deletedTransCount + insertedTransCount;
out.write(""+nl);
out.write(""+nl);
out.write("");
//DROPPED section
out.write(nl+""+nl);
//System.out.println(droppedSection);
out.write(droppedSection);
out.write(""+nl);
//CUT section
out.write(nl+"");
out.write(cutMatchSection);
out.write(nl+""+nl);
//GRADUAL section
out.write(nl+""+nl);
this.gradualFrameCount = frameNumCount;
this.gradualRecallFrameCount = frameRecallDenCount;
this.gradualPrecisionFrameCount = framePrecisionDenCount;
out.write(gradualMatchSection);
out.write(nl+""+nl);
//INSERTION section
out.write(nl);
out.write(insertionsSection);
//DELETION section
out.write(nl);
out.write(deletionsSection);
out.write(nl+"");
out.close();
} catch(IOException i){
i.printStackTrace();
System.out.println("A problem occured while writing results");
}
}
/**
* Private method that computes and writes in file a part of header results for a section.
* For example the attributes of the cut mathcing section's Xml element:
*
* It starts writing attributes begining at "referenceTransCount" Xml attribute.
*
* @param transitionCount The inserted transitions count for the comparison.
* @param insertedTransCount The deleted transitions count for the comparison.
* @param deletedTransCount The deleted transitions count for the comparison.
*/
private void getXmlAttributes(double transitionCount,
double insertedTransCount,
double deletedTransCount){
try{
String nl = System.getProperty("line.separator");
out.write(" referenceTransCount=\""+(int)transitionCount+"\" "+nl);
out.write(" insertedTransCount=\""+(int)insertedTransCount+"\" "+nl);
out.write(" deletedTransCount=\""+(int)deletedTransCount+"\" "+nl);
if(transitionCount != 0.0){
out.write(" correctionRate=\""+
trimPrecision(new Double((transitionCount-deletedTransCount)/transitionCount))
+"\" "+nl);
out.write(" deletionRate=\""+
trimPrecision(new Double(deletedTransCount/transitionCount))+
"\" "+nl);
out.write(" insertionRate=\""+
trimPrecision(new Double(insertedTransCount/transitionCount))+
"\" "+nl);
out.write(" errorRate=\""+
trimPrecision(new Double((deletedTransCount+insertedTransCount)/transitionCount))+
"\" "+nl);
out.write(" qualityIndex=\""+
trimPrecision(new Double((transitionCount-deletedTransCount-(insertedTransCount/3))/transitionCount))+
"\" "+nl);
out.write(" correctionProbability=\""+
trimPrecision(new Double(1-(insertedTransCount/
(totalFrameCount-transitionCount) + deletedTransCount/transitionCount)/2))+
"\" "+nl);
out.write(" recall=\""+
trimPrecision(new Double((transitionCount-deletedTransCount)/transitionCount))+
"\" "+nl);
if((transitionCount-deletedTransCount+insertedTransCount != 0) &&
(transitionCount-deletedTransCount != 0))
out.write(" precision=\""+
trimPrecision(new Double((transitionCount-deletedTransCount)/
(transitionCount-deletedTransCount+insertedTransCount)))+
"\""+nl);
else
out.write(" precision=\"0.0\""+nl);
}
else{
out.write(" correctionRate=\"0.0\" "+nl);
out.write(" deletionRate=\"0.0\" "+nl);
out.write(" insertionRate=\"0.0\" "+nl);
out.write(" errorRate=\"0.0\" "+nl);
out.write(" qualityIndex=\"0.0\" "+nl);
out.write(" correctionProbability=\"0.0\" "+nl);
out.write(" recall=\"0.0\" "+nl);
if(transitionCount-deletedTransCount+insertedTransCount != 0)
out.write(" precision=\""+
trimPrecision(new Double((transitionCount-deletedTransCount)/
(transitionCount-deletedTransCount+insertedTransCount)))+
nl);
else
out.write(" precision=\"0.0\""+nl);
}
} catch(IOException i){
i.printStackTrace();
System.out.println("A problem occured while writing results");
}
}
/**
* Private method that only trim precision of a double until the first 3 decimals and returns it as a String.
*
*/
public static String trimPrecision(Double d){
String toReturn = d.toString();
if(toReturn.length() >= 6)
toReturn = toReturn.substring(0,5);
return toReturn;
}
}
./sbeval/shotResultContentHandler.java 0100755 0041014 0010236 00000022737 07754734774 017765 0 ustar over nlpiruid import java.util.*;
import java.io.*;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
/**
* A class that extends DefaultHandler classes of Java Xml SAX API.
* This class is used to get Xml data from the Xml parser and
* return them in defined formats (Hastable, Segmentation instances...).
*
* @author
* This software was produced by NIST, an agency of the
* U.S. government, and by statute is not subject to copyright in the
* United States. Recipients of this software assume all
* responsibilities associated with its operation, modification and
* maintenance.
*
*/
public class shotResultContentHandler extends DefaultHandler {
static private Writer out;
/**
* The Hashtable used to store the system results,
* the key is the system ID, and value is a systemResult instance.
*
* @see #getSystemResults()
*/
private Hashtable systemResults = new Hashtable();
/**
* Segmentation instance used to get the current Segmentation the parser is working on.
* The transitions of this segmentation will be added as and when the parser calls startsElement() method
* and the Xml element "" and its attributes are recognized.
*
*/
private Segmentation currentSeg = null;
/**
* systemResult instance used to get the current system results the parser is working on.
* The segmentations of this system result will be added when the parser calls startsElement() method
* and the Xml element "" and its attributes are recognized.
*
*/
private systemResult currentSys = null;
/**
* Hashtable that contains the reference file names stored in an Xml file.
* The key is the video name and value is reference file name.
*/
private Hashtable referenceFileNames = new Hashtable();
/**
* Constructs an instance of this class with the given Writer as the output
* writer used to get information during parsing...
*
*/
public shotResultContentHandler(Writer out){ this.out = out; }
/**
* Returns the systemResults parsed and contained in an Hashtable.
*
*/
public Hashtable getSystemResults(){
return systemResults;
}
/**
* Returns the reference file namesparsed and contained in an Hashtable.
*
*/
public Hashtable getReferenceFileNames(){
return referenceFileNames;
}
/**
* Returns the reference segmentation parsed from one Xml file per segmentation in the reference.
* Actually currentSeg is returned cause it contains either the current parsed reference
* segmentation or a segmentation of a system.
*/
public Segmentation getRefSegmentation(){
return currentSeg;
}
/**
* SAX DocumentHandler method.
*
*/
public void setDocumentLocator(Locator l)
{
// Save this to resolve relative URIs or to give diagnostics.
try {
//out.write("LOCATOR");
out.write(" "+l.getSystemId()+System.getProperty("line.separator"));
out.flush();
} catch (IOException e) {
// Ignore errors
}
}
/**
* SAX DocumentHandler method.
*
*/
public void startDocument() throws SAXException{
//nl();
}
/**
* SAX DocumentHandler method.
*
*/
public void endDocument() throws SAXException {
//emit("END DOCUMENT");
try {
//nl();
out.flush();
} catch (IOException e) {
throw new SAXException("I/O error", e);
}
}
/**
* SAX DocumentHandler method used to recognized Xml tags and get the information in the required Hashtable
* or any data structure for later use.
*
*/
public void startElement(String namespaceURI,
String lName, // local name
String qName, // qualified name
Attributes attrs) throws SAXException {
//indentLevel++;
String eName = lName; // element name
if ("".equals(eName)) eName = qName; // namespaceAware = false
//Case
if(eName.equals("refSeg")){
String src = null;
int totalFNumber = 0;
if (attrs != null) {
for (int i = 0; i < attrs.getLength(); i++) {
String aName = attrs.getLocalName(i); // Attr name
if ("".equals(aName)) aName = attrs.getQName(i);
if(aName.equals("src")) src = attrs.getValue(i).toLowerCase();
if(aName.equals("totalFNum")) totalFNumber = Integer.parseInt(attrs.getValue(i));
}
}
currentSeg = new Segmentation(src, IntervalComparator.getInstance(), totalFNumber);
}
else if(eName.equals("referenceFileName")){
String videoName = null;
String segName = null;
if (attrs != null) {
for (int i = 0; i < attrs.getLength(); i++) {
String aName = attrs.getLocalName(i); // Attr name
if ("".equals(aName)) aName = attrs.getQName(i);
if(aName.equals("videoName")) videoName = attrs.getValue(i).toLowerCase();
if(aName.equals("segName")) segName = attrs.getValue(i);
}
}
referenceFileNames.put(videoName, segName);
}
else if(eName.equals("trans")){
String type = "";
int pre = 0;
int post = 0;
try{
if (attrs != null) {
for (int i = 0; i < attrs.getLength(); i++) {
String aName = attrs.getLocalName(i); // Attr name
if ("".equals(aName)) aName = attrs.getQName(i);
if(aName.equals("type")) type = attrs.getValue(i);
if(aName.equals("preFNum")){
pre = Integer.parseInt((String) attrs.getValue(i));
}
if(aName.equals("postFNum")) post = Integer.parseInt(attrs.getValue(i));
}
}
//parsing du type cut
Transition t = new Transition(pre, post ,type);
currentSeg.add(t);
} catch (TransitionDefinitionException e){
throw new SAXException("Error in transition definition: "+pre+" "+post);
} catch (Exception e){
throw new SAXException("Error in transition reading or processing");
}
}
else if(eName.equals("seg")){
String fileName = null;
if (attrs != null) {
for (int i = 0; i < attrs.getLength(); i++) {
String aName = attrs.getLocalName(i); // Attr name
if ("".equals(aName)) aName = attrs.getQName(i);
if(aName.equals("src")) fileName = attrs.getValue(i).toLowerCase();
}
}
currentSeg = new Segmentation(fileName, IntervalComparator.getInstance());
currentSys.addSegmentation(currentSeg);
}
else if(eName.equals("shotBoundaryResult")){
String sysId = null;
if (attrs != null) {
for (int i = 0; i < attrs.getLength(); i++) {
String aName = attrs.getLocalName(i); // Attr name
if ("".equals(aName)) aName = attrs.getQName(i);
if(aName.equals("sysId")) sysId = attrs.getValue(i);
}
}
currentSys = new systemResult(sysId);
systemResults.put(sysId, currentSys);
}
else if(eName.equals("shotBoundaryResults")){
}
}
/**
* SAX DocumentHandler method.
*
*/
public void endElement(String namespaceURI,
String sName, // simple name
String qName // qualified name
) throws SAXException {
}
/**
* SAX DocumentHandler method.
*
*/
public void characters(char buf[], int offset, int len) throws SAXException {
//nl();
emit("CHARS: ");
String s = new String(buf, offset, len);
if (!s.trim().equals("")) emit(s);
}
/**
* SAX DocumentHandler method.
*
*/
public void ignorableWhitespace(char buf[], int offset, int len) throws SAXException {
// Ignore it
}
/**
* SAX DocumentHandler method.
*
*/
public void processingInstruction(String target, String data) throws SAXException {
//nl();
emit("PROCESS: ");
emit(""+target+" "+data+"?>");
}
/**
* SAX ErrorHandler method. Treats validation errors as fatal.
*
*/
public void error(SAXParseException e) throws SAXParseException {
throw e;
}
/**
* SAX ErrorHandler method. Dumps warnings.
*
*/
public void warning(SAXParseException err) throws SAXParseException {
System.out.println("** Warning"
+ ", line " + err.getLineNumber()
+ ", uri " + err.getSystemId());
System.out.println(" " + err.getMessage());
}
//===========================================================
// Utility Methods ...
//===========================================================
/**
* Wrap I/O exceptions in SAX exceptions, to suit handler signature
* requirements.
*
*/
private void emit(String s) throws SAXException {
try {
out.write(s);
out.flush();
} catch (IOException e) {
throw new SAXException("I/O error", e);
}
}
/**
* Start a new line and indent the next line appropriately.
*
*/
private void nl() throws SAXException {
String lineEnd = System.getProperty("line.separator");
try {
out.write(lineEnd);
//for (int i=0; i < indentLevel; i++) out.write(indentString);
} catch (IOException e) {
throw new SAXException("I/O error", e);
}
}
}
./sbeval/systemResult.java 0100755 0041014 0010236 00000021123 07754734774 015467 0 ustar over nlpiruid import java.util.*;
import java.io.*;
/**
* This class represents the results for one system identified by its ID.
* One system has several segmentation results corresponding to the run of this system on a video.
* used in shot boundary detection task programs of TREC 2001.
*
* @author
* This software was produced by NIST, an agency of the
* U.S. government, and by statute is not subject to copyright in the
* United States. Recipients of this software assume all
* responsibilities associated with its operation, modification and
* maintenance.
*
*/
public class systemResult{
/**
* The segmentations for this system are stored in this Hashtable.
* The key is the name of the video the segmentation is done for.
*
*/
private Hashtable segmentations = new Hashtable();
/**
* The system ID of the results.
*
*/
private String sysId;
/**
* The number of frames of all the gradual-gradual intersections
*
*/
public int gradualFrameCount = 0;
/**
* The number of frames of the matching reference gradual transitions
*
*/
public int gradualRecallFrameCount = 0;
/**
* The number of frames of the matching system transitions
*
*/
public int gradualPrecisionFrameCount = 0;
/**
* The number of reference matching transitions across all segmentations
*
*/
public int referenceMatchingCount = 0;
/**
* The number of reference matching cut transitions across all
* segmentations
* po
*/
public int referenceCutMatchingCount = 0;
/**
* The number of reference matching gradual transitions across all
* segmentations
* po
*/
public int referenceGradMatchingCount = 0;
/**
* The number of system matching transitions across all segmentations
*
*/
public int systemMatchingCount = 0;
/**
* The number of system matching cut transitions across all segmentations
* po
*/
public int systemCutMatchingCount = 0;
/**
* The number of system matching gradual transitions across all
* segmentations
* po
*/
public int systemGradMatchingCount = 0;
/**
* The number of system transitions across all segmentations
*
*/
public int systemTransCount = 0;
/**
* The number of system cut transitions across all segmentations
* po
*/
public int systemCutTransCount = 0;
/**
* The number of system gradual transitions across all segmentations
* po
*/
public int systemGradTransCount = 0;
/**
* The number of reference transitions across all segmentations
*
*/
public int referenceTransCount = 0;
/**
* The number of reference cut transitions across all segmentations
* po
*/
public int referenceCutTransCount = 0;
/**
* The number of reference gradual transitions across all segmentations
* po
*/
public int referenceGradTransCount = 0;
/**
* Instanciate a systemResult object with only the given system ID.
*
*/
private int droppedCount = 0;
public systemResult(String sysId){
this.sysId = sysId;
}
/**
* Add the given segmentation to the system results.
*
*/
public void addSegmentation(Segmentation s){
if(s.getVideoName() == null){
System.out.println("PROBLEM");
}
segmentations.put(s.getVideoName(), s);
}
/**
* Returns an enumeration of segmentations.
*
*/
public Enumeration getSegmentations(){
return segmentations.elements();
}
/**
* Returns the system ID.
*
*/
public String getSysId(){
return this.sysId;
}
/**
* Returns a Vector containing video names of the segmentations.
*
*/
public Vector getSegmentationsVideoNames(){
Vector toReturn = new Vector();
Enumeration e = segmentations.elements();
while(e.hasMoreElements()){
Segmentation s = (Segmentation) e.nextElement();
toReturn.add(s.getVideoName());
}
return toReturn;
}
/**
* Process the comparison between the reference segmentations and each system segmentation.
*
*/
public void processComparison(Hashtable referenceSegmentations) throws Exception{
System.out.println(this.sysId);
//For each Segmentation
Enumeration n = this.getSegmentations();
while(n.hasMoreElements()){
Segmentation aSystemSeg = (Segmentation) n.nextElement();
this.droppedCount += aSystemSeg.getDroppedCount();
Segmentation aRefSeg = (Segmentation) referenceSegmentations.get(aSystemSeg.getVideoName());
//We compare the two segmentations
//Creation of a comparisonResult
if(aRefSeg != null){
comparisonResult aResult = aRefSeg.processComparison(this.getSysId(), aSystemSeg);
this.gradualFrameCount += aResult.gradualFrameCount;
this.gradualRecallFrameCount += aResult.gradualRecallFrameCount;
this.gradualPrecisionFrameCount += aResult.gradualPrecisionFrameCount;
this.referenceMatchingCount += aResult.referenceMatchingCount;
this.referenceCutMatchingCount += aResult.referenceCutMatchingCount;
this.referenceGradMatchingCount += aResult.referenceGradMatchingCount;
this.systemMatchingCount += aResult.systemMatchingCount;
this.systemCutMatchingCount += aResult.systemCutMatchingCount;
this.systemGradMatchingCount += aResult.systemGradMatchingCount;
this.systemTransCount += aSystemSeg.getTransitionCount();
this.systemCutTransCount += aSystemSeg.getCutFrameCount();
this.systemGradTransCount += aSystemSeg.getTransitionCount() - aSystemSeg.getCutFrameCount();
this.referenceTransCount += aRefSeg.getTransitionCount();
this.referenceCutTransCount += aRefSeg.getCutFrameCount();
this.referenceGradTransCount += aRefSeg.getTransitionCount() - aRefSeg.getCutFrameCount();
}
else{
System.out.println(" Warning: Unprocessed segmentation - No reference found for: "+
aSystemSeg.getVideoName());
}
}
}
/**
* Returns an Xml String of the system results including all segmentations.
*
*/
public String toString(){
String toReturn = ""+System.getProperty("line.separator");
Enumeration e = segmentations.elements();
while(e.hasMoreElements()){
Segmentation s = (Segmentation) e.nextElement();
toReturn += s.toString();
}
toReturn += ""+System.getProperty("line.separator");
return toReturn;
}
/**
* Write into a file the system level results
*
*/
public void save(){
File sysIdDir = new File(System.getProperty("user.dir")+System.getProperty("file.separator")+
"ComparisonResult"+System.getProperty("file.separator")+
sysId+System.getProperty("file.separator"));
sysIdDir.mkdir();
File outputXmlFile = new File(sysIdDir, sysId+".xml");
try{
FileWriter out = new FileWriter(outputXmlFile);
String nl = System.getProperty("line.separator");
out.write(""+nl);
out.write(""+nl);
out.write("");
out.close();
}
catch(IOException i){
System.out.println("A problem occured while preparing to write results");
}
}
}
./sbeval/ComparisonResult/ 0040755 0041014 0010236 00000000000 07542125515 015371 5 ustar over nlpiruid ./sbeval/README 0100755 0041014 0010236 00000000611 07542126233 012734 0 ustar over nlpiruid Running the TREC 2002 Shot Boundary evaluation software
Compile the java
Locate the directory with the reference files
Locate the file with the run(s) to be evaluated
Invoke the evaluation as follows:
java ComparisonManager PATH-TO-THE-FILE-WITH-RUNS/FILE_WITH_RUN(S) -referenceDir/PATH-TO-THE-DIRECTORY-WITH-THE-REFERENCE-FILES
Results are left in the ComparisonResult directory