Reputation: 169
I'm trying to build a C#.NET application from the source code of a solution provided here.
I've already added a reference to AForge.Video.FFMPEG.dll, but I am still getting the following error:
Error 2 The type or namespace name 'ImageEntitiesContainer' could not be found (are you missing a using directive or an assembly reference?) C:\WorkSpace\Visual Studio 2013\Projects\CSharp\ImagesToVideo\Program.cs 56 40 ImagesToVideo
I searched for this error and found a few posts, but nothing that helps. I tried changing the target framework from my default ".NET Framework 4.5" to some other frameworks: ".NET Framework 2.0", ".NET Framework 3.0", ".NET Framework 4.0", but without any success. Does anyone have any idea why I am still getting this error?
Here is my full source code:
using AForge.Video.FFMPEG;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AForge.Video.FFMPEG
{
public class MovieMaker
{
public void Start()
{
var startDate = DateTime.Parse("12 Mar 2012");
var endDate = DateTime.Parse("13 Aug 2012");
CreateMovie(startDate, endDate);
}
/*THIS CODE BLOCK IS COPIED*/
public Bitmap ToBitmap(byte[] byteArrayIn)
{
var ms = new System.IO.MemoryStream(byteArrayIn);
var returnImage = System.Drawing.Image.FromStream(ms);
var bitmap = new System.Drawing.Bitmap(returnImage);
return bitmap;
}
public Bitmap ReduceBitmap(Bitmap original, int reducedWidth, int reducedHeight)
{
var reduced = new Bitmap(reducedWidth, reducedHeight);
using (var dc = Graphics.FromImage(reduced))
{
// you might want to change properties like
dc.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
dc.DrawImage(original, new Rectangle(0, 0, reducedWidth, reducedHeight), new Rectangle(0, 0, original.Width, original.Height), GraphicsUnit.Pixel);
}
return reduced;
}
/*END OF COPIED CODE BLOCK*/
private void CreateMovie(DateTime startDate, DateTime endDate)
{
int width = 320;
int height = 240;
var framRate = 200;
using (var container = new ImageEntitiesContainer())
{
//a LINQ-query for getting the desired images
var query = from d in container.ImageSet
where d.Date >= startDate && d.Date <= endDate
select d;
// create instance of video writer
using (var vFWriter = new VideoFileWriter())
{
// create new video file
vFWriter.Open("nameOfMyVideoFile.avi", width, height, framRate, VideoCodec.Raw);
var imageEntities = query.ToList();
//loop throught all images in the collection
foreach (var imageEntity in imageEntities)
{
//what's the current image data?
var imageByteArray = imageEntity.Data;
var bmp = ToBitmap(imageByteArray);
var bmpReduced = ReduceBitmap(bmp, width, height);
vFWriter.WriteVideoFrame(bmpReduced);
}
vFWriter.Close();
}
}
}
}
}
Upvotes: 1
Views: 3651
Reputation: 1587
The ImageEntitiesContainer is not a class but a Data Source.You can figure it out in the LINQ-query code:
using (var container = new ImageEntitiesContainer())
{
//a LINQ-query for getting the desired images
var query = from d in container.ImageSet
where d.Date >= startDate && d.Date <= endDate
select d;
ImageEntitiesContainer is the ADO.Net Entity Data Model which you have to create it by yourself.
ImageSet is a table in ImageEntitiesContainer.
The picture was captured from the link you provided:
Upvotes: 2