//Some annotations might be updated with an old library and others might be updated with a new one. public static void UpdateInvalidatedLayers(List <LayerWrapper> layers) { //Initialize the intermediate interpretations Dictionary <string, InterpretationFromImage> interps = InitializeInterpretations(layers); string configId = LayerChain.ConfigurationId(layers, -1); LayerWrapper currLayer = null; //For each layer, re-interpret the captured images for its annotations //and let the layer recompute any data for them try { for (int i = 0; i < layers.Count; i++) { currLayer = layers[i]; //Check if the layer is invalidated string layerConfigId = GetPreviousConfigId(currLayer); if (!configId.StartsWith(layerConfigId)) { List <AnnotatedNode> nodes = NodesFromImageAnnotations(layers, i - 1, interps); AnnotationArgs args = new AnnotationArgs(nodes, currLayer.Intent); //process those nodes currLayer.Layer.ProcessAnnotations(args); //save the configuration id so we know if this layer becomes invalidated. SetConfigId(layers, i); } } } catch (Exception e) { throw new LayerException(currLayer, e); } }
private static void SetConfigId(List <LayerWrapper> layers, int layerIndex) { LayerWrapper layer = layers[layerIndex]; string configid = LayerChain.ConfigurationId(layers, layerIndex); IRuntimeStorage intent = layer.Intent; JObject jobj = new JObject(); jobj["id"] = configid; intent.PutData("config", jobj); }