本文整理汇总了C#中Folder.TryGetTempDocument方法的典型用法代码示例。如果您正苦于以下问题:C# Folder.TryGetTempDocument方法的具体用法?C# Folder.TryGetTempDocument怎么用?C# Folder.TryGetTempDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder.TryGetTempDocument方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SolveCaptcha
/// <summary>
/// <para>Pulls the image</para>
/// <para>Runs the ocr on it</para>
/// <para>fills in the blanks</para>
/// <para>submits the page</para>
/// </summary>
/// <param name="challenge"></param>
/// <param name="cancellationToken"></param>
/// <param name="answer"></param>
/// <returns></returns>
private bool SolveCaptcha( Uri challenge, CancellationToken cancellationToken, out String answer ) {
answer = null;
var tesseractEngine = this.TesseractEngine;
if ( null == tesseractEngine ) {
return false;
}
var captchaData = this.PullCaptchaData( challenge );
if ( captchaData.ImageUri == null ) {
captchaData.Status = CaptchaStatus.NoImageFoundToBeSolved;
this.UpdateCaptchaData( captchaData );
return false;
}
Console.WriteLine( Resources.Uber_SolveCaptcha_Attempting_OCR_on__0_, captchaData.ImageUri.AbsolutePath );
captchaData.Status = CaptchaStatus.SolvingImage;
this.UpdateCaptchaData( captchaData );
var folder = new Folder( Path.GetTempPath() );
Document document;
folder.TryGetTempDocument( document: out document, extension: "png" );
this.PictureBoxChallenge.Image.Save( document.FullPathWithFileName, ImageFormat.Png );
var aforgeImage = AForge.Imaging.Image.FromFile( document.FullPathWithFileName );
var smoothing = new ConservativeSmoothing();
var cannyEdgeDetector = new CannyEdgeDetector();
cannyEdgeDetector.Apply( aforgeImage );
aforgeImage.Save( document.FullPathWithFileName, ImageFormat.Png );
this.PictureBoxChallenge.ImageLocation = document.FullPathWithFileName;
this.PictureBoxChallenge.Load();
this.Throttle( Seconds.Ten );
using ( var img = Pix.LoadFromFile( document.FullPathWithFileName ).Deskew() ) {
using ( var page = tesseractEngine.Process( img, PageSegMode.SingleLine ) ) {
answer = page.GetText();
var paragraph = new Paragraph( answer );
answer = new Sentence( paragraph.ToStrings( " " ) ).ToStrings( " " );
FluentTimers.Create( Minutes.One, () => document.Delete() ).AndStart();
if ( !String.IsNullOrWhiteSpace( answer ) ) {
captchaData.Status = CaptchaStatus.SolvedChallenge;
this.UpdateCaptchaData( captchaData );
return true;
}
return false;
}
}
}