コード例 #1
0
 public synchronized Term getBlobs() {
   Term result = PrologEmptyList.instance;
   for (int n = blobRectangles.length - 1; n >= 0; n--) {
     Term prologIdentifier = new PrologInteger(blobIdentifiers[n]);
     int[] rectangle = blobRectangles[n];
     Term prologX = new PrologInteger(StrictMath.round((rectangle[0] + rectangle[1]) / 2));
     Term prologY = new PrologInteger(StrictMath.round((rectangle[2] + rectangle[3]) / 2));
     Term prologWidth = new PrologInteger(rectangle[1] - rectangle[0]);
     Term prologHeight = new PrologInteger(rectangle[3] - rectangle[2]);
     Term prologBlob =
         new PrologSet(
             -SymbolCodes.symbolCode_E_identifier,
             prologIdentifier,
             new PrologSet(
                 -SymbolCodes.symbolCode_E_x,
                 prologX,
                 new PrologSet(
                     -SymbolCodes.symbolCode_E_y,
                     prologY,
                     new PrologSet(
                         -SymbolCodes.symbolCode_E_width,
                         prologWidth,
                         new PrologSet(
                             -SymbolCodes.symbolCode_E_height,
                             prologHeight,
                             PrologEmptySet.instance)))));
     result = new PrologList(prologBlob, result);
   }
   ;
   return result;
 }
コード例 #2
0
 public synchronized Term getConnectedGraphs() {
   ConnectedGraph[] graphs = formAndGetConnectedGraphs();
   Term list1 = PrologEmptyList.instance;
   for (int n = graphs.length - 1; n >= 0; n--) {
     ConnectedGraph graph = graphs[n];
     ArrayList<ConnectedSegment> connectedSegments = graph.connectedSegments;
     int numberOfSegments = connectedSegments.size();
     if (numberOfSegments <= 0) {
       continue;
     }
     ;
     Term list2 = PrologEmptyList.instance;
     for (int k = numberOfSegments - 1; k >= 0; k--) {
       ConnectedSegment connectedSegment = connectedSegments.get(k);
       int connectedSegmentNumber = connectedSegments.indexOf(connectedSegment);
       TrackSegment trackSegment = connectedSegment.trackSegment;
       Term prologOriginEdges =
           collectOriginEdges(connectedSegment, connectedSegmentNumber, connectedSegments);
       Term prologBrachEdges =
           collectBranchEdges(connectedSegment, connectedSegmentNumber, connectedSegments);
       Term prologIdentifier = new PrologInteger(trackSegment.owner);
       long beginningTime = trackSegment.beginningTime;
       int[][] rectangles = trackSegment.rectangles;
       int[] firstRectangle = rectangles[0];
       long frameNumber1 = beginningTime + firstRectangle[0];
       long x1 = StrictMath.round((firstRectangle[1] + firstRectangle[2]) / 2.0);
       long y1 = StrictMath.round((firstRectangle[3] + firstRectangle[4]) / 2.0);
       int[] lastRectangle = rectangles[rectangles.length - 1];
       long frameNumber2 = beginningTime + lastRectangle[0];
       long x2 = StrictMath.round((lastRectangle[1] + lastRectangle[2]) / 2.0);
       long y2 = StrictMath.round((lastRectangle[3] + lastRectangle[4]) / 2.0);
       Term prologSegment =
           assembleTrackSegment(frameNumber1, x1, y1, frameNumber2, x2, y2, trackSegment);
       Term prologEdge =
           new PrologSet(
               -SymbolCodes.symbolCode_E_inputs,
               prologOriginEdges,
               new PrologSet(
                   -SymbolCodes.symbolCode_E_outputs,
                   prologBrachEdges,
                   new PrologSet(
                       -SymbolCodes.symbolCode_E_identifier, prologIdentifier, prologSegment)));
       list2 = new PrologList(prologEdge, list2);
     }
     ;
     list1 = new PrologList(list2, list1);
   }
   ;
   return list1;
 }
