Example dataflow and queries used in the paper.
Dataflow and user query 1: Amber alert
  1. USING Optasia;
  2.  
  3. //Extract video frames
  4. rawframes =
  5.     EXTRACT vid : int, //camera/video id
  6.             fid : int, //frame id
  7.             cid : int, //chunk id
  8.             frame : string //video frame
  9.     FROM SPARSE STREAMSET @"/my/v_wsdot/"
  10.                 PATTERN @"t_%n.avi"
  11.                 RANGE __serialnum = ["1","100"]
  12.     USING VideoExtractor("300", "50");
  13.  
  14. //Detect license plates
  15. lpr =
  16.     PROCESS rawframes
  17.     USING LPRProcessor("LP.model", "OCR.model")
  18.     PRODUCE vid,
  19.             fid,
  20.             LP,
  21.             Confidence;
  22.  
  23. //Extract RGB histogram feature
  24. features_RGBHIST =
  25.     PROCESS rawframes
  26.     USING FeatureProcessor("RGBHIST:size=10")
  27.     PRODUCE vid,
  28.             fid,
  29.             Feature;
  30.  
  31. //Extract HOG feature
  32. features_HOG =
  33.     PROCESS rawframes
  34.     USING FeatureProcessor("HOG:dimh=64,dimw=64")
  35.     PRODUCE vid,
  36.             fid,
  37.             Feature;
  38.  
  39. //Combine features
  40. features_CarClassification =
  41.     REDUCE
  42.     (
  43.         SELECT *
  44.         FROM features_HOG
  45.         UNION
  46.         SELECT *
  47.         FROM features_RGBHIST
  48.     )
  49.     ON vid, fid
  50.     USING FeatureReducer;
  51.  
  52. //Apply classifier and predict vehicle type labels
  53. labels_CarClassification =
  54.     PROCESS features_CarClassification
  55.     USING ClassifierProcessor(@"vehicle.model")
  56.     PRODUCE vid,
  57.             fid,
  58.             label,
  59.             confidence;
  60.  
  61. //Apply classifier and predict vehicle color labels
  62. labels_ColorClassification =
  63.     PROCESS features_RGBHIST
  64.     USING ClassifierProcessor(@"color.model")
  65.     PRODUCE vid,
  66.             fid,
  67.             label,
  68.             confidence;
  69.  
  70. results =
  71.     SELECT labels_CarClassification.vid,
  72.            labels_CarClassification.fid
  73.     FROM labels_CarClassification
  74.          INNER JOIN
  75.              lpr
  76.          ON lpr.fid == labels_CarClassification.fid
  77.             AND lpr.vid == labels_CarClassification.vid
  78.          INNER JOIN
  79.              labels_ColorClassification
  80.          ON labels_ColorClassification.vid == labels_CarClassification.vid
  81.             AND labels_ColorClassification.fid == labels_CarClassification.fid
  82.     WHERE lpr.LP.StartsWith("A") AND labels_CarClassification.label == "suv"
  83.           AND labels_ColorClassification.label == "red";

