错误消息:无法加载文件或程序集‘openalpr、Version=2.3.0.0、Culture=neutral、PublicKeyToken=null’或其依赖项之一。尝试加载格式不正确的程序。。
但是,当我按推荐行运行alpr.exe时,它没有任何问题。
这是我的代码:
private void CallAlpr()
{
var openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == true)
{
OpenAlpr.Output(openFileDialog.FileName);
}
Console.Read();
}OpenAlpr类:
using ......
using openalprnet;
using System.Drawing;
public static List<AlprPlateResultNet> RecognizePlate(string imagePath)
{
var alpr = new AlprNet("en", "/openalpr_64/openalpr.conf", "/openalpr_64/runtime_data");
if (!alpr.IsLoaded())
{
throw new Exception("OpenAlpr failed to load!");
}
alpr.DefaultRegion = "md";
var results = alpr.Recognize(imagePath);
return results?.Plates;
}
public static void Output(string imagePath)
{
var plates = RecognizePlate(imagePath);
var i = 0;
foreach (var result in plates)
{
Console.WriteLine("Plate {0}:{1} result(s)", i++, result.TopNPlates.Count);
Console.WriteLine(" Processing Time: {0} msec(s)", result.ProcessingTimeMs);
foreach (var plate in result.TopNPlates)
{
Console.WriteLine(" - {0}\t Confidence: {1}\tMatches Template: {2}",
plate.Characters, plate.OverallConfidence, plate.MatchesTemplate);
}
}
}我在我的项目文件夹下有一个文件夹: openalpr_64。
发布于 2017-01-17 03:23:57
通过将所有文件和文件夹从zip文件复制到Debug文件夹,并确保.config和runtime_data指向正确的路径,解决了这个问题。
发布于 2017-01-16 04:07:27
在我的经验中,我只在尝试使用C# all / .EXEs时看到了这条特定的消息,这些消息并不都是32位或64位的。
检查您的项目构建没有设置为“任何CPU”(默认为64位操作系统上的64位)。
至少,检查.EXE和库.DLL的32/64位。
祝好运!
https://stackoverflow.com/questions/41668305
复制相似问题