コード例 #3
0
 public synchronized Term getTracks() {
   Set<BigInteger> trackIdentifiers = tracks.keySet();
   Iterator<BigInteger> trackIdentifiersIterator = trackIdentifiers.iterator();
   Term list1 = PrologEmptyList.instance;
   while (trackIdentifiersIterator.hasNext()) {
     BigInteger blobIdentifier = trackIdentifiersIterator.next();
     StableTrack track = tracks.get(blobIdentifier);
     Term prologIdentifier = new PrologInteger(blobIdentifier);
     ArrayList<TrackSegment> segmentList = track.getTrackSegments();
     ListIterator<TrackSegment> segmentListIterator = segmentList.listIterator(segmentList.size());
     Term list2 = PrologEmptyList.instance;
     while (segmentListIterator.hasPrevious()) {
       TrackSegment segment = segmentListIterator.previous();
       int[][] rectangles = segment.rectangles;
       if (rectangles.length <= 0) {
         continue;
       }
       ;
       long beginningTime = segment.beginningTime;
       int[] firstRectangle = rectangles[0];
       long frameNumber1 = beginningTime + firstRectangle[0];
       long x1 = StrictMath.round((firstRectangle[1] + firstRectangle[2]) / 2.0);
       long y1 = StrictMath.round((firstRectangle[3] + firstRectangle[4]) / 2.0);
       int[] lastRectangle = rectangles[rectangles.length - 1];
       long frameNumber2 = beginningTime + lastRectangle[0];
       long x2 = StrictMath.round((lastRectangle[1] + lastRectangle[2]) / 2.0);
       long y2 = StrictMath.round((lastRectangle[3] + lastRectangle[4]) / 2.0);
       Term prologSegment =
           assembleTrackSegment(frameNumber1, x1, y1, frameNumber2, x2, y2, segment);
       list2 = new PrologList(prologSegment, list2);
     }
     ;
     Term prologTrack =
         new PrologSet(
             -SymbolCodes.symbolCode_E_identifier,
             prologIdentifier,
             new PrologSet(-SymbolCodes.symbolCode_E_segments, list2, PrologEmptySet.instance));
     list1 = new PrologList(prologTrack, list1);
   }
   ;
   return list1;
 }
コード例 #4
0
 protected Term formTrackOfBlob(TrackSegment segment) {
   long beginningTime = segment.beginningTime;
   int[][] rectangles = segment.rectangles;
   double[] windowedR2ReferentValues = segment.getWindowedR2ReferentValues();
   Term list3 = PrologEmptyList.instance;
   for (int n = rectangles.length - 1; n >= 0; n--) {
     int[] currentRectangle = rectangles[n];
     long currentForegroundArea = segment.foregroundAreaValues[n];
     double currentCharacteristicLength = segment.characteristicLengthValues[n];
     long currentContourLength = segment.contourLengthValues[n];
     double currentR2 = windowedR2ReferentValues[n];
     double currentVelocity = segment.velocityValues[n];
     Term prologFrameN = new PrologInteger(beginningTime + currentRectangle[0]);
     Term prologXn =
         new PrologInteger(StrictMath.round((currentRectangle[1] + currentRectangle[2]) / 2.0));
     Term prologYn =
         new PrologInteger(StrictMath.round((currentRectangle[3] + currentRectangle[4]) / 2.0));
     Term prologWidthN = new PrologInteger(currentRectangle[2] - currentRectangle[1]);
     Term prologHeightN = new PrologInteger(currentRectangle[4] - currentRectangle[3]);
     Term prologForegroundAreaN = new PrologInteger(currentForegroundArea);
     Term prologCharacteristicLengthN = new PrologReal(currentCharacteristicLength);
     Term prologContourLengthN = new PrologInteger(currentContourLength);
     Term prologR2N = new PrologReal(currentR2);
     Term prologVelocityN = new PrologReal(currentVelocity);
     Term prologRectangle =
         new PrologSet(
             -SymbolCodes.symbolCode_E_frame,
             prologFrameN,
             new PrologSet(
                 -SymbolCodes.symbolCode_E_x,
                 prologXn,
                 new PrologSet(
                     -SymbolCodes.symbolCode_E_y,
                     prologYn,
                     new PrologSet(
                         -SymbolCodes.symbolCode_E_width,
                         prologWidthN,
                         new PrologSet(
                             -SymbolCodes.symbolCode_E_height,
                             prologHeightN,
                             new PrologSet(
                                 -SymbolCodes.symbolCode_E_foreground_area,
                                 prologForegroundAreaN,
                                 new PrologSet(
                                     -SymbolCodes.symbolCode_E_characteristic_length,
                                     prologCharacteristicLengthN,
                                     new PrologSet(
                                         -SymbolCodes.symbolCode_E_contour_length,
                                         prologContourLengthN,
                                         new PrologSet(
                                             -SymbolCodes.symbolCode_E_r2,
                                             prologR2N,
                                             new PrologSet(
                                                 -SymbolCodes.symbolCode_E_velocity,
                                                 prologVelocityN,
                                                 PrologEmptySet.instance))))))))));
     list3 = new PrologList(prologRectangle, list3);
   }
   ;
   return list3;
 }