我想用openCV制作电影。我可以把所有的图像放到AVI中,除非图像倾斜得很大,否则它的效果很好。看起来它已经在整个图像上被抹掉了。在openCV中倾斜的视频
框架是完全正方形的,所以它不能成为让高度和宽度感到困惑的问题。图像是24位。另一件奇怪的事情是,它发生时似乎并不一致。有时它看起来很棒,有时它会倾斜。
这里是从电影图像: http://dl.dropbox.com/u/63600049/MIP.avi
这里是代码:
PInvoke的方法
IntPtr _ptr = CvInvoke.cvCreateVideoWriter(AVIFilename, CvInvoke.CV_FOURCC('M', 'J', 'P', 'G'), 15, size, 1);
int count = 0;
for (int n = 1; n < Frames.Length; n++)
{
if (Frames[n].Trim().Length > 0)
{
try
{
FileInfo file = new FileInfo(Frames[n]);
IntPtr ptr = CvInvoke.cvLoadImage(file.FullName, Emgu.CV.CvEnum.LOAD_IMAGE_TYPE.CV_LOAD_IMAGE_ANYCOLOR | Emgu.CV.CvEnum.LOAD_IMAGE_TYPE.CV_LOAD_IMAGE_ANYDEPTH);
if (ptr == IntPtr.Zero)
throw new NullReferenceException(String.Format("Unable to load image from file \"{0}\".", file.FullName));
CvInvoke.cvWriteFrame(_ptr, ptr);
//VW.WriteFrame<Bgr, byte>(frame);
count++;
}
catch (Exception ex)
{
System.Diagnostics.Debug.Print(ex.Message);
}
}
}
CvInvoke.cvReleaseVideoWriter(ref _ptr);
EMGU版
public static void CreateAVIVideoEMGU(string AVIFilename, string[] Frames)
{
Bitmap bitmap = new Bitmap(Frames[0]);
VideoWriter VW = null;
VW = new VideoWriter(AVIFilename, CvInvoke.CV_FOURCC('M', 'J', 'P', 'G'), 15, bitmap.Height, bitmap.Width, true);
int count = 0;
for (int n = 1; n < Frames.Length; n++)
{
if (Frames[n].Trim().Length > 0)
{
var frame = new Emgu.CV.Image<Bgr, byte>(ConvertBitmapTo24(new Bitmap (Frames[n])));
VW.WriteFrame<Bgr, byte>(frame);
count++;
}
}
VW.Dispose();
}
的图像是所有24个具有相同尺寸的位jpg
你正在使用什么OpenCV版本,以及这是什么操作系统? (Win/Linux/Mac) – karlphillip 2012-03-28 22:26:29
它是EMGU 2.3 64位版本(c#openCV 2.0的封装)。我正在使用Windows 7机器。 – ochensati 2012-03-28 22:58:09
你可以发布“涂抹”图片的图片吗? – mevatron 2012-03-29 00:38:11