一些遗传算法框架,例如http://www.aforgenet.com/需要许多参数,例如突变率,种群大小等
这些参数有通用的最佳数字吗?我认为这取决于问题(适应度函数延迟,突变延迟,重组延迟,进化速率等).我的第一个想法是使用GA来配置另一个GA.
有更好的想法吗?
大家.我已经被困在这里处理这些错误了好几天,但我仍然无法弄明白.我的猜测:我认为我的代码存在一些问题,因为我在使用它之后没有正确处理对象,(我不太熟悉释放资源,线程的这些概念).我通过参考人们在youtube上做了什么来获得这些代码,但是尽管我做了完全相同的事情,但我的代码并没有很好地解决.
情况:我有两个图片框,左边一个可以拍摄我的视频,右边一个拍摄快照,如果你按下button1,你将启动视频,clone_button将复制一个图像,即拍摄快照,save_image应该将它保存到但是,当我试图保存它时,我在GDI +中反复出现一般错误.此外,我的调试器似乎变得疯狂(即无法终止vshost.exe)一旦我运行此程序,我必须重新启动计算机以使我的代码再次运行,这是令人沮丧和令人沮丧的.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;
//AForge.Video dll
using AForge.Video;
using AForge.Video.DirectShow;
using AForge.Imaging;
using AForge.Imaging.Filters;
using AForge;
namespace WebCameraCapture
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private FilterInfoCollection CaptureDevice; // list of webcam
private VideoCaptureDevice FinalFrame;
private void Form1_Load(object sender, EventArgs e)
{
CaptureDevice = new FilterInfoCollection(FilterCategory.VideoInputDevice);//constructor
foreach (FilterInfo Device in CaptureDevice)
{
comboBox1.Items.Add(Device.Name);
}
comboBox1.SelectedIndex …Run Code Online (Sandbox Code Playgroud) 我正在尝试开发一个 WindowsForm 应用程序,它将使用网络摄像头来检测 QRCode 并解码消息。为此,我使用 AForge.NET 和 ZXing.NET。
到目前为止,我已经能够弄清楚如何从 URI 解码 QRCode,但我想从网络摄像头检测 QRCode,并对其进行解码。
以下是我的代码示例。
public String Decode(Uri uri)
{
Bitmap image;
try
{
image = (Bitmap)Bitmap.FromFile(uri.LocalPath);
}
catch (Exception ex)
{
throw new FileNotFoundException("Resource not found: " + uri);
}
using (image)
{
String text = "";
LuminanceSource source = new BitmapLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result = new MultiFormatReader().decode(bitmap);
if (result != null)
{
text = result.Text;
return text;
}
text = "Provided QR couldn't be …Run Code Online (Sandbox Code Playgroud) 在我之前的问题中,我改变了这个图像:
进入这个:
Tesseract OCR解释为:
1O351
Run Code Online (Sandbox Code Playgroud)
在图像周围放置一个框架
实际上改善了OCR结果.
1CB51
Run Code Online (Sandbox Code Playgroud)
但是,我需要正确地将所有5个字符都放到OCR中,所以作为一个实验,我使用Paint.NET旋转并将每个字母对齐到正确的方向:
得出正确答案:
1CB52
Run Code Online (Sandbox Code Playgroud)
我将如何在C#中执行此更正?
我已经对各种文本对齐算法做了一些研究,但它们都假设源图像中存在文本行,可以从中导出旋转角度的行,但是已经包含了正确的间距和方向关系.这些信.
我试图检测矩形内的矩形AForge.我已经成功确定Rectangles但无法找到circles内部Rectangle.如何找到另一个形状内的形状AForge.
string strPath = Server.MapPath("~/Recipt001.png");
Bitmap myBitmap = new Bitmap(strPath);
//Some filters Grayscale, invert, threshold
//Blod Filtering
BlobCounter blobCounter = new BlobCounter();
blobCounter.ProcessImage(temp);
blobCounter.ObjectsOrder = ObjectsOrder.YX;
blobCounter.FilterBlobs = true;
Blob[] blobs = blobCounter.GetObjectsInformation();
Graphics g = Graphics.FromImage(myBitmap);
Pen redPen = new Pen(Color.Red, 2);
SimpleShapeChecker shapeChecker = new SimpleShapeChecker();
// dictionary of color to highlight different shapes
Dictionary<PolygonSubType, Color> colors = new Dictionary<PolygonSubType, Color>();
colors.Add(PolygonSubType.Unknown, Color.White);
colors.Add(PolygonSubType.Trapezoid, Color.Orange);
colors.Add(PolygonSubType.Parallelogram, Color.Red);
colors.Add(PolygonSubType.Rectangle, …Run Code Online (Sandbox Code Playgroud) 我一直在尝试在 ASP.NET 中设置 MJPEG 流。我想从 URL 检索 MJEPG 流,并将我获得的每一帧发送到每个连接的客户端。我能够找到的示例只能从设置文件中读取,而不是从 URL 继续流,并通过MultiStreamContent发送整个文件。由于我逐帧检索,因此无法执行此操作。我想知道是否可以用 ASP.NET MVC 做我想做的事。我目前正在使用 AForge 视频从链接中检索 MJPEG 流。我的控制器类代码:
using System.Net.Http;
using System.Web.Http;
using AForge.Video;
namespace VideoPrototypeMVC.Controllers
{
public class CameraController : ApiController
{
int framecounter = 0;
MJPEGStream stream = new MJPEGStream();
[HttpGet]
public void GetVideoContent()
{
stream.Source = @"http://127.0.0.1:5002/stream";
stream.NewFrame += new NewFrameEventHandler(showFrame);
stream.Start();
MultipartContent content = new MultipartContent();
while (stream.IsRunning)
{
//Continues streaming should be here?
}
}
//Can be used to display of a frame …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法来识别 C# 中的图像是否模糊。我看到了这篇文章,但我没有看到适用于我的案例的方法。
我找到了AForge.dll将 FFT 应用于我的图像。我正在寻找一种简单的方法来确定图像是否模糊(我对数学不太熟悉)。
这是我的代码:
Bitmap Picture;
// I'm working with images sized between 130x130 and 150x150
Bitmap tmp = new Bitmap(pictureFile);
// Crop to be 128x128
Bitmap cropped = cropBitmap(tmp, 128, 128);
using (MemoryStream ms = new MemoryStream())
{
cropped.Save(ms, ImageFormat.Gif);
ms.Position = 0;
// Save in grayscale
Picture = new Bitmap(ms);
}
// Create the ComplexImage with AForge.dll
ComplexImage output = ComplexImage.FromBitmap(Picture);
// Apply FFT
output.ForwardFourierTransform();
Bitmap result = output.ToBitmap();
// to …Run Code Online (Sandbox Code Playgroud) 我有使用相机拍摄的图像。有时,图像中的光线不均匀。有一些深色阴影。这会导致EMGU以及Aforge处理OCR图像的最佳阈值设置错误。
这是我获得阈值后得到的:
我该如何校正照明?我尝试了自适应阈值,结果大致相同。也使用以下代码尝试了伽玛校正:
ImageAttributes attributes = new ImageAttributes();
attributes.SetGamma(10);
// Draw the image onto the new bitmap
// while applying the new gamma value.
System.Drawing.Point[] points =
{
new System.Drawing.Point(0, 0),
new System.Drawing.Point(image.Width, 0),
new System.Drawing.Point(0, image.Height),
};
Rectangle rect =
new Rectangle(0, 0, image.Width, image.Height);
// Make the result bitmap.
Bitmap bm = new Bitmap(image.Width, image.Height);
using (Graphics gr = Graphics.FromImage(bm))
{
gr.DrawImage(HSICONV.Bitmap, points, rect,
GraphicsUnit.Pixel, attributes);
}
Run Code Online (Sandbox Code Playgroud)
同样的结果。请帮忙。
更新:根据Nathancy的建议,我将他的代码转换为c#以进行不均匀的照明校正,并且它的工作原理是:
Image<Gray, byte> smoothedGrayFrame = grayImage.PyrDown();
smoothedGrayFrame = smoothedGrayFrame.PyrUp(); …Run Code Online (Sandbox Code Playgroud) 我收到以下错误:
ASP.NET 运行时错误:无法加载文件或程序集“AForge.Video.FFMPEG.DLL”或其依赖项之一。指定的模块无法找到。
我在一个 Windows 窗体项目中使用了此方法,但在尝试将该项目转换为 ASP.NET 项目后,我无法让它运行。我在那里使用 64 位 DLL,但现在已切换到使用 32 位 DLL,因为我似乎在这方面取得了更多进展(在 64 位 DLL 中遇到了类似的错误)。
我已在项目属性中将平台目标设置为 x86,并尝试将其设置为任何 CPU(这会触发警告,因为 DLL 是本机 32 位),并且还尝试在使用 64 位 DLL 时将目标更改为 x64。
在 IIS 应用程序池中,我将“启用 32 位应用程序”设置为 true。删除这一 DLL 会导致项目正常运行,而将其重新添加会导致项目失败。
我试过了:
该项目中甚至没有使用 DLL 的代码(我在 Windows 窗体项目中有代码,我打算将其合并到此项目中,但如果引用甚至不起作用,我就无法这样做)。我什至创建了新项目,以防项目中出现一些奇怪的人工制品。
请注意,我几乎阅读了与此 DLL 和 ASP.NET 相关的所有 Google 结果。这些方法似乎都不起作用。