public void Follow(Inter newTarget) { agent.stoppingDistance = newTarget.radius * .5f; agent.updateRotation = false; target = newTarget.interactionTransform; }
public override bool Do() { ClearOut(); try { Inter InterEnum = (Inter)EnumPropertys["Inter"].Value; foreach (var src in Sources) { foreach (var outData in src.GetOut()) { int xc = (int)(outData.Image.Width * FloatPropertys["xc"].Value); int yc = (int)(outData.Image.Height * FloatPropertys["yc"].Value); Mat rotationMatrix = new Mat(); CvInvoke.GetRotationMatrix2D(new System.Drawing.Point(xc, yc), FloatPropertys["Deg"].Value, FloatPropertys["Scale"].Value, rotationMatrix); var outSz = new System.Drawing.Size(outData.Image.Width, outData.Image.Height); if (IntPropertys["NewSize"].Value > 0) { outSz = new System.Drawing.Size(IntPropertys["Width"].Value, IntPropertys["Height"].Value); } Mat dst = new Mat(); CvInvoke.WarpAffine(outData.Image, dst, rotationMatrix, outSz, InterEnum); this.m_out.Add(new DataSrc(dst, outData.Info, false)); } } } catch { return(false); } return(true); }
/// <summary> /// Resizes the image but keeps the aspect ratio /// </summary> /// <param name="origin"> source image to resize </param> /// <param name="width"> new Width </param> /// <param name="method"> scale method </param> /// <returns> resized image </returns> public Image <Bgr, byte> ResizeImg(Image <Bgr, byte> origin, int width, Inter method) { float ratio = (float)origin.Width / origin.Height; int height = (int)(width / ratio); return(origin.Resize(width, height, method)); }
internal double LagrangInterpTest([PexAssumeUnderTest] Inter target) { double result = target.LagrangInterp(); return(result); // TODO: добавление проверочных утверждений в метод InterTest.LagrangInterpTest(Inter) }
void RemoveFocus() { if (focus != null) { focus.OnDefocused(); } focus = null; mover.StopFollowing(); }
public ActionResult Create([Bind(Include = "ProductId,ProductName,ProductPrice,InStock")] Product product) { if (ModelState.IsValid) { Inter.CreateProduct(product.ProductName, product.ProductPrice, product.InStock); return(RedirectToAction("Index")); } return(View(product)); }
public void TestVirtualIndirectCallInNative() { using (Inter i = new Inter()) { using (InterfaceTester tester = new InterfaceTester()) { tester.SetInterface(i); Assert.That(tester.Get(10), Is.EqualTo(IntPtr.Zero)); } } }
/// <summary> /// Resize an image such that it fits in a given frame /// </summary> /// <param name="src">The source image</param> /// <param name="dst">The result image</param> /// <param name="frameSize">The size of the frame</param> /// <param name="interpolationMethod">The interpolation method</param> /// <param name="scaleDownOnly">If true, it will not try to scale up the image to fit the frame</param> public static void ResizeForFrame(IInputArray src, IOutputArray dst, Size frameSize, Inter interpolationMethod = Inter.Linear, bool scaleDownOnly = true) { using (InputArray iaImage = src.GetInputArray()) { Size sz = iaImage.GetSize(); if (scaleDownOnly == true && sz.Width <= frameSize.Width && sz.Height <= frameSize.Height ) { iaImage.CopyTo(dst); } Size newSize = ComputeScalePreservingSize(iaImage.GetSize(), frameSize); CvInvoke.Resize(src, dst, newSize, 0, 0, interpolationMethod); } }
public FieldParameters(string filepath, string imagePath, string colors, int horizontalDistance, int horizontalSize, int verticalSize, int verticalDistance, int width, int height, Inter scalingMode, IColorComparison colorMode, Dithering ditherMode, IterationInformation iterationInformation) : base(filepath) { ColorPath = colors; HorizontalDistance = horizontalDistance; HorizontalSize = horizontalSize; VerticalSize = verticalSize; VerticalDistance = verticalDistance; Length = width; Height = height; PrimaryImageTreatment = new FieldReadout(this, imagePath, scalingMode); PrimaryCalculation = new FieldCalculation(colorMode, ditherMode, iterationInformation); HasProtocolDefinition = true; }
public void DeleteMonth(Employee[] logs) { try { if (logs is null || logs.Length <= 0) { throw new NullReferenceException("אין מידע למחיקה"); } else { Inter.DeleteMonth(logs); } }
public FieldParameters(int imageWidth, int imageHeight, Color background, string colors, int horizontalDistance, int horizontalSize, int verticalSize, int verticalDistance, int targetSize, Inter scalingMode, IColorComparison colorMode, Dithering ditherMode, IterationInformation iterationInformation) { ColorPath = colors; HorizontalDistance = horizontalDistance; HorizontalSize = horizontalSize; VerticalSize = verticalSize; VerticalDistance = verticalDistance; PrimaryImageTreatment = new FieldReadout(this, imageWidth, imageHeight, scalingMode); PrimaryImageTreatment.Background = background; TargetCount = targetSize; PrimaryCalculation = new FieldCalculation(colorMode, ditherMode, iterationInformation); HasProtocolDefinition = true; }
private static async Task TestInterception(Func <IInter, Inter, Task> test) { var interceptor = new TestInterceptor(); var inter = new Inter(); var gen = new ProxyGenerator(); var impl = (IInter)gen.CreateInterfaceProxyWithTargetInterface( typeof(IInter), new Type[0], inter, interceptor); await test(impl, inter); Assert.Equal(1, interceptor.Count); }
//Functions only applicable to the admin class // View other members accounts internal void ShowMember() { string Type = "View Balance of"; Console.CursorVisible = false; string Selection = ""; Console.Clear(); if (Users.Count == 1 && Users[0] == "Error") { Inter.Logger(false, Type, "-", 0, DateTime.Now, 0); Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\n\t\tUnable to procceed. Transaction failed.\n"); Console.ResetColor(); Console.Write("\nPlease try again later, press any key to continue..."); Console.ReadKey(); return; } ; Users.RemoveAll(x => x == Inter.UserName); string messa = "Please select the name of the user you would like to check"; while (Selection.Length == 0) { Selection = BuildMenu(Users, messa); } Tuple <DateTime, decimal> result = new Tuple <DateTime, decimal>(DateTime.Now, -1); result = Inter.GetBalance(Selection, true); Console.Clear(); if (result.Item2 == -1) { Console.ForegroundColor = ConsoleColor.Red; Console.Write("\n\t\tUnable to retrieve account balance. Transaction Failed.\n"); Console.ResetColor(); Console.Write("\nPress any key to continue..."); } else { Console.ForegroundColor = ConsoleColor.Green; Console.Write("\nAccount balance "); Console.ResetColor(); Console.Write($"for user: {Selection} on {DateTime.Now.ToString(Culture)} is {result.Item2.ToString("c", Culture)}\n\nPress any key to continue..."); } Console.ReadKey(); }
// ------- Interactions ------------ void SetFocus(Inter newFocus) { // If our focus has changed if (newFocus != focus) { // Defocus the old one if (focus != null) { focus.OnDefocused(); } focus = newFocus; // Set our new focus mover.Follow(newFocus); // Follow the new focus } newFocus.OnFocused(transform); }
public override bool Do() { ClearOut(); try { Inter InterEnum = (Inter)EnumPropertys["Inter"].Value; foreach (var src in Sources) { foreach (var outData in src.GetOut()) { Mat imgout = new Mat(); CvInvoke.Resize(outData.Image, imgout, new System.Drawing.Size(IntPropertys["Width"].Value, IntPropertys["Height"].Value), FloatPropertys["fx"].Value, FloatPropertys["fy"].Value, InterEnum); this.m_out.Add(new DataSrc(imgout, outData.Info, false)); } } } catch { return(false); } return(true); }
public override bool Do() { ClearOut(); try { Inter InterEnum = (Inter)EnumPropertys["Inter"].Value; foreach (var src in Sources) { foreach (var outData in src.GetOut()) { int w = (int)(outData.Image.Width * FloatPropertys["Scale"].Value); int h = (int)(outData.Image.Height * FloatPropertys["Scale"].Value); Mat imgout = new Mat(); CvInvoke.Resize(outData.Image, imgout, new System.Drawing.Size(w, h), 0, 0, InterEnum); this.m_out.Add(new DataSrc(imgout, outData.Info, false)); } } } catch { return(false); } return(true); }
public static Mat RescaleImage(Mat image, int width = 0, int height = 0, Inter interpolation = Inter.Area) { if (image == null) { return(null); } Mat tinyImage = new Mat(); System.Drawing.Size dim = new System.Drawing.Size(); float ratio; int w = image.Width; int h = image.Height; //If width and height equals zero ,return original image if (width <= 0 && height <= 0) { return(image); } if (width <= 0) { ratio = height / (float)h; dim.Width = (int)(w * ratio); dim.Height = height; } else { ratio = width / (float)h; dim.Width = width; dim.Height = (int)(h * ratio); } CvInvoke.Resize(image, tinyImage, dim, interpolation: interpolation); return(tinyImage); }
public void DeleteRow(Employee log) { try { if (log is null) { throw new NullReferenceException("לא נבחרה שורה"); } else { Inter.DeleteLog(log); Logs.ToList().Remove(log); emp.logs = Logs; OnPropertyChanged("Logs"); OnPropertyChanged("Emp"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public MooreInterface(Inter f) { inter = f; InitializeComponent(); }
// Withdraw from accounts internal void Withdraw() { string Type = "Withdraw from"; Index = 0; string with; decimal withdraw; decimal amount; string Selection = ""; Console.Clear(); Console.CursorVisible = false; Users.RemoveAll(x => x == Inter.UserName); if (Users.Count == 1 && Users[0] == "Error") { Inter.Logger(false, Type, "-", 0, DateTime.Now, 0); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\n\n\t\tUnable to perform this request. Transaction failed."); Console.ResetColor(); Console.WriteLine("\nPress any key to continue..."); Console.ReadKey(); return; } ; string messa = "Please select the name of the user you would like to withdraw from:"; while (Selection.Length == 0) { Selection = BuildMenu(Users, messa); } amount = Inter.GetBalance(Selection, false).Item2; if (amount == -1) { Inter.Logger(false, Type, "-", 0, DateTime.Now, 0); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\n\n\t\tUnable to perform this request. Transaction failed."); Console.ResetColor(); Console.WriteLine("\nPress any key to continue..."); Console.ReadKey(); return; } Console.TreatControlCAsInput = false; Console.WriteLine($"\nYou have selected: {Selection}"); Console.Write($"\nThe available founds at your disposal are {amount}\n"); Console.CursorVisible = true; Console.Write("\nNow enter the amount you would like to withdraw: "); with = Console.ReadLine(); bool chec = Decimal.TryParse(with, out withdraw); int n = 0; while (!chec || (withdraw > amount) || (withdraw <= 0)) { if (!chec) { n++; Console.ForegroundColor = ConsoleColor.Red; Console.Write("\nWarning: "); Console.ResetColor(); Console.Write("You did not enter a number.\n"); if (n == 3) { Console.ForegroundColor = ConsoleColor.Red; Console.Write("Three erroneous imputs. "); Console.ResetColor(); Console.Write("Returning to main menu.\nPress any key to continue..."); Console.ReadKey(); Console.CursorVisible = false; return; } else { Console.Write("You can stop this transaction by pressing "); Console.ForegroundColor = ConsoleColor.Red; Console.Write("q"); Console.ResetColor(); Console.Write(" or press any key to try again.\n"); } Console.CursorVisible = false; ConsoleKeyInfo key; key = Console.ReadKey(true); if (key.KeyChar == 'Q' || key.KeyChar == 'q') { return; } Console.CursorVisible = true; Console.Write("\nYou chose to try again.\nPlease enter the amount you would like to withdraw: "); with = Console.ReadLine(); chec = Decimal.TryParse(with, out withdraw); } if (withdraw > amount) { n++; Console.ForegroundColor = ConsoleColor.Red; Console.Write("\nWarning: "); Console.ResetColor(); Console.Write("You do not have sufficient founds to complete this transaction.\n"); if (n == 3) { Console.ForegroundColor = ConsoleColor.Red; Console.Write("Three erroneous imputs. "); Console.ResetColor(); Console.Write("Returning to main menu.\nPress any key to continue..."); Console.ReadKey(); Console.CursorVisible = false; return; } else { Console.Write("You can stop this transaction by pressing "); Console.ForegroundColor = ConsoleColor.Red; Console.Write("q"); Console.ResetColor(); Console.Write(" or press any key to try again.\n"); } Console.CursorVisible = false; ConsoleKeyInfo key; key = Console.ReadKey(true); if (key.KeyChar == 'Q' || key.KeyChar == 'q') { return; } Console.CursorVisible = true; Console.Write($"\nYou chose to try again.\nPlease try again using a different amount which must be less than {amount}: "); with = Console.ReadLine(); chec = Decimal.TryParse(with, out withdraw); } if (withdraw <= 0) { n++; Console.ForegroundColor = ConsoleColor.Red; Console.Write("\nWarning: "); Console.ResetColor(); Console.Write("You may not use zero or a negative number. \n"); if (n == 3) { Console.ForegroundColor = ConsoleColor.Red; Console.Write("Three erroneous imputs. "); Console.ResetColor(); Console.Write("Returning to main menu.\nPress any key to continue..."); Console.ReadKey(); Console.CursorVisible = false; return; } else { Console.Write("You can stop this transaction by pressing "); Console.ForegroundColor = ConsoleColor.Red; Console.Write("q"); Console.ResetColor(); Console.Write(" or press any key to try again.\n"); } Console.CursorVisible = false; ConsoleKeyInfo key; key = Console.ReadKey(true); if (key.KeyChar == 'Q' || key.KeyChar == 'q') { return; } Console.CursorVisible = true; Console.Write($"\nYou chose to try again.\nPlease try again using a different amount \nwhich must be less than {amount.ToString("c", Culture)}: "); with = Console.ReadLine(); chec = Decimal.TryParse(with, out withdraw); } } Tuple <bool, decimal, decimal, DateTime> success = Inter.Withdraw(Selection, withdraw); if (success.Item1) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Green; Console.Write("\n\t\tTransaction completed successfuly"); Console.ResetColor(); Console.Write(" on {0}.\n\t\t Your current balance is {1} ", success.Item4.ToString(Culture), success.Item3.ToString(Culture)); Console.Write("\n\nPress any key to continue..."); } else { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.Write("\n\t\tTransaction Failed"); Console.ResetColor(); Console.Write(" on {0}. \n\nPress any key to continue...", success.Item4.ToString(Culture)); } Console.CursorVisible = false; Console.ReadKey(); }
public static Mat Resize(this Mat mat, Size size, double fx = 0.0D, double fy = 0.0D, Inter interpolation = Inter.Linear) => mat.Modify(dst => CvInvoke.Resize(mat, dst, size, fx, fy, interpolation));
public MealyInterface(Inter f) { InitializeComponent(); inter = f; }
private void ProcessWhiskers() { bool time = false; //bool showOnce = true; //Get quarter size of image around nose point int newWidth = (int)(VideoWidth / ZoomRatio); int newHeight = (int)(VideoHeight / ZoomRatio); IWhiskerDetector whiskerDetector = ModelResolver.Resolve <IWhiskerDetector>(); //float scaleRatio = 4; //whiskerDetector.LineLength = 8*(int) scaleRatio; whiskerDetector.OrientationResolution = 1; //Dictionary<int, IWhiskerCollection> whiskers = new Dictionary<int, IWhiskerCollection>(); int newCount = HeadPoints.Count; int counter = 0; for (int i = 0; i < HeadPoints.Count; i++) { //Stopwatch sw = new Stopwatch(); ISingleFrameExtendedResults currentFrame = HeadPoints[i]; counter++; if (currentFrame == null) { //whiskers.Add(i, null); if (ProgressUpdates != null) { ProgressUpdates(this, new RBSKVideoUpdateEvent(0.5 + (((double)counter / newCount) / 2))); } continue; } if (currentFrame.HeadPoints == null) { //whiskers.Add(i, null); if (ProgressUpdates != null) { ProgressUpdates(this, new RBSKVideoUpdateEvent(0.5 + (((double)counter / newCount) / 2))); } continue; } if (currentFrame.BodyContour == null || !currentFrame.BodyContour.Any()) { //whiskers.Add(i, null); if (ProgressUpdates != null) { ProgressUpdates(this, new RBSKVideoUpdateEvent(0.5 + (((double)counter / newCount) / 2))); } continue; } //if (time) //{ // sw.Stop(); // Console.WriteLine("1) " + sw.ElapsedMilliseconds); // sw.Restart(); //} int x = (int)currentFrame.HeadPoints[2].X - (newWidth / 2); int y = (int)currentFrame.HeadPoints[2].Y - (newHeight / 2); int left = x + newWidth; int top = y + newHeight; if (x < 0) { x = 0; } if (y < 0) { y = 0; } if (left > VideoWidth) { left = VideoWidth; } if (top > VideoHeight) { top = VideoHeight; } Rectangle zoomRect = new Rectangle(x, y, left - x, top - y); //if (time) //{ // sw.Stop(); // Console.WriteLine("2) " + sw.ElapsedMilliseconds); // sw.Restart(); //} //Video.SetFrame(i); //if (time) //{ // sw.Stop(); // Console.WriteLine("3) " + sw.ElapsedMilliseconds); // sw.Restart(); //} Inter interpolationType = Inter.Area; //using (Image<Gray, byte> frame = Video.GetGrayFrameImage()) { Image.ROI = zoomRect; BackgroundImage.ROI = zoomRect; //if (time) //{ // sw.Stop(); // Console.WriteLine("4) " + sw.ElapsedMilliseconds); // sw.Restart(); //} using (Image <Gray, byte> subImage = Image.Copy()) using (Image <Gray, byte> subBinary = BackgroundImage.Copy()) using (Image <Gray, byte> zoomedImage = subImage.Resize(ScaleRatio, interpolationType)) using (Image <Gray, byte> zoomedBinary = subBinary.Resize(ScaleRatio, interpolationType)) { //if (time) //{ // sw.Stop(); // Console.WriteLine("5) " + sw.ElapsedMilliseconds); // sw.Restart(); //} //if (showOnce) //{ // ImageViewer.Show(zoomedImage); // ImageViewer.Show(zoomedBinary); // showOnce = false; //} PointF[] headPointsCorrected = new PointF[5]; int bodyContourLength = currentFrame.BodyContour.Length; Point[] bodyContourCorrected = new Point[bodyContourLength]; for (int j = 0; j < 5; j++) { headPointsCorrected[j] = new PointF((currentFrame.HeadPoints[j].X - zoomRect.X) * ScaleRatio, (currentFrame.HeadPoints[j].Y - zoomRect.Y) * ScaleRatio); } for (int j = 0; j < bodyContourLength; j++) { bodyContourCorrected[j] = new Point((int)((currentFrame.BodyContour[j].X - zoomRect.X) * ScaleRatio), (int)((currentFrame.BodyContour[j].Y - zoomRect.Y) * ScaleRatio)); } List <IWhiskerSegment>[] cWhisk = whiskerDetector.FindWhiskers(zoomedImage, zoomedBinary, headPointsCorrected, bodyContourCorrected, (int)ScaleRatio, currentFrame, null); List <IWhiskerSegment> cWhiskLeft = cWhisk[0]; List <IWhiskerSegment> cWhiskRight = cWhisk[1]; //if (time) //{ // sw.Stop(); // Console.WriteLine("6) " + sw.ElapsedMilliseconds); // sw.Restart(); //} //IWhiskerSegment[] correctedWhiskers = new IWhiskerSegment[cWhisk.Length]; foreach (var whisker in cWhiskLeft) { whisker.X = (int)((whisker.X / ScaleRatio) + zoomRect.X); whisker.Y = (int)((whisker.Y / ScaleRatio) + zoomRect.Y); Point p1 = new Point((int)((whisker.Line.P1.X / ScaleRatio)) + zoomRect.X, (int)((whisker.Line.P1.Y / ScaleRatio) + zoomRect.Y)); Point p2 = new Point((int)((whisker.Line.P2.X / ScaleRatio)) + zoomRect.X, (int)((whisker.Line.P2.Y / ScaleRatio) + zoomRect.Y)); whisker.Line = new LineSegment2D(p1, p2); } foreach (var whisker in cWhiskRight) { whisker.X = (int)((whisker.X / ScaleRatio) + zoomRect.X); whisker.Y = (int)((whisker.Y / ScaleRatio) + zoomRect.Y); Point p1 = new Point((int)((whisker.Line.P1.X / ScaleRatio)) + zoomRect.X, (int)((whisker.Line.P1.Y / ScaleRatio) + zoomRect.Y)); Point p2 = new Point((int)((whisker.Line.P2.X / ScaleRatio)) + zoomRect.X, (int)((whisker.Line.P2.Y / ScaleRatio) + zoomRect.Y)); whisker.Line = new LineSegment2D(p1, p2); } IWhiskerCollection whiskerCollection = ModelResolver.Resolve <IWhiskerCollection>(); whiskerCollection.LeftWhiskers = cWhiskLeft.ToArray(); whiskerCollection.RightWhiskers = cWhiskRight.ToArray(); currentFrame.AllWhiskers = whiskerCollection; //whiskers.Add(i, whiskerCollection); } } if (ProgressUpdates != null) { ProgressUpdates(this, new RBSKVideoUpdateEvent(0.5 + (((double)counter / newCount) / 2))); } //if (time) //{ // sw.Stop(); // Console.WriteLine("7) " + sw.ElapsedMilliseconds); // sw.Restart(); //} } //WhiskerResultsAll = whiskers; //PostProcessWhiskers(); //WhiskerResults = whiskers; }
public static void ToggleVisibility() => Inter.OnMouseVisChanged();
public override void Instantiate() { p = new Inter(ExtendedMethods.Hit); p(i); }
public FieldParameters(string filepath, string imagePath, string colors, int horizontalDistance, int horizontalSize, int verticalSize, int verticalDistance, int targetSize, Inter scalingMode, IColorComparison colorMode, Dithering ditherMode, IterationInformation iterationInformation) : this(filepath, imagePath, colors, horizontalDistance, horizontalSize, verticalSize, verticalDistance, 1, 1, scalingMode, colorMode, ditherMode, iterationInformation) { TargetCount = targetSize; }
public Controller(Inter i) { inter = i; }
public static void Transform(this Mat src, double xScale, double yScale, double xTrans = 0, double yTrans = 0, Size dstSize = default, Inter interpolation = Inter.Linear) { //var dst = new Mat(src.Size, src.Depth, src.NumberOfChannels); using (var translateTransform = new Matrix <double>(2, 3) {
// GET: Products public ActionResult Index() { return(View(Inter.GetAllProducts())); }