Dataflow and user query 2: Traffic violation
  1. USING Optasia;
  2.  
  3. rawframes =
  4.     EXTRACT vid : int, //camera/video id
  5.             fid : int, //frame id
  6.             cid : int, //chunk id
  7.             frame : string //video frame
  8.     FROM SPARSE STREAMSET @"/my/v_wsdot/"
  9.                 PATTERN @"t_%n.avi"
  10.                 RANGE __serialnum = ["1","100"]
  11.     USING VideoExtractor("300", "50");
  12.  
  13. //Estimate traffic flow
  14. counter =
  15.     REDUCE rawframes
  16.     ON vid, cid
  17.     PRODUCE vid,
  18.             fid,
  19.             patch, //image patch for detected vehicles
  20.             inbox, //vehicles passing which entry box
  21.             fid_in, //time to pass the entry box
  22.             outbox, //vehicles passing which exit box
  23.             fid_out //time to pass the exit box
  24.     USING TrackingReducer("L_lane_in,M_lane_in,R_lane_in", "L_lane_out,M_lane_out,R_lane_out", "MercerSt.tif");
  25.  
  26. //Extract HOG feature
  27. features_HOG =
  28.     PROCESS counter
  29.     USING FeatureProcessor("HOG:dimh=64,dimw=64")
  30.     PRODUCE vid,
  31.             fid,
  32.             Feature;
  33.  
  34. //Extract RGB histogram feature
  35. features_RGBHIST =
  36.     PROCESS counter
  37.     USING FeatureProcessor("RGBHIST:size=10")
  38.     PRODUCE vid,
  39.             fid,
  40.             Feature;
  41.  
  42. //Combine features
  43. features_CarClassification =
  44.     REDUCE
  45.     (
  46.         SELECT *
  47.         FROM features_HOG
  48.         UNION
  49.         SELECT *
  50.         FROM features_RGBHIST
  51.     )
  52.     ON vid, fid
  53.     USING FeatureReducer;
  54.  
  55. //Apply classifier and predict vehicle type labels
  56. labels_CarClassification =
  57.     PROCESS features_CarClassification
  58.     USING ClassifierProcessor(@"vehicle.model")
  59.     PRODUCE vid,
  60.             fid,
  61.             label,
  62.             confidence;
  63.  
  64. results =
  65.     SELECT counter.*,
  66.            labels_CarClassification.*
  67.     FROM counter
  68.          INNER JOIN
  69.              labels_CarClassification
  70.          ON counter.fid == labels_CarClassification.fid
  71.             AND counter.vid == labels_CarClassification.vid
  72.     WHERE inbox == "L_lane_in" AND outbox == "R_lane_out"
  73.           AND labels_CarClassification.label == "truck";

