Add new settings to OCR - Fixes #3712, #3601, #2848

This commit is contained in:
Luke Anderson 2018-11-15 11:40:54 +10:30
parent c628a22d9d
commit dad5b81096
12 changed files with 270 additions and 27 deletions

View file

@ -56,6 +56,7 @@ private void InitializeComponent()
// //
resources.ApplyResources(this.txtResult, "txtResult"); resources.ApplyResources(this.txtResult, "txtResult");
this.txtResult.Name = "txtResult"; this.txtResult.Name = "txtResult";
this.txtResult.ReadOnly = true;
// //
// lblResult // lblResult
// //

View file

@ -25,6 +25,7 @@
using ShareX.HelpersLib; using ShareX.HelpersLib;
using ShareX.UploadersLib.OtherServices; using ShareX.UploadersLib.OtherServices;
using ShareX.UploadersLib.Properties;
using System; using System;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -34,24 +35,28 @@ namespace ShareX.UploadersLib
{ {
public partial class OCRSpaceForm : Form public partial class OCRSpaceForm : Form
{ {
public OCRSpaceLanguages Language { get; set; } = OCRSpaceLanguages.eng; public OCRSpaceLanguages Language { get; set; }
public string Result { get; private set; } public string Result { get; private set; }
private Stream data; private Stream data;
private string filename; private string filename;
private OCROptions ocrOptions;
public OCRSpaceForm() public OCRSpaceForm(OCROptions ocrOptions)
{ {
InitializeComponent(); InitializeComponent();
Icon = ShareXResources.Icon; Icon = ShareXResources.Icon;
cbLanguages.Items.AddRange(Helpers.GetEnumDescriptions<OCRSpaceLanguages>()); cbLanguages.Items.AddRange(Helpers.GetEnumDescriptions<OCRSpaceLanguages>());
cbLanguages.SelectedIndex = (int)ocrOptions.DefaultLanguage;
Language = ocrOptions.DefaultLanguage;
txtResult.SupportSelectAll(); txtResult.SupportSelectAll();
} }
public OCRSpaceForm(Stream data, string filename) : this() public OCRSpaceForm(Stream data, string filename, OCROptions ocrOptions) : this(ocrOptions)
{ {
this.data = data; this.data = data;
this.filename = filename; this.filename = filename;
this.ocrOptions = ocrOptions;
} }
private async void OCRSpaceResultForm_Shown(object sender, EventArgs e) private async void OCRSpaceResultForm_Shown(object sender, EventArgs e)
@ -76,7 +81,7 @@ private void UpdateControls()
btnStartOCR.Visible = data != null && data.Length > 0 && !string.IsNullOrEmpty(filename); btnStartOCR.Visible = data != null && data.Length > 0 && !string.IsNullOrEmpty(filename);
} }
private async Task StartOCR(Stream stream, string filename) public async Task StartOCR(Stream stream, string filename)
{ {
if (stream != null && stream.Length > 0 && !string.IsNullOrEmpty(filename)) if (stream != null && stream.Length > 0 && !string.IsNullOrEmpty(filename))
{ {
@ -133,4 +138,10 @@ private void llGoogleTranslate_LinkClicked(object sender, LinkLabelLinkClickedEv
Close(); Close();
} }
} }
public class OCROptions
{
public OCRSpaceLanguages DefaultLanguage = OCRSpaceLanguages.eng;
public bool Silent = false;
}
} }

View file

@ -284,12 +284,6 @@ public int HotkeyRepeatLimit
#endregion Webpage Capture Form #endregion Webpage Capture Form
#region OCR Form
public OCRSpaceLanguages OCRLanguage = OCRSpaceLanguages.eng;
#endregion OCR Form
#region Actions toolbar #region Actions toolbar
public List<HotkeyType> ActionsToolbarList = new List<HotkeyType>() { HotkeyType.RectangleRegion, HotkeyType.PrintScreen, HotkeyType.ScreenRecorder, public List<HotkeyType> ActionsToolbarList = new List<HotkeyType>() { HotkeyType.RectangleRegion, HotkeyType.PrintScreen, HotkeyType.ScreenRecorder,

View file

@ -175,6 +175,10 @@ private void InitializeComponent()
this.cbScreenRecorderFixedDuration = new System.Windows.Forms.CheckBox(); this.cbScreenRecorderFixedDuration = new System.Windows.Forms.CheckBox();
this.nudGIFFPS = new System.Windows.Forms.NumericUpDown(); this.nudGIFFPS = new System.Windows.Forms.NumericUpDown();
this.lblGIFFPS = new System.Windows.Forms.Label(); this.lblGIFFPS = new System.Windows.Forms.Label();
this.tpOCR = new System.Windows.Forms.TabPage();
this.cbCaptureOCRSilent = new System.Windows.Forms.CheckBox();
this.lblOCRDefaultLanguage = new System.Windows.Forms.Label();
this.cbCaptureOCRDefaultLanguage = new System.Windows.Forms.ComboBox();
this.tpUpload = new System.Windows.Forms.TabPage(); this.tpUpload = new System.Windows.Forms.TabPage();
this.tcUpload = new System.Windows.Forms.TabControl(); this.tcUpload = new System.Windows.Forms.TabControl();
this.tpUploadMain = new System.Windows.Forms.TabPage(); this.tpUploadMain = new System.Windows.Forms.TabPage();
@ -279,6 +283,7 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.nudScreenRecorderDuration)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudScreenRecorderDuration)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudScreenRecorderStartDelay)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudScreenRecorderStartDelay)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudGIFFPS)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudGIFFPS)).BeginInit();
this.tpOCR.SuspendLayout();
this.tpUpload.SuspendLayout(); this.tpUpload.SuspendLayout();
this.tcUpload.SuspendLayout(); this.tcUpload.SuspendLayout();
this.tpUploadMain.SuspendLayout(); this.tpUploadMain.SuspendLayout();
@ -805,6 +810,7 @@ private void InitializeComponent()
this.tcCapture.Controls.Add(this.tpCaptureGeneral); this.tcCapture.Controls.Add(this.tpCaptureGeneral);
this.tcCapture.Controls.Add(this.tpRegionCapture); this.tcCapture.Controls.Add(this.tpRegionCapture);
this.tcCapture.Controls.Add(this.tpScreenRecorder); this.tcCapture.Controls.Add(this.tpScreenRecorder);
this.tcCapture.Controls.Add(this.tpOCR);
resources.ApplyResources(this.tcCapture, "tcCapture"); resources.ApplyResources(this.tcCapture, "tcCapture");
this.tcCapture.Name = "tcCapture"; this.tcCapture.Name = "tcCapture";
this.tcCapture.SelectedIndex = 0; this.tcCapture.SelectedIndex = 0;
@ -1576,6 +1582,35 @@ private void InitializeComponent()
resources.ApplyResources(this.lblGIFFPS, "lblGIFFPS"); resources.ApplyResources(this.lblGIFFPS, "lblGIFFPS");
this.lblGIFFPS.Name = "lblGIFFPS"; this.lblGIFFPS.Name = "lblGIFFPS";
// //
// tpOCR
//
this.tpOCR.Controls.Add(this.cbCaptureOCRSilent);
this.tpOCR.Controls.Add(this.lblOCRDefaultLanguage);
this.tpOCR.Controls.Add(this.cbCaptureOCRDefaultLanguage);
resources.ApplyResources(this.tpOCR, "tpOCR");
this.tpOCR.Name = "tpOCR";
this.tpOCR.UseVisualStyleBackColor = true;
//
// cbCaptureOCRSilent
//
resources.ApplyResources(this.cbCaptureOCRSilent, "cbCaptureOCRSilent");
this.cbCaptureOCRSilent.Name = "cbCaptureOCRSilent";
this.cbCaptureOCRSilent.UseVisualStyleBackColor = true;
this.cbCaptureOCRSilent.CheckedChanged += new System.EventHandler(this.cbCaptureOCRSilent_CheckedChanged);
//
// lblOCRDefaultLanguage
//
resources.ApplyResources(this.lblOCRDefaultLanguage, "lblOCRDefaultLanguage");
this.lblOCRDefaultLanguage.Name = "lblOCRDefaultLanguage";
//
// cbCaptureOCRDefaultLanguage
//
this.cbCaptureOCRDefaultLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbCaptureOCRDefaultLanguage.FormattingEnabled = true;
resources.ApplyResources(this.cbCaptureOCRDefaultLanguage, "cbCaptureOCRDefaultLanguage");
this.cbCaptureOCRDefaultLanguage.Name = "cbCaptureOCRDefaultLanguage";
this.cbCaptureOCRDefaultLanguage.SelectedIndexChanged += new System.EventHandler(this.cbCaptureOCRDefaultLanguage_SelectedIndexChanged);
//
// tpUpload // tpUpload
// //
this.tpUpload.BackColor = System.Drawing.SystemColors.Window; this.tpUpload.BackColor = System.Drawing.SystemColors.Window;
@ -2117,6 +2152,8 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.nudScreenRecorderDuration)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudScreenRecorderDuration)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudScreenRecorderStartDelay)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudScreenRecorderStartDelay)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudGIFFPS)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudGIFFPS)).EndInit();
this.tpOCR.ResumeLayout(false);
this.tpOCR.PerformLayout();
this.tpUpload.ResumeLayout(false); this.tpUpload.ResumeLayout(false);
this.tcUpload.ResumeLayout(false); this.tcUpload.ResumeLayout(false);
this.tpUploadMain.ResumeLayout(false); this.tpUploadMain.ResumeLayout(false);
@ -2354,5 +2391,9 @@ private void InitializeComponent()
private System.Windows.Forms.CheckBox cbScreenRecordConfirmAbort; private System.Windows.Forms.CheckBox cbScreenRecordConfirmAbort;
private System.Windows.Forms.CheckBox cbFileUploadReplaceProblematicCharacters; private System.Windows.Forms.CheckBox cbFileUploadReplaceProblematicCharacters;
private System.Windows.Forms.CheckBox cbScreenRecordTwoPassEncoding; private System.Windows.Forms.CheckBox cbScreenRecordTwoPassEncoding;
private System.Windows.Forms.TabPage tpOCR;
private System.Windows.Forms.Label lblOCRDefaultLanguage;
private System.Windows.Forms.ComboBox cbCaptureOCRDefaultLanguage;
private System.Windows.Forms.CheckBox cbCaptureOCRSilent;
} }
} }

View file

@ -28,6 +28,7 @@
using ShareX.Properties; using ShareX.Properties;
using ShareX.ScreenCaptureLib; using ShareX.ScreenCaptureLib;
using ShareX.UploadersLib; using ShareX.UploadersLib;
using ShareX.UploadersLib.OtherServices;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
@ -296,6 +297,17 @@ public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
#endregion Screen recorder #endregion Screen recorder
#region OCR
OCROptions ocrOptions = TaskSettings.CaptureSettings.OCROptions;
cbCaptureOCRDefaultLanguage.Items.AddRange(Helpers.GetEnumDescriptions<OCRSpaceLanguages>());
cbCaptureOCRDefaultLanguage.SelectedIndex = (int)ocrOptions.DefaultLanguage;
cbCaptureOCRSilent.Checked = ocrOptions.Silent;
#endregion
#endregion Capture #endregion Capture
#region Upload #region Upload
@ -1097,6 +1109,20 @@ private void cbScreenRecordConfirmAbort_CheckedChanged(object sender, EventArgs
#endregion Screen recorder #endregion Screen recorder
#region OCR
private void cbCaptureOCRDefaultLanguage_SelectedIndexChanged(object sender, EventArgs e)
{
TaskSettings.CaptureSettings.OCROptions.DefaultLanguage = (OCRSpaceLanguages)cbCaptureOCRDefaultLanguage.SelectedIndex;
}
private void cbCaptureOCRSilent_CheckedChanged(object sender, EventArgs e)
{
TaskSettings.CaptureSettings.OCROptions.Silent = cbCaptureOCRSilent.Checked;
}
#endregion
#endregion Capture #endregion Capture
#region Upload #region Upload

View file

@ -3780,6 +3780,114 @@
<data name="&gt;&gt;tpScreenRecorder.ZOrder" xml:space="preserve"> <data name="&gt;&gt;tpScreenRecorder.ZOrder" xml:space="preserve">
<value>2</value> <value>2</value>
</data> </data>
<data name="cbCaptureOCRSilent.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="cbCaptureOCRSilent.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="cbCaptureOCRSilent.Location" type="System.Drawing.Point, System.Drawing">
<value>11, 60</value>
</data>
<data name="cbCaptureOCRSilent.Size" type="System.Drawing.Size, System.Drawing">
<value>124, 17</value>
</data>
<data name="cbCaptureOCRSilent.TabIndex" type="System.Int32, mscorlib">
<value>14</value>
</data>
<data name="cbCaptureOCRSilent.Text" xml:space="preserve">
<value>Process OCR silently</value>
</data>
<data name="&gt;&gt;cbCaptureOCRSilent.Name" xml:space="preserve">
<value>cbCaptureOCRSilent</value>
</data>
<data name="&gt;&gt;cbCaptureOCRSilent.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cbCaptureOCRSilent.Parent" xml:space="preserve">
<value>tpOCR</value>
</data>
<data name="&gt;&gt;cbCaptureOCRSilent.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="lblOCRDefaultLanguage.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="lblOCRDefaultLanguage.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="lblOCRDefaultLanguage.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 8</value>
</data>
<data name="lblOCRDefaultLanguage.Size" type="System.Drawing.Size, System.Drawing">
<value>91, 13</value>
</data>
<data name="lblOCRDefaultLanguage.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="lblOCRDefaultLanguage.Text" xml:space="preserve">
<value>Default language:</value>
</data>
<data name="&gt;&gt;lblOCRDefaultLanguage.Name" xml:space="preserve">
<value>lblOCRDefaultLanguage</value>
</data>
<data name="&gt;&gt;lblOCRDefaultLanguage.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;lblOCRDefaultLanguage.Parent" xml:space="preserve">
<value>tpOCR</value>
</data>
<data name="&gt;&gt;lblOCRDefaultLanguage.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="cbCaptureOCRDefaultLanguage.Location" type="System.Drawing.Point, System.Drawing">
<value>11, 24</value>
</data>
<data name="cbCaptureOCRDefaultLanguage.Size" type="System.Drawing.Size, System.Drawing">
<value>152, 21</value>
</data>
<data name="cbCaptureOCRDefaultLanguage.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="&gt;&gt;cbCaptureOCRDefaultLanguage.Name" xml:space="preserve">
<value>cbCaptureOCRDefaultLanguage</value>
</data>
<data name="&gt;&gt;cbCaptureOCRDefaultLanguage.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cbCaptureOCRDefaultLanguage.Parent" xml:space="preserve">
<value>tpOCR</value>
</data>
<data name="&gt;&gt;cbCaptureOCRDefaultLanguage.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="tpOCR.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 22</value>
</data>
<data name="tpOCR.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 3</value>
</data>
<data name="tpOCR.Size" type="System.Drawing.Size, System.Drawing">
<value>557, 447</value>
</data>
<data name="tpOCR.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="tpOCR.Text" xml:space="preserve">
<value>OCR</value>
</data>
<data name="&gt;&gt;tpOCR.Name" xml:space="preserve">
<value>tpOCR</value>
</data>
<data name="&gt;&gt;tpOCR.Type" xml:space="preserve">
<value>System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;tpOCR.Parent" xml:space="preserve">
<value>tcCapture</value>
</data>
<data name="&gt;&gt;tpOCR.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="tcCapture.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms"> <data name="tcCapture.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value> <value>Fill</value>
</data> </data>

View file

@ -1905,6 +1905,33 @@ public class Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to The OCR output has been copied to your clipboard..
/// </summary>
public static string OCRForm_AutoComplete {
get {
return ResourceManager.GetString("OCRForm_AutoComplete", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Error occurred during OCR processing, or no text was returned..
/// </summary>
public static string OCRForm_AutoCompleteFail {
get {
return ResourceManager.GetString("OCRForm_AutoCompleteFail", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to OCR is processing..
/// </summary>
public static string OCRForm_AutoProcessing {
get {
return ResourceManager.GetString("OCRForm_AutoProcessing", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>

View file

@ -985,4 +985,13 @@ Middle click to close</value>
<data name="AboutForm_AboutForm_Language_es_MX" xml:space="preserve"> <data name="AboutForm_AboutForm_Language_es_MX" xml:space="preserve">
<value>Mexican Spanish</value> <value>Mexican Spanish</value>
</data> </data>
<data name="OCRForm_AutoComplete" xml:space="preserve">
<value>The OCR output has been copied to your clipboard.</value>
</data>
<data name="OCRForm_AutoCompleteFail" xml:space="preserve">
<value>Error occurred during OCR processing, or no text was returned.</value>
</data>
<data name="OCRForm_AutoProcessing" xml:space="preserve">
<value>OCR is processing.</value>
</data>
</root> </root>

View file

@ -31,6 +31,7 @@
using ShareX.Properties; using ShareX.Properties;
using ShareX.ScreenCaptureLib; using ShareX.ScreenCaptureLib;
using ShareX.UploadersLib; using ShareX.UploadersLib;
using ShareX.UploadersLib.OtherServices;
using ShareX.UploadersLib.SharingServices; using ShareX.UploadersLib.SharingServices;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -1106,52 +1107,70 @@ public static void OpenRuler(TaskSettings taskSettings = null)
RegionCaptureTasks.ShowScreenRuler(taskSettings.CaptureSettings.SurfaceOptions); RegionCaptureTasks.ShowScreenRuler(taskSettings.CaptureSettings.SurfaceOptions);
} }
public static void SearchImage(string url)
{
new GoogleImageSearchSharingService().CreateSharer(null, null).ShareURL(url);
}
public static void OCRImage(TaskSettings taskSettings = null) public static void OCRImage(TaskSettings taskSettings = null)
{ {
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings(); if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
using (Image img = RegionCaptureTasks.GetRegionImage(taskSettings.CaptureSettings.SurfaceOptions)) using (Image img = RegionCaptureTasks.GetRegionImage(taskSettings.CaptureSettings.SurfaceOptions))
{ {
OCRImage(img); OCRImage(img, taskSettings);
} }
} }
public static void OCRImage(Image img) public static void OCRImage(Image img, TaskSettings taskSettings = null)
{ {
if (img != null) if (img != null)
{ {
using (Stream stream = SaveImageAsStream(img, EImageFormat.PNG)) using (Stream stream = SaveImageAsStream(img, EImageFormat.PNG))
{ {
OCRImage(stream, "ShareX.png"); OCRImage(stream, "ShareX.png", taskSettings);
} }
} }
} }
public static void SearchImage(string url) public static void OCRImage(string filePath, TaskSettings taskSettings = null)
{
new GoogleImageSearchSharingService().CreateSharer(null, null).ShareURL(url);
}
public static void OCRImage(string filePath)
{ {
if (File.Exists(filePath)) if (File.Exists(filePath))
{ {
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
{ {
OCRImage(fs, Path.GetFileName(filePath), filePath); OCRImage(fs, Path.GetFileName(filePath), taskSettings, filePath);
} }
} }
} }
public static void OCRImage(Stream stream, string fileName, string filePath = null) public static void OCRImage(Stream stream, string fileName, TaskSettings taskSettings = null, string filePath = null)
{ {
if (stream != null) if (stream != null)
{ {
using (OCRSpaceForm form = new OCRSpaceForm(stream, fileName)) if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
OCROptions ocrOptions = taskSettings.CaptureSettings.OCROptions;
using (OCRSpaceForm form = new OCRSpaceForm(stream, fileName, ocrOptions))
{ {
form.Language = Program.Settings.OCRLanguage; if (ocrOptions.Silent)
form.ShowDialog(); {
Program.Settings.OCRLanguage = form.Language; Program.MainForm.niTray.ShowBalloonTip(3000, "ShareX", Resources.OCRForm_AutoProcessing, ToolTipIcon.Info);
Task.Run(() => form.StartOCR(stream, fileName)).Wait();
if (!string.IsNullOrEmpty(form.Result)) {
ClipboardHelpers.CopyText(form.Result);
Program.MainForm.niTray.ShowBalloonTip(3000, "ShareX", Resources.OCRForm_AutoComplete, ToolTipIcon.Info);
}
else
{
Program.MainForm.niTray.ShowBalloonTip(3000, "ShareX", Resources.OCRForm_AutoCompleteFail, ToolTipIcon.Warning);
}
}
else
{
form.ShowDialog();
}
if (!string.IsNullOrEmpty(form.Result) && !string.IsNullOrEmpty(filePath)) if (!string.IsNullOrEmpty(form.Result) && !string.IsNullOrEmpty(filePath))
{ {

View file

@ -30,6 +30,7 @@
using ShareX.MediaLib; using ShareX.MediaLib;
using ShareX.ScreenCaptureLib; using ShareX.ScreenCaptureLib;
using ShareX.UploadersLib; using ShareX.UploadersLib;
using ShareX.UploadersLib.OtherServices;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -358,6 +359,12 @@ public class TaskSettingsCapture
public ScrollingCaptureOptions ScrollingCaptureOptions = new ScrollingCaptureOptions(); public ScrollingCaptureOptions ScrollingCaptureOptions = new ScrollingCaptureOptions();
#endregion Capture / Scrolling capture #endregion Capture / Scrolling capture
#region Capture / OCR
public OCROptions OCROptions = new OCROptions();
#endregion
} }
public class TaskSettingsUpload public class TaskSettingsUpload

View file

@ -364,7 +364,7 @@ public void ShowQRCode()
public void OCRImage() public void OCRImage()
{ {
if (IsItemSelected && SelectedItem.IsImageFile) TaskHelpers.OCRImage(SelectedItem.Info.FilePath); if (IsItemSelected && SelectedItem.IsImageFile) TaskHelpers.OCRImage(SelectedItem.Info.FilePath, Program.DefaultTaskSettings);
} }
public void CombineImages() public void CombineImages()

View file

@ -1009,7 +1009,7 @@ private void DoOCR()
{ {
if (Data != null && Info.DataType == EDataType.Image) if (Data != null && Info.DataType == EDataType.Image)
{ {
TaskHelpers.OCRImage(Data, Info.FileName, Info.FilePath); TaskHelpers.OCRImage(Data, Info.FileName, Info.TaskSettings, Info.FilePath);
} }
} }