protected void RunAnalysis() { switch (_worklistMethodName) { case "FIFOWorklist": _worklist = new FIFOWorklist(_flow); break; case "LIFOWorklist": _worklist = new LIFOWorklist(_flow); break; case "ChaoticIteration": _worklist = new ChaoticIteration(_flow.Shuffle(3)); break; case "RoundRobin": DepthFirstSpanningTree dfst = new DepthFirstSpanningTree(new FlowGraph(_program)); _worklist = new RoundRobin(_flow, dfst.GetRP()); break; default: break; } WorkThroughWorklist(_worklist); var labels = FlowUtil.Labels(_blocks); foreach (var lab in labels) { var edges = _flow.Where(x => x.Dest == lab); _analysisFilled[lab] = TransferFunctions(lab); } }
public Analysis(Program program, AnalysisDirection direction, string worklistName) { _program = program; _blocks = FlowUtil.Blocks(program); _worklistMethodName = worklistName; var flow = FlowUtil.Flow(program); if (direction == AnalysisDirection.Forward) { _flow = flow; _extremalLabels = FlowUtil.Init(program).Singleton(); } else { _flow = FlowUtil.FlowR(flow); _extremalLabels = FlowUtil.Final(program); } _analysisCircle = new List <ILattice <T> >(); _analysisFilled = new List <ILattice <T> >(); _iterationSteps = new List <IterationStep>(); }
public void TryCatchFinallyTest() { { var onErrorMock = new Mock <Func <Exception, string> >(); var finallyMock = new Mock <Action>(); var result = FlowUtil.TryCatchFinally <string, Exception>( () => expectedResult, onErrorMock.Object, finallyMock.Object); Assert.AreEqual(expectedResult, result); onErrorMock.VerifyNoOtherCalls(); finallyMock.Verify(f => f.Invoke()); } { var onErrorMock = new Mock <Func <Exception, string> >(); var finallyMock = new Mock <Action>(); var result = FlowUtil.TryCatchFinally <string, Exception>( () => throw new Exception(), onErrorMock.Object, finallyMock.Object); Assert.IsNull(result); onErrorMock.Verify(f => f.Invoke(It.IsAny <Exception>())); finallyMock.Verify(f => f.Invoke()); } { var onErrorMock = new Mock <Func <Exception, string> >(); var finallyMock = new Mock <Action>(); var result = FlowUtil.TryCatchFinally( () => expectedResult, onErrorMock.Object, finallyMock.Object); Assert.AreEqual(expectedResult, result); onErrorMock.VerifyNoOtherCalls(); finallyMock.Verify(f => f.Invoke()); } { var onErrorMock = new Mock <Func <Exception, string> >(); var finallyMock = new Mock <Action>(); var result = FlowUtil.TryCatchFinally( () => throw new Exception(), onErrorMock.Object, finallyMock.Object); Assert.IsNull(result); onErrorMock.Verify(f => f.Invoke(It.IsAny <Exception>())); finallyMock.Verify(f => f.Invoke()); } }
void Start() { _of = GetComponent <OpticalFlowWorker>(); _tex = new Texture2D(0, 0, TextureFormat.RGB24, false); target.renderer.sharedMaterial.mainTexture = _tex; _corners0 = FlowUtil.GenGridCorners(_of.width, _of.height, 50f); _prevResult = _result = _of.CalculateOpticalFlow(_corners0); }
private int WorkThroughWorklist(IWorkList _workList) { int numberOfOperations = 0; List <(int, string)> analysisCircleList = new List <(int, string)>(); foreach (int lab in FlowUtil.Labels(_blocks)) { analysisCircleList.Add((lab, _analysisCircle[lab].ToString()));
void Start() { _of = GetComponent <OpticalFlowWorker>(); _tex = new Texture2D(0, 0, TextureFormat.RGB24, false); var mf = flow.GetComponent <MeshFilter>(); _mesh = mf.mesh = new Mesh(); background.renderer.sharedMaterial.mainTexture = _tex; _corners0 = FlowUtil.GenGridCorners(_of.width, _of.height, 50f); _result = _of.CalculateOpticalFlow(_corners0); }
void Update() { if (!_result.completed) { return; } if (_firstTimeUpdate) { _firstTimeUpdate = false; UpdateAspectRatio(_result.imageWidth, _result.imageHeight); _velocities = new CvPoint2D32f[_mesh.vertexCount / 2]; } ShowImage(_result); FlowUtil.CalculateFlowVelocities(_result, ref _velocities); FlowUtil.UpdateLineMesh(_result, _mesh, _velocities, limitVelocity); _result = _of.CalculateOpticalFlow(_corners0); }
// Use this for initialization void Start() { _of = GetComponent <OpticalFlowWorker>(); _videoTex = new Texture2D(0, 0, TextureFormat.RGB24, false, false); _flowMesh = new Mesh(); var mf = flow.GetComponent <MeshFilter>(); mf.sharedMesh = _flowMesh; video.renderer.sharedMaterial.mainTexture = _videoTex; _corners0 = FlowUtil.GenGridCorners(_of.width, _of.height, 50f); _cornerBirthTimes = new float[_corners0.Length]; var t = Time.timeSinceLevelLoad; for (var i = 0; i < _cornerBirthTimes.Length; i++) { _cornerBirthTimes[i] = t; } _ofResult = _of.CalculateOpticalFlow(_corners0); }
// Update is called once per frame void Update() { if (!_ofResult.completed) { return; } //Debug.Log(string.Format("Optical Flow elapsed time {0:f}(ms)", _ofResult.elapsedMs)); if (_ofResult.imageWidth != _videoTex.width || _ofResult.imageHeight != _videoTex.height) { _videoTex.Resize(_ofResult.imageWidth, _ofResult.imageHeight); var s = video.transform.localScale; s.x = s.y * _ofResult.imageWidth / _ofResult.imageHeight; video.transform.localScale = s; } _videoTex.LoadRawTextureData(_ofResult.imageData); _videoTex.Apply(); FlowUtil.CalculateFlowVelocities(_ofResult, ref _velocities); FlowUtil.UpdateLineMesh(_ofResult, _flowMesh, _velocities, limitVelocity); _ofResult = _of.CalculateOpticalFlow(_ofResult.corners1); }
private async Task <AuthClaims> TryGetAuthClaims(ActionExecutingContext ctx) { var ok = ctx.HttpContext.Request.Cookies.TryGetValue(Constants.SessionCookieName, out var token); if (ok && !string.IsNullOrEmpty(token)) { return(FlowUtil.TryCatch( () => authorization.ValidateSessionKey(token), (_) => null)); } ok = ctx.HttpContext.Request.Headers.TryGetValue("authorization", out var authHeaderValue); if (!ok) { return(null); } var ahvStr = authHeaderValue.ToString(); if (ahvStr.ToString().StartsWith("session ")) { return(FlowUtil.TryCatch( () => authorization.ValidateSessionKey(ahvStr[8..]),