像许多人似乎已经拥有(这里有几个主题)我正在寻找从一系列图像创建视频的方法.
我想在C#中实现我的功能!
这是我不想做的事情:
/*Pseudo code*/
void CreateVideo(List<Image> imageSequence, long durationOfEachImageMs, string outputVideoFileName, string outputFormat)
{
// Info: imageSequence.Count will be > 30 000 images
// Info: durationOfEachImageMs will be < 300 ms
if (outputFormat = "mpeg")
{
}
else if (outputFormat = "avi")
{
}
else
{
}
//Save video file do disk
}
Run Code Online (Sandbox Code Playgroud)
我知道有一个名为Splicer的项目(http://splicer.codeplex.com/)但我找不到合适的文档或明确的例子我可以遵循(这些是我发现的例子).
我想在CodePlex上找到的最接近的是: 如何在C#中的图像目录中创建视频?
我还阅读了一些关于ffmpeg的线程(例如:C#和FFmpeg最好没有shell命令?这个:使用ffmpeg转换图像序列)但我发现没有人帮我解决我的问题而且我不认为ffmpeg -命令行样式对我来说是最好的解决方案(因为图像数量).
我相信我可以用某种方式使用Splicer -project(?).
在我的情况下,它大约是> 30 000张图像,其中每张图像应显示约200毫秒(在我想要创建的视频流中).
(视频是关于什么的?植物生长......)
谁能帮我完成我的功能?
我正在开发一种自动增强扫描35毫米幻灯片的程序.我正在寻找一种增强对比度和消除色偏的好算法.该算法必须是完全自动的,因为将有数千个图像要处理.这些是直接来自扫描仪的几个样本图像,仅针对网络裁剪和缩小尺寸:


我正在使用AForge.NET库,并尝试了HistogramEqualization和ContrastStretch过滤器.HistogramEqualization有利于最大化局部对比度但总体上不会产生令人满意的结果.ContrastStretch更好,但由于它单独拉伸每个色带的直方图,它有时会产生强烈的色偏:

为了减少颜色偏移,我UniformContrastStretch自己使用ImageStatistics和LevelsLinear类创建了一个过滤器.这对所有色带使用相同的范围,以较低的对比度为代价保留色彩.
ImageStatistics stats = new ImageStatistics(image);
int min = Math.Min(Math.Min(stats.Red.Min, stats.Green.Min), stats.Blue.Min);
int max = Math.Max(Math.Max(stats.Red.Max, stats.Green.Max), stats.Blue.Max);
LevelsLinear levelsLinear = new LevelsLinear();
levelsLinear.Input = new IntRange(min, max);
Bitmap stretched = levelsLinear.Apply(image);
Run Code Online (Sandbox Code Playgroud)

虽然图像仍然很蓝,所以我创建了一个ColorCorrection首先计算图像平均亮度的滤镜.然后为每个颜色通道计算伽马校正值,使得每个颜色通道的平均值将等于平均亮度.均匀对比度拉伸图像具有平均值R=70 G=64 B=93,平均亮度为(70 + 64 + 93) / 3 = 76.计算伽玛值R=1.09 G=1.18 B=0.80,得到的非常中性的图像具有R=76 G=76 B=76预期的平均值:

现在,解决真正的问题...我想将图像的平均颜色校正为灰色有点过于剧烈,会使一些图像在外观上显得相当沉闷,就像第二个样本(第一个图像是均匀拉伸的,接下来是相同的图像颜色校正):

在照片编辑程序中手动执行色彩校正的一种方法是对已知中性色(白色/灰色/黑色)的颜色进行采样,并将图像的其余部分调整为该颜色.但由于这个例程必须是完全自动的,所以这不是一个选择.
我想我可以为我的ColorCorrection滤镜添加强度设置,因此强度为0.5会将平均值的一半移动到平均亮度.但另一方面,一些图像可能会做得最好,没有任何颜色校正.
有什么想法可以获得更好的算法吗?或者某些方法来检测图像是否有偏色或者只是有很多颜色,比如第二个样本?
我想检测和裁剪照片出来的是空白页,在使用AForge未知的随机位置,文章下面这里
我从谷歌图片下载了一张护照照片,然后卡在白纸上:
AForge完成了工作,然而,有一个我无法弄清楚的问题; 照片被裁剪错了.
以下是处理后裁剪照片的外观:
你注意到照片的白边吗?好像照片倾斜,两侧留下空白区域.
不仅AForge不承认这张照片的四边形是一个矩形,但它也错了.
这是我从文章中获取并调整裁剪的代码:
Bitmap bitmap = AForge.Imaging.Image.Clone(bmp, PixelFormat.Format24bppRgb);
BitmapData bitmapData = bitmap.LockBits(
new Rectangle(0, 0, bitmap.Width, bitmap.Height),
ImageLockMode.ReadWrite, bitmap.PixelFormat);
Invert invertFilter = new Invert();
invertFilter.ApplyInPlace(bitmapData);
BlobCounter blobCounter = new BlobCounter();
blobCounter.FilterBlobs = true;
blobCounter.MinHeight = 50;
blobCounter.MinWidth = 50;
blobCounter.MaxHeight = 1500;
blobCounter.MaxWidth = 1500;
blobCounter.ProcessImage(bitmapData);
Blob[] blobs = blobCounter.GetObjectsInformation();
bitmap.UnlockBits(bitmapData);
if (blobs.Length == 1)
{
List<IntPoint> corners;
List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blobs[0]);
SimpleShapeChecker shapeChecker = new SimpleShapeChecker();
if (shapeChecker.IsConvexPolygon(edgePoints, out corners))
{
if (corners.Count …Run Code Online (Sandbox Code Playgroud) 我正在尝试为一些测试自动化工作开发图像聚焦算法.我选择使用AForge.net,因为它看起来像一个很好的成熟.net友好系统.
不幸的是,我似乎无法从头开始找到有关构建自动对焦算法的信息,所以我给了它最好的尝试:
拍照.应用sobel边缘检测滤波器,生成灰度边缘轮廓.生成直方图并保存标准开发.将相机移近主体一步并拍摄另一张照片.如果标准开发小于前一个,我们将获得更多关注.否则,我们已经超过拍摄照片的最佳距离.
有没有更好的办法?
更新:顺便说一下,这有很大的缺陷.当我超越最佳焦点时,我的"焦点图像"价值继续增长.你期望一个抛物线函数看距离/焦点值,但实际上你会得到一些更对数的东西
更新2:好的,所以我回到了这个,我们正在探索的当前方法给出了一些已知的边缘(好吧,所以我确切地知道图片中的对象是什么),我做了一个手动像素强度比较.随着结果图变得越来越陡峭,我得到了更多关注.一旦核心算法从matlab移植到c#(是的,matlab ..:S),我就会发布代码
更新3:yay最终更新.再次回到这里.最终的代码如下所示:
第1步:从图像列表中获取图像(我通过聚焦点拍摄了一百张照片)
第2步:找到我正在聚焦的物体的边缘(在我的情况下,它是一个总是在同一个地方的矩形物体,所以我裁剪出一个边缘的HIGH和NARROW矩形)
第3步:获取该裁剪图像的HorizontalIntensityStatistics(Aforge.net类).
第4步:获取直方图(灰色,在我的情况下)
步骤5:找到直方图值的导数
第6步:当你的坡度最大时,就是你处于最关注点的时候.
我即将开始一个视觉图像处理项目,没有Matlab,Aforge,OpenCV的经验,并且想知道是否有人对这些不同的软件包有任何经验.
我也想知道三个软件包中哪一个最有效率我假设OpenCV但是有没有人有过任何经验?
谢谢
杰米.
我想用相机拍摄网络摄像头.为此我使用了2个引用:AForge.Video.dll和AForge.Video.DirectShow.dll.
public FilterInfoCollection CamsCollection;
public VideoCaptureDevice Cam = null;
void Cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
frameholder.Source = (Bitmap)eventArgs.Frame.Clone();
/* ^
* Here it cannot convert implicitly from System.Drawing.Bitmap to
* System.Windows.Media.ImageSource
*/
}
private void startcam_Click(object sender, RoutedEventArgs e)
{
CamsCollection = new FilterInfoCollection(FilterCategory.VideoInputDevice);
Cam = new VideoCaptureDevice(CamsCollection[1].MonikerString);
Cam.NewFrame += new NewFrameEventHandler(Cam_NewFrame);
Cam.Start();
}
private void stopcam_Click(object sender, RoutedEventArgs e)
{
Cam.Stop();
}
Run Code Online (Sandbox Code Playgroud)
}
他们用a PictureBox来显示帧.当我在WPF工作时,我使用了它
总结一下这是我的代码目前的样子.
public FilterInfoCollection CamsCollection; …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个应用程序,它可以访问连接到PC的摄像机,录制视频并从视频中获取图像.我使用AForge.NET库来访问摄像头:http://www.aforgenet.com/framework/
我不知道名为AForge.Video.NewFrameEventHandler的事件是如何工作的.在此代码中,事件将null返回到位图而不是视频中的新帧,或者不调用该事件.我希望每次都能从视频中获取帧到一个图片框,以制作类似于视频流的内容,点击停止按钮后,我希望最后一个图像保持显示在图片框中.有谁知道怎么样?为什么我的代码不起作用?
码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AForge.Video.DirectShow;
using System.Drawing;
using AForge.Video;
namespace CameraDevice
{
public class CameraImaging
{
// enumerate video devices
public FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice );
//camera
public VideoCaptureDevice videoSource;
//screen shot
public Bitmap bitmap;
public CameraImaging()
{
// create video source
VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString );
// set NewFrame event handler
videoSource.NewFrame += new NewFrameEventHandler( video_NewFrame );
}
public void StartVideo(VideoCaptureDevice videoSource)
{
// start the video …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个解决谜题的应用程序(尝试开发图形算法),我不想一直手工输入样本输入.
编辑: 我不是想建立一个游戏.我正在尝试建立一个扮演游戏"SpellSeeker"的经纪人
假设我在屏幕上有一个图像(见附件),上面有数字,我知道这些框的位置,我有这些数字的确切图像.我想要做的只是告诉相应的盒子上有哪个图像(数字).
数字http://i46.tinypic.com/3089vyt.jpg
所以我想我需要实施
bool isImageInsideImage(Bitmap numberImage,Bitmap Portion_Of_ScreenCap) 或类似的东西.
我试过的是(使用AForge库)
public static bool Contains(this Bitmap template, Bitmap bmp)
{
const Int32 divisor = 4;
const Int32 epsilon = 10;
ExhaustiveTemplateMatching etm = new ExhaustiveTemplateMatching(0.9f);
TemplateMatch[] tm = etm.ProcessImage(
new ResizeNearestNeighbor(template.Width / divisor, template.Height / divisor).Apply(template),
new ResizeNearestNeighbor(bmp.Width / divisor, bmp.Height / divisor).Apply(bmp)
);
if (tm.Length == 1)
{
Rectangle tempRect = tm[0].Rectangle;
if (Math.Abs(bmp.Width / divisor - tempRect.Width) < epsilon
&&
Math.Abs(bmp.Height / divisor - tempRect.Height) …Run Code Online (Sandbox Code Playgroud) 我正在使用Aforge.net框架工作进行图像处理工作.我添加'AForge.Video.FFMPEG.dll'作为我的项目的参考.我正在使用VS2012和32位构建目标.当Buiding我得到
System.IO.FileNotFoundException was unhandled
HResult=-2147024770
Message=Could not load file or assembly 'AForge.Video.FFMPEG.dll' or one of its dependencies. The specified module could not be found.
Source=VideoReadere
FileName=AForge.Video.FFMPEG.dll
FusionLog=""
StackTrace:
at VideoReadere.Form1..ctor()
at VideoReadere.Program.Main() in c:\Users\Prabad\Documents\Visual Studio 2012\Projects\VideoReadere\VideoReadere\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at …Run Code Online (Sandbox Code Playgroud)