public static void AddLiveTile(Category cat) { // Look to see whether the Tile already exists; if so, don't try to create it again. ShellTile tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("/Category/" + cat.CategoryID.ToString())); // Create the Tile if we didn't find that it already exists. if (tileToFind == null) { // Create an image for the category if there isnt one. if (cat.ImageURL == null || cat.ImageURL == String.Empty) { cat.ImageURL = ImageGrabber.GetDefaultImage(); } // Create the Tile object and set some initial properties for the Tile. StandardTileData newTileData = new StandardTileData { BackgroundImage = new Uri(cat.ImageURL, UriKind.RelativeOrAbsolute), Title = cat.CategoryTitle, Count = 0, BackTitle = cat.CategoryTitle, BackContent = "Read the latest in " + cat.CategoryTitle + "!", }; // Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application. ShellTile.Create(new Uri("/Category/" + cat.CategoryID, UriKind.Relative), newTileData); cat.IsPinned = true; App.DataBaseUtility.SaveChangesToDB(); } }
private void run() { using (ImageGrabber imageGrabber = new ImageGrabber(_info)) { imageGrabber.Bandwidth = 128000; ulong videoId = 0; int wait = 0; while (!_disposeEvent.Wait(wait)) { videoId = getNextVideoId(videoId); if (videoId != 0) { wait = 1; Image image = imageGrabber.GrabImage(videoId, _timeout); Image thumbnail = createThumbnail(image); if (image != null) { fireThumbnailEvent(videoId, thumbnail); } } else { wait = 1000; } } } }
public async Task GetHtmlTest() { var imageGrabber = new ImageGrabber(Substitute.For <ILog>()); var html = await imageGrabber.GetHtml("http://www.google.com"); Assert.IsNotNull(html); Assert.That(html, Does.Contain("google")); }
void Start() { serviceInterface = GetComponent <ServiceInterface>(); _imageGrabber = GetComponent <ImageGrabber>(); _popUpManager = GetComponent <PopUpManager>(); LoadingPanel.SetActive(false); DeviceCanvas.SetActive(false); LoggingCanvas.SetActive(true); }
public void VerifyFolderPathTest(string path) { try { ImageGrabber.CreatePath(path); } finally { Directory.Delete(path, true); } }
internal Image GetSnapshot() { var frame = _displayer.LastFrame; if (frame != null) { return(ImageGrabber.GetImageFromYv12Data(frame.Width, frame.Height, frame.Data)); } else { return(null); } }
public async Task FullTest(string url, string fileLocation, int expectedDownloadCount) { var imageGrabber = new ImageGrabber(Substitute.For <ILog>()); var dResults = await imageGrabber.DownloadAllImages(url, fileLocation); Assert.That(dResults, Is.Not.Null); Assert.That(dResults.Count(), Is.EqualTo(expectedDownloadCount)); var errors = string.Join("\n", dResults.Where(d => !d.WasSuccessful).Select(d => $"Request to {d.Url} failed with the following reason {d.ErrorReason}")); Assert.That(string.IsNullOrWhiteSpace(errors), Is.True, errors); Directory.Delete(fileLocation, true); }
public System.Drawing.Image GetSnapshot() { var frame = _lastFrame; if (frame != null) { return(ImageGrabber.GetImageFromYv12Data(frame.Width, frame.Height, frame.Data)); } else { return(null); } }
public HALCONDialog() { InitializeComponent(); width_ratio = halconWindow.Width / (float)Width; height_ratio = halconWindow.Height / (float)Height; buttonRun.Location = new Point(buttonRun.Location.X, halconWindow.Location.Y + halconWindow.Height + 10); buttonStop.Location = new Point(buttonStop.Location.X, halconWindow.Location.Y + halconWindow.Height + 10); HOperatorSet.GenCrossContourXld(out dummy, -10, -10, 5, 0); halconWindow.HalconWindow.SetColor("green"); halconWindow.HalconWindow.SetLineWidth(2); // Allow the shape model to be found when lying partly outside of the image HOperatorSet.SetSystem("border_shape_models", "true"); // the drawing object allows the user to dynamically select the ROI // and see how it affects to the resulting shape based model roi_object = new HDrawingObject(350.0, 400.0, 0.0, 200.0, 100.0); HImage img = new HImage("metal-parts/circle_plate_01"); HTuple width, height; img.GetImageSize(out width, out height); halconWindow.HalconWindow.SetPart(-1.0, -1.0, height - 1, width - 1); delayCheckBox.Checked = true; dummy_msg = new HMessage(); HOperatorSet.GenEmptyObj(out dummy); dummy_msg.SetMessageObj(dummy, "dummy"); // this example emulates the case where one continuously grabs images // in order to adapt the camera parameters so that the image processing // works properly. In this case, the framegrabber acquires the same image // continuously. createsbm = new ShapeModelDisplay("metal-parts/circle_plate_01", roi_object, this); createsbm.Start(); roi_object.OnAttach(DefineShapeBasedModel); roi_object.OnDrag(DefineShapeBasedModel); roi_object.OnResize(DefineShapeBasedModel); halconWindow.HalconWindow.AttachDrawingObjectToWindow(roi_object); halconWindow.HalconWindow.SetColor("green"); // initialize the chain of responsibility pattern findsbm = new ShapeModelFinder(this); imggrabber = new ImageGrabber("circle_plate.seq", findsbm); }
public void GetImageUrlsFromHtmlTest() { const string testHtml = @" <!DOCTYPE html> <html lang=""en""> <head> <meta http-equiv=""Content-type"" content=""text/html; charset=utf-8"" /> <link rel=""stylesheet"" type=""text/css"" href=""/css/style.css""> <link href='http://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'> <title>Scott Hanselman - Coder, Blogger, Teacher, Speaker, Author</title> </head> <body class=""line-darkbrown""> <section class=""containerOuter line-tan"" id=""topbar""> <section class=""containerInner""> <h1><a href=""/"">Scott Hanselman</a></h1> <nav> <ul> <li><a href=""http://hanselman.com/about"">about</a></li> <li><a href=""http://hanselman.com/blog"" >blog</a></li> <li><a href=""http://hanselman.com/speaking"">speaking</a></li> <li><a href=""http://hanselman.com/podcasts"">podcasts</a></li> <li><a href=""http://hanselman.com/books"">books</a></li> </ul> <ul class=""itemFeed""> <li><a href=""http://www.hanselminutes.com""><img src=""/images/blog-hanselminutes.png"" alt=""The Hanselminutes Podcast"" /></a></li> <li><a href=""http://thisdeveloperslife.com""><img src=""/images/blog-tdl.png"" alt=""This Developer's Life"" /></a></li> <li><a href=""http://www.ratchetandthegeek.com""><img src=""/images/blog-rachetgeek.png"" alt=""Rachet and the Geek"" /></a></li> <li><a href=""http://friday.azure.com""><img src=""/images/blog-AzureFriday.png"" alt=""Azure Friday"" /></a></li> </ul> </nav> </section> </section> </body> </html> "; var urls = ImageGrabber.GetImageUrlsFromHtml(testHtml); var expectedUrls = new[] { "/images/blog-hanselminutes.png", "/images/blog-tdl.png", "/images/blog-rachetgeek.png", "/images/blog-AzureFriday.png" }; CollectionAssert.AreEquivalent(expectedUrls, urls); }
public async Task DownloadTest() { CleanTestDirectory(); var imageGrabber = new ImageGrabber(Substitute.For <ILog>()); const string url = "http://www.hanselman.com/images/blog-hanselminutes.png"; const string outDirectory = @"C:\temp\ImageGrabber\Hansel"; var results = await imageGrabber.DownloadImages(new[] { url }, outDirectory); Assert.That(results.Count(), Is.EqualTo(1)); var downloadResult = results.First(); Assert.That(downloadResult.Url, Is.EqualTo(url)); Assert.That(downloadResult.FileLocation, Is.EqualTo(outDirectory + @"\blog-hanselminutes.png")); Assert.That(downloadResult.FileSize, Is.EqualTo(1538)); Assert.That(File.Exists(downloadResult.FileLocation), Is.True); var fileInfo = new FileInfo(downloadResult.FileLocation); Assert.That(fileInfo.Length, Is.EqualTo(downloadResult.FileSize)); Directory.Delete(outDirectory, true); }
public void AssertArgumentExceptionThrownForBadUrl(string url) { var imageGrabber = new ImageGrabber(Substitute.For <ILog>()); Assert.ThrowsAsync <ArgumentException>(async() => await imageGrabber.DownloadAllImages(url, @"C:\temp\ImageGrabber")); }
public string CreateAbsoluteUrlTests(string baseUrl, string imgSrcUrl) { var imageGrabber = new ImageGrabber(Substitute.For <ILog>()); return(imageGrabber.CreateAbsoluteUrl(baseUrl, imgSrcUrl)); }
public void StopCapture() { if (_grabber != null) { _grabber.Stop(); _grabber = null; _hwnd = IntPtr.Zero; } }
public void StartCapture() { var hwndSource = PresentationSource.FromVisual(CameraImage) as HwndSource; if (hwndSource != null) { _hwnd = hwndSource.Handle; _grabber = new ImageGrabber(_hwnd.ToInt32()); _grabber.ImageCaptured += grabber_ImageCaptured; _grabber.Start(); } }
public bool TestUrl(string url) { return(ImageGrabber.CheckUrl(url)); }
private void RibbonWindow_SourceInitialized(object sender, EventArgs e) { var hwndSource = PresentationSource.FromVisual(camImg) as HwndSource; if (hwndSource != null) { hwnd = hwndSource.Handle; grabber = new ImageGrabber(hwnd.ToInt32()); grabber.ImageCaptured += GrabberImageCaptured; grabber.Start(); } }