private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = @"demo\"; openFileDialog.Filter = "All file|*.*|jpg|*.jpg|png|*.png"; openFileDialog.RestoreDirectory = true; openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog() == DialogResult.OK) { ABox aBox = new ABox(0, 0, 256, 256); LbfCascade cas = new LbfCascade(@"GlasssixLandmarks.model"); double[,] landmatks = cas.Predict(openFileDialog.FileName, aBox); Bitmap bmp = new Bitmap(openFileDialog.FileName); int count = 0; for (int i = 0; i < 68; i++) { if (Convert.ToInt32(landmatks[i, 0]) < 255 && Convert.ToInt32(landmatks[i, 0]) > 1 && Convert.ToInt32(landmatks[i, 1]) < 255 && Convert.ToInt32(landmatks[i, 1])>1) { bmp.SetPixel(Convert.ToInt32(landmatks[i, 0]), Convert.ToInt32(landmatks[i, 1]), Color.Aqua); bmp.SetPixel(Convert.ToInt32(landmatks[i, 0]) + 1, Convert.ToInt32(landmatks[i, 1]) + 1, Color.Aqua); bmp.SetPixel(Convert.ToInt32(landmatks[i, 0]) - 1, Convert.ToInt32(landmatks[i, 1]) - 1, Color.Aqua); bmp.SetPixel(Convert.ToInt32(landmatks[i, 0]) + 1, Convert.ToInt32(landmatks[i, 1]) - 1, Color.Aqua); bmp.SetPixel(Convert.ToInt32(landmatks[i, 0]) - 1, Convert.ToInt32(landmatks[i, 1]) + 1, Color.Aqua); count++; } } FileInfo file = new FileInfo(openFileDialog.FileName); Console.WriteLine(count); bmp.Save(@"results\"+file.Name ); pictureBox1.Image = bmp; } }
public override AType Execute(AType argument, Aplus environment = null) { AType result = ABox.Create(argument); if (argument.Type == ATypes.AFunc && !argument.IsFunctionScalar) { result.Type = ATypes.AFunc; } return(result); }
public void DropRestrictedWholweNumber2BoxList() { AType expected = AArray.Create( ATypes.ABox, ABox.Create(AInteger.Create(1)) ); AType result = this.engine.Execute <AType>("2.0000000000000000009 drop (3;5;1)"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void EachUseDyadicScalarFunctionScalar2OneElementArray() { AType expected = AArray.Create( ATypes.ABox, ABox.Create(AInteger.Create(12)) ); AType result = this.engine.Execute <AType>(" 3 ((* each)) 1 rho 4"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void BoxofVectorMember() { ScriptScope scope = this.engine.CreateScope(); scope.SetVariable(".a", ABox.Create(AInteger.Create(1))); scope.SetVariable(".b", ABox.Create(AArray.Create(ATypes.AInteger, AInteger.Create(1), AInteger.Create(2)))); AType result = this.engine.Execute <AType>("a in b", scope); Assert.AreEqual <AType>(AInteger.Create(0), result, "Invalid value produced"); Assert.AreEqual(InfoResult.OK, result.CompareInfos(AInteger.Create(0))); }
public void DroppedNullExample() { AType expected = AArray.Create(ATypes.ABox, ABox.Create(AArray.Create(ATypes.ASymbol, ASymbol.Create("a"))), ABox.Create(AArray.Create(ATypes.ABox, ABox.Create(AInteger.Create(1)))) ); AType result = this.engine.Execute <AType>("_alsf{(`a;1;)}"); Assert.AreEqual(expected, result); }
public void init(ABox sceneObj) { wid = sceneObj.wid; hei = sceneObj.hei; hWid = wid / 2; hHei = hei / 2; cornerPoints = new Vector3[4]; for (int i = 0; i < cornerPoints.Length; i++) { cornerPoints[i] = sceneObj._vertexs[i].pos; } leftBottomPoint = cornerPoints[3]; }
public void ReplicateInteger2Box() { AType expected = AArray.Create( ATypes.ABox, ABox.Create(Helpers.BuildString("test")), ABox.Create(Helpers.BuildString("test")), ABox.Create(Helpers.BuildString("test")) ); AType result = this.engine.Execute <AType>("3 / < 'test'"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void NegativeIndex() { AType expected = AArray.Create(ATypes.ABox, ABox.Create(Helpers.BuildString("May 15")), ABox.Create(Helpers.BuildString("n.a.")), ABox.Create(Helpers.BuildString("n.a.")), ABox.Create(Helpers.BuildString("Jul 18")) ); AType result = this.engine.Execute <AType>("_index{2 -2 -14 1;('Mar 06';'Jul 18';'May 15';'Nov 26');<'n.a.'}"); Assert.AreEqual(expected, result); }
internal AABBRegion(float dx, float dy, float dz) { TheABox = new ABox { Min = new Bitub.Dto.Spatial.XYZ(), Max = new Bitub.Dto.Spatial.XYZ { X = dx, Y = dy, Z = dz } }; }
public void EachUsePrimitiveFunctionToCharacterMatrix() { AType expected = AArray.Create( ATypes.ABox, AArray.Create(ATypes.ABox, ABox.Create(ASymbol.Create("a")), ABox.Create(ASymbol.Create("b"))), AArray.Create(ATypes.ABox, ABox.Create(ASymbol.Create("c")), ABox.Create(ASymbol.Create("d"))) ); AType result = this.engine.Execute <AType>("(pack each) 2 2 rho 'abcd'"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void EncloseTwiceUserDefinedFunction() { ScriptScope scriptscope = this.engine.CreateScope(); scriptscope.SetVariable("a", udf); AType expected = ABox.Create(ABox.Create(udf, ATypes.AFunc)); AType result = this.engine.Execute <AType>("< <{a}", scriptscope); Assert.AreEqual <AType>(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public override void testCollide() { for (int i = 0; i < Groups.bulletAll.Count; i++) { ABox otherObj = Groups.bulletAll[i] as ABox; for (int j = 0; j < collideBoxs.Length; j++) { ABox collideBox = collideBoxs[j]; collideBox.collideWithOtherBox(otherObj); } } }
public void TakeInteger2Null() { AType expected = AArray.Create( ATypes.ABox, ABox.Create(Utils.ANull()), ABox.Create(Utils.ANull()) ); AType result = this.engine.Execute <AType>("2 take ()"); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); //Assert.AreEqual(expected, result); }
public void PickSymbolConstant2SlotFiller3() { ScriptScope scope = this.engine.CreateScope(); this.engine.Execute <AType>("a{b}: b+b", scope); AType expected = ABox.Create(scope.GetVariable <AType>(".a"), ATypes.AFunc); AType result = this.engine.Execute <AType>("`a pick (`a; <{a})", scope); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); Assert.AreEqual(expected, result); }
public void TakeInteger2Box() { AType expected = AArray.Create( ATypes.ABox, ABox.Create(AInteger.Create(1)), ABox.Create(AInteger.Create(5)) ); AType result = this.engine.Execute <AType>("2 take (1;5;7)"); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); Assert.AreEqual(expected, result); }
public void CatenateMixedArray() { AType expected = AArray.Create(ATypes.ASymbol, ASymbol.Create("a"), ASymbol.Create("b"), ABox.Create(AInteger.Create(1)), ABox.Create(AInteger.Create(3)) ); AType result = this.engine.Execute <AType>("`a`b , (1;3)"); Assert.AreEqual <AType>(expected, result, "Incorrect result created"); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
void createCollideGroup() { Transform collideGroup = transform.Find("collideGroup"); Transform[] childs = collideGroup.transform.GetComponentsInChildren <Transform> (); collideBoxs = new ABox[childs.Length - 1]; for (int i = 1; i < childs.Length; i++) { int j = i - 1; createCustomBox(ref collideBoxs[j]); collideBoxs[j].connect(childs[i]); collideBoxs[j].belongToObj = this; } }
public void PickSymbolConstant2ExtendedSlotFiller5() { ScriptScope scope = this.engine.CreateScope(); this.engine.Execute <AType>("a{b}: b+b", scope); this.engine.Execute <AType>("b{a}: a*a", scope); AType expected = ABox.Create(scope.GetVariable <AType>(".b")); AType result = this.engine.Execute <AType>("`b pick (`a`c`b;(a;+;b))", scope); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); Assert.AreEqual(expected, result); }
public void BoxReshape() { AType expected = AArray.Create(ATypes.ABox, AArray.Create(ATypes.ABox, ABox.Create(AInteger.Create(1)), ABox.Create(AInteger.Create(2)), ABox.Create(AInteger.Create(1))), AArray.Create(ATypes.ABox, ABox.Create(AInteger.Create(2)), ABox.Create(AInteger.Create(1)), ABox.Create(AInteger.Create(2))), AArray.Create(ATypes.ABox, ABox.Create(AInteger.Create(1)), ABox.Create(AInteger.Create(2)), ABox.Create(AInteger.Create(1))) ); Console.WriteLine(expected); AType result = this.engine.Execute <AType>(" 3 3 rho (1;2)"); Console.WriteLine(result); Assert.AreEqual <AType>(expected, result, "Incorrect integer matrix generated"); }
public void ReverseNestedMixedArray() { AType expected = AArray.Create( ATypes.ASymbol, ASymbol.Create("b"), ABox.Create(AInteger.Create(8)), ASymbol.Create("a"), ABox.Create(AInteger.Create(5)) ); AType result = this.engine.Execute <AType>("rot (<5), `a , (<8), `b"); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void SelectiveAssignmentPreset() { AType expected = Helpers.BuildStrand( new AType[] { ASymbol.Create("b"), ASymbol.Create("ctx"), Utils.ANull(), AInteger.Create(0), ABox.Create(AArray.Create(ATypes.ASymbol, ASymbol.Create("Scalar"), ASymbol.Create("Vector"), ASymbol.Create("Matrix"))), Helpers.BuildString("static") } ); AType expectedValue = Helpers.BuildStrand( new AType[] { Helpers.BuildStrand( new AType[] { AArray.Create( ATypes.AInteger, AArray.Create(ATypes.AInteger, AInteger.Create(0), AInteger.Create(1)), AArray.Create(ATypes.AInteger, AInteger.Create(2), AInteger.Create(3)), AArray.Create(ATypes.AInteger, AInteger.Create(4), AInteger.Create(5)) ), Helpers.BuildString("abcdef"), AFloat.Create(3.14) } ), AArray.Create(ATypes.ASymbol, ASymbol.Create("Scalar"), ASymbol.Create("Vector"), ASymbol.Create("Matrix")) } ); ScriptScope scope = this.engine.CreateScope(); this.engine.Execute("$cx ctx", scope); this.engine.Execute("b := (`scalar `vector `matrix; (3.14; 'abcdef'; iota 3 2))", scope); this.engine.Execute("cbf{a;b;c;d;e;f}:{.result := (a;b;c;d;e;f); := b}", scope); this.engine.Execute("_spcb{`b;(cbf;'static')}", scope); this.engine.Execute("(1 0 /b) := <`Scalar `Vector `Matrix", scope); Assert.AreEqual(expected.CompareInfos(scope.GetVariable <AType>(".result")), InfoResult.OK); Assert.AreEqual(expectedValue, scope.GetVariable <AType>("ctx.b")); Assert.AreEqual(expected, scope.GetVariable <AType>(".result")); }
private static AType ArrayInput(AType input) { AType result; AType titles = AArray.Create(ATypes.ANull); AType elements = AArray.Create(ATypes.ANull); int odd = input.Length % 2; for (int i = 0; i < input.Length - odd; i += 2) { AType key = MonadicFunctionInstance.Disclose.Execute(input[i]); AType value = input[i + 1]; if (key.Type != ATypes.ASymbol) { throw new Error.Domain("_alsf"); } if (!value.IsBox) { value = ABox.Create(value); } titles.Add(key); elements.Add(value); } AType lastItem; if (input.Length == 0) { lastItem = input; } else { lastItem = MonadicFunctionInstance.Disclose.Execute(input[input.Length - 1]); } if (odd != 0 && lastItem.Type != ATypes.ANull) { titles.Add(lastItem); elements.Add(ABox.Create(AArray.Create(ATypes.ANull))); } result = AArray.Create(ATypes.AType, ABox.Create(titles), ABox.Create(elements)); return(result); }
/// <summary> /// Creates a result for the SyncRead/SyncSend depending on the error type. /// </summary> /// <param name="exception"></param> /// <returns></returns> protected AType SyncFillError(SocketError errorCode, bool isRead) { string category; string detail; switch (errorCode) { case SocketError.TimedOut: category = "timeout"; detail = "Syncread loop timed out"; break; case SocketError.ConnectionReset: category = "reset"; detail = "Reset occured. No message read."; break; case SocketError.Interrupted: category = "interrupt"; detail = "select() received an interrupt"; break; case SocketError.NoBufferSpaceAvailable: category = isRead ? "buffread" : "buffwrite"; detail = String.Concat(category, " returned error"); break; case SocketError.NotInitialized: case SocketError.NotConnected: category = "nochan"; detail = "channel is null"; break; default: category = "other"; detail = "other error occured"; break; } AType result = AArray.Create(ATypes.ABox, ABox.Create(ASymbol.Create("error")), ABox.Create(ASymbol.Create(category)), ABox.Create(Helpers.BuildString(detail)) ); return(result); }
public void DiscloseMixedNestedArray() { ScriptScope scope = this.engine.CreateScope(); AType a = this.engine.Execute <AType>("a := <{+}", scope); AType expected = AArray.Create( ATypes.ASymbol, ASymbol.Create("a"), a, ABox.Create(AInteger.Create(4)) ); AType result = this.engine.Execute <AType>(">(`a;a;<4)", scope); Assert.AreEqual <AType>(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
public void SymbolVector() { AType expected = AArray.Create(ATypes.ABox, ABox.Create(AArray.Create(ATypes.ASymbol, ASymbol.Create("a"), ASymbol.Create("c"))), ABox.Create( AArray.Create(ATypes.ABox, ABox.Create(ASymbol.Create("b")), ABox.Create(ASymbol.Create("d")) ) ) ); AType result = this.engine.Execute <AType>("_alsf{`a `b `c `d}"); Assert.AreEqual(expected, result); }
public void collideWithOtherBox(ABox other) { calculateGlobalspeedAndRelateVec(this, other); //if (!isObjsMatchCondition ( other )) // return; for (int k = 0; k < other._surfaces.Length; k++) { SURFACE surface = other._surfaces[k]; for (int j = 0; j < _vertexs.Length; j++) { VERTEX vertex = _vertexs[j]; vertexContactSurface(vertex, surface); } } CollideManager.totalCollideObjNumPerFrame++; }
public static ABox IntersectWith(this ABox a, ABox b) { return(new ABox { Min = new XYZ { X = Math.Max(a.Min.X, b.Min.X), Y = Math.Max(a.Min.Y, b.Min.Y), Z = Math.Max(a.Min.Z, b.Min.Z) }, Max = new XYZ { X = Math.Min(a.Max.X, b.Max.X), Y = Math.Min(a.Max.Y, b.Max.Y), Z = Math.Min(a.Max.Z, b.Max.Z) } }); }
public void GeneralApplyInvoke() { ScriptScope scope = this.engine.CreateScope(); this.engine.Execute <AType>("f{a;b;c}: drop (a;b;c)", scope); this.engine.Execute <AType>("boxF:= <{f}", scope); AType expected = AArray.Create(ATypes.ABox, ABox.Create(AInteger.Create(1)), ABox.Create(AInteger.Create(2)), ABox.Create(AInteger.Create(3)) ); AType result = this.engine.Execute <AType>("(boxF) each {1;2;3}", scope); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }
/// <summary> /// Convert the input argument to an array. /// </summary> /// <param name="argument"></param> /// <returns></returns> private AType PrepareInputItems(AType argument) { AType result; if (argument.Type == ATypes.ANull) { result = AArray.Create(ATypes.ABox, ABox.Create(argument)); } else if (argument.IsArray) { result = argument; } else { result = AArray.Create(argument.Type, argument); } return(result); }
public void RazeNestedMixedArray() { ScriptScope scope = this.engine.CreateScope(); AType f = this.engine.Execute <AType>("f := <{+}", scope); AType expected = AArray.Create( ATypes.AFunc, f, ASymbol.Create("a"), ABox.Create(AInteger.Create(2)), ABox.Create(AInteger.Create(6)), ABox.Create(AInteger.Create(7)) ); AType result = this.engine.Execute <AType>("pick (f;;`a;(2;6);<7)", scope); Assert.AreEqual(expected, result); Assert.AreEqual(InfoResult.OK, result.CompareInfos(expected)); }