Dataflow and user query 3: Re-identification
  1. USING Optasia;
  2.  
  3. //Read existed Re-ID matrix
  4. reid_mat =
  5.     EXTRACT CamId_a : int,
  6.             CamId_b : int,
  7.             data : string
  8.     FROM @"/my/reid/ReID_1_2.gz"
  9.     USING ReIDDictExtractor();
  10.  
  11. //Extrat video frames
  12. v_a =
  13.     EXTRACT vid : int,
  14.             fid : int,
  15.             cid : int,
  16.             frame : string
  17.     FROM SPARSE STREAMSET @"/my/garageA/"
  18.                 PATTERN @"G_%n.mp4"
  19.                 RANGE __serialnum = ["1","100"]
  20.     USING VideoExtractor("300", "50");
  21.  
  22. v_b =
  23.     EXTRACT vid : int,
  24.             fid : int,
  25.             cid : int,
  26.             frame : string
  27.     FROM SPARSE STREAMSET @"/my/garageB/"
  28.                 PATTERN @"G_%n.mp4"
  29.                 RANGE __serialnum = ["1","100"]
  30.     USING VideoExtractor("300", "50");
  31.  
  32. //Extract features on feed A
  33. features_HOG_a =
  34.     PROCESS v_a
  35.     USING FeatureProcessor("HOG:dimh=64,dimw=64")
  36.     PRODUCE vid,
  37.             fid,
  38.             Feature;
  39.  
  40. features_RGBHIST_a =
  41.     PROCESS v_a
  42.     USING FeatureProcessor("RGBHIST:size=10")
  43.     PRODUCE vid,
  44.             fid,
  45.             Feature;
  46.  
  47. features_CarClassification_a =
  48.     REDUCE
  49.     (
  50.         SELECT *
  51.         FROM features_HOG_a
  52.         UNION
  53.         SELECT *
  54.         FROM features_RGBHIST_a
  55.     )
  56.     ON vid, fid
  57.     USING FeatureReducer;
  58.  
  59. //Apply classifier and predict vehicle type labels
  60. type_a =
  61.     PROCESS features_CarClassification_a
  62.     USING ClassifierProcessor(@"vehicle.model")
  63.     PRODUCE vid,
  64.             fid,
  65.             label,
  66.             confidence;
  67.  
  68. //Extract features on feed B
  69. features_HOG_b =
  70.     PROCESS v_b
  71.     USING FeatureProcessor("HOG:dimh=64,dimw=64")
  72.     PRODUCE vid,
  73.             fid,
  74.             Feature;
  75.  
  76. features_RGBHIST_b =
  77.     PROCESS v_b
  78.     USING FeatureProcessor("RGBHIST:size=10")
  79.     PRODUCE vid,
  80.             fid,
  81.             Feature;
  82.  
  83. features_CarClassification_b =
  84.     REDUCE
  85.     (
  86.         SELECT *
  87.         FROM features_HOG_b
  88.         UNION
  89.         SELECT *
  90.         FROM features_RGBHIST_b
  91.     )
  92.     ON vid, fid
  93.     USING FeatureReducer;
  94.  
  95. //Apply classifier and predict vehicle type labels
  96. type_b =
  97.     PROCESS features_CarClassification_b
  98.     USING ClassifierProcessor(@"vehicle.model")
  99.     PRODUCE vid,
  100.             fid,
  101.             label,
  102.             confidence;
  103.  
  104. //Extract Re-ID features feed A
  105. features_pyramidSILTP_a =
  106.     PROCESS v_a
  107.     USING FeatureProcessor("PYRAMIDMAXSILTPHIST")
  108.     PRODUCE vid,
  109.             fid,
  110.             Feature;
  111.  
  112. features_pyramidHIST_a =
  113.     PROCESS features_pyramidSILTP_a
  114.     USING FeatureProcessor("PYRAMIDMAXJOINTHIST")
  115.     PRODUCE v_a,
  116.             fid,
  117.             Feature;
  118.  
  119. features_reid_a =
  120.     REDUCE
  121.     (
  122.         SELECT *
  123.         FROM features_pyramidSILTP_a
  124.         UNION
  125.         SELECT *
  126.         FROM features_pyramidHIST_a
  127.     )
  128.     ON vid, fid
  129.     USING FeatureReducer;
  130.  
  131. //Extract Re-ID features feed B
  132. features_pyramidSILTP_b =
  133.     PROCESS v_b
  134.     USING FeatureProcessor("PYRAMIDMAXSILTPHIST")
  135.     PRODUCE vid,
  136.             fid,
  137.             Feature;
  138.  
  139. features_pyramidHIST_b =
  140.     PROCESS v_b
  141.     USING FeatureProcessor("PYRAMIDMAXJOINTHIST")
  142.     PRODUCE vid,
  143.             fid,
  144.             Feature;
  145.  
  146. features_reid_b =
  147.     REDUCE
  148.     (
  149.         SELECT *
  150.         FROM features_pyramidSILTP_b
  151.         UNION
  152.         SELECT *
  153.         FROM features_pyramidHIST_b
  154.     )
  155.     ON vid, fid
  156.     USING FeatureReducer;
  157.  
  158. //Re-ID combiner
  159. reid =
  160.     COMBINE
  161.     (
  162.         SELECT features_reid_a.vid AS vid_a,
  163.                features_reid_a.fid AS fid_a,
  164.                features_reid_b.vid AS vid_b,
  165.                features_reid_b.fid AS fid_b,
  166.                features_reid_a.Feature AS Feature_a,
  167.                features_reid_b.Feature AS Feature_b
  168.         FROM features_pyramidHIST_a
  169.              CROSS JOIN
  170.                  features_pyramidHIST_b
  171.     ) WITH reid_mat
  172.     USING ReIDCombiner()
  173.     PRODUCE vid_a,
  174.             fid_a,
  175.             vid_b,
  176.             fid_b,
  177.             score;
  178.  
  179. results =
  180.     SELECT reid.*
  181.     FROM reid
  182.          INNER JOIN
  183.              type_a
  184.          ON reid.vid_a == type_a.vid AND reid.fid_a == type_a.fid
  185.          INNER JOIN
  186.              type_b
  187.          ON reid.vid_b == type_b.vid AND reid.fid_b == type_b.fid
  188.     WHERE reid.score > - 15
  189.           AND type_a.label == "suv" AND type_b.label == "suv";