我一直在寻找一段时间以及所有我见过的OCR库请求.我想知道如何实现最纯净,易于安装和使用OCR库以及安装到C#项目的详细信息.
如果可行,我只想像通常的dll参考一样实现它...
例:
using org.pdfbox.pdmodel;
using org.pdfbox.util;
Run Code Online (Sandbox Code Playgroud)
还有一个小的OCR代码示例会很好,例如:
public string OCRFromBitmap(Bitmap Bmp)
{
Bmp.Save(temppath, System.Drawing.Imaging.ImageFormat.Tiff);
string OcrResult = Analyze(temppath);
File.Delete(temppath);
return OcrResult;
}
Run Code Online (Sandbox Code Playgroud)
所以请考虑我对OCR项目并不熟悉,并给我一个答案,比如和假人交谈.
编辑: 我猜人们误解了我的要求.我想知道如何将这些开源OCR库实现到C#项目以及如何使用它们.作为dup给出的链接没有给出我要求的答案.
我试图通过C#读出脚本并确定它们是否包含某些单词,但这些单词应该相同,而不是只包含我正在寻找的内容.有没有办法使用contains-function,单个单词,并检查它是否与确切的单词相同?
如何确定它是否包含且与搜索词相同?
目前我使用以下脚本:
// GetScriptAssetsOfType<MonoBehaviour>() Returns all monobehaviour scripts as text
foreach (MonoScript m in GetScriptAssetsOfType<MonoBehaviour>())
{
if (m.text.Contains("Material"))
{
// Identical check?
}
}
Run Code Online (Sandbox Code Playgroud) 我当时只在场景中工作,只有一些2d螺旋,最近添加了带有一个带有碰撞效果的子发射器的粒子系统。在工作并测试了几分钟之后,我总是收到此致命错误。我不知道为什么得到这个。我的笔记本电脑有16GB的RAM。Unity版本5.4.1f1 64位
错误:
无法分配内存:系统内存不足!
尝试分配:具有16个对齐方式的18446743951336546967B。
MemoryLabel:TempOverflow
分配发生在:行:C:/buildslave/unity/build/Runtime/Allocator/ThreadsafeLinearAllocator.cpp中的177
[ALLOC_DEFAULT]使用:40694528B | 峰值:0B | 保留:74448896B
[ALLOC_TEMP_JOB]使用:0B | 峰值:0B | 保留:2097152B
[ALLOC_GFX]使用:108085168B | 峰值:0B | 保留:119117128B
[ALLOC_CACHEOBJECTS]使用:332752B | 峰值:0B | 保留:10485760B
[ALLOC_TYPETREE]使用:493472B | 峰值:0B | 保留:17825792B
[ALLOC_PROFILER]使用:29600B | 峰值:0B | 保留:8388608B
[ALLOC_TEMP_THREAD]使用:31211B | 峰值:0B | 保留:55017472B
在Code Review.stackexchange上询问我的问题之后,我被建议使用以下代码片段.我注意到在传输过程中string [] Lines被设置为IEnumerable.
在查看IEnumerable函数之后,我没有找到任何暗示任何性能改进的东西.那么这只是为了可读性吗?或者使用IEnumerable而不是数组实际上存在性能差异或一般优势?
private void ProcessSingleItem(String fileName, String oldId, String newId)
{
string[] lines = File.ReadAllLines(fileName);
File.WriteAllText(fileName, ProcessLines(lines, oldId, newId));
}
private String ProcessLines(IEnumerable<String> lines, String oldId, String newId)
{
StringBuilder sb = new StringBuilder(2048);
foreach (String line in lines)
{
sb.AppendLine(line.Replace(oldId, newId));
}
return sb.ToString();
}
Run Code Online (Sandbox Code Playgroud) 我一直在寻找最后2个小时,而我实际上一直在寻找愚蠢的.
我试图读取Registry_binary值并将其转换为字符串.我尝试了一些我在网上找到的东西(包括一些stackoverflow帖子),但似乎我无法让它工作:
class Class1 {
RegistryKey RegKey;
String keys;
static void Main() {
Class1 c=new Class1();
c.initialize();
}
void initialize() {
RegKey=Registry.LocalMachine.OpenSubKey("the location", true);
var bytearray=Converter<RegKey.GetValue("key"), String[keys]>;
Console.WriteLine(bytearray);
System.Threading.Thread.Sleep(5000);
}
}
Run Code Online (Sandbox Code Playgroud)
我也试过用:
keys=keys+BitConverter.ToString(System.byte[RegKey.GetValue("key")]);
Run Code Online (Sandbox Code Playgroud)
根据要求:
RegKey=Registry.LocalMachine.OpenSubKey("Software\\MXstudios\\riseingtesharts", true);
keys=RegKey.GetValue("key");
Run Code Online (Sandbox Code Playgroud)
这将输出 System.Bytes[]
看了一下后,我来到了这个页面.在这里,我找到了一些代码来将C#字符串发送到PHP页面.
但是,在我自己的程序中实现它后,它不起作用.这是我的代码:
private void executesend()
{
using (WebClient client = new WebClient())
{
client.UploadString(url,"POST",keys);
}
}
Run Code Online (Sandbox Code Playgroud)
对于PHP部分,我有:
<?php
mysql_connect("localhost", "", "") or die(mysql_error()); // Connect to database server(localhost) with username and password.
mysql_select_db("dimittv89_dayz") or die(mysql_error()); // Select registration database.
$name = $_GET["message"];
if ( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
$name = file_get_contents('php://input');
$opdracht = "INSERT INTO 'keys', (`key`) VALUES ('$name')";
print $name;
}
if (mysql_query($opdracht)){
echo "succesfully registerd to the melloniax u wil now be returned to our …Run Code Online (Sandbox Code Playgroud) 今天我注意到我制作的一个小程序经常在程序生命周期的前10~20秒内触发GC.之后它再也几乎没有触发.

在这段时间内只运行一个函数,即下面的函数.获取~2k的文件路径,并过滤掉大部分文件路径.
public static string[] FilterFiles(string path)
{
// Fetch the files from given directory
var files = Directory.GetFiles(path);
// Delete all files that are to small
foreach (string file in files)
{
string fullFile = default(string);
try
{
fullFile = File.ReadAllText(file);
}
catch
{
continue;
}
if (fullFile.Length < Settings.MinimumFileSize)
{
File.Delete(file);
}
}
// Obtain the new list without the small files
List<string> cleanFiles = new List<string>(Directory.GetFiles(path));
List<string> cleanReturn = new List<string>(Directory.GetFiles(path));
// Remove files we have handled …Run Code Online (Sandbox Code Playgroud) 我做了一些C#程序,它获取了最新创建的文件.
例如它是一个D:\Directory1\file1.txt 文件
当它获取文件时,其文件的地址存储在某个变量中,如此字符串:
"D:\\Directory1\\file1.txt"
当您在调试中观察时,您可以看到此值.
FileInfo f1; // this is a latest created file "D:\Directory1\file1.txt"
string s1 = f1.FullName; // string value will be "D:\\Directory1\\file1.txt"
string s2 = SomeFunction(s1); // in order to get @"D:\Directory1\file1.txt" value
Run Code Online (Sandbox Code Playgroud)
如果将其值分配给不同的变量s2,那么您将再次获得相同的字符串值!
那么如何将此值赋给不同的变量以获得@"D:\ Directory1\file1.txt"值.
我应该使用StringBuilder类吗?
我应该使用String.Format吗?
还是非常感谢!
c# ×7
allocation ×1
contains ×1
fatal-error ×1
linq ×1
mysql ×1
ocr ×1
overflow ×1
performance ×1
php ×1
registrykey ×1
string ×1
tostring ×1
unity3d-gui ×1
unity5 ×1