c# - OpenCVsharp:实时流式传输

标签 c# .net opencv video-streaming wowza

我正在一个项目中,该项目需要使用RTSP或RTMP流式传输到wowza流式传输服务器。我知道如何捕捉视频。我尝试使用CvVideoWrier。但这并没有真正起作用。

CvCapture cap = CvCapture.FromCamera(0);
            cap.SetCaptureProperty(CaptureProperty.FrameHeight, pictureBox1.Height);
            cap.SetCaptureProperty(CaptureProperty.FrameWidth, pictureBox1.Width);
            while (true)
            {
                IplImage img = cap.QueryFrame();
                Bitmap bm = BitmapConverter.ToBitmap(img);
                bm.SetResolution(pictureBox1.Width, pictureBox1.Height);
                pictureBox1.Image = bm;

                img = null;
                bm = null;
            }

这是我到目前为止所做的。请帮助我。.我在这一点上停留了超过2天。

最佳答案

using System;
using OpenCvSharp;

namespace EdgeDetect
{
    class Template
    {
        public Template()
        {
            CvCapture cap = CvCapture.FromCamera(1);
            CvWindow w = new CvWindow("Template Matching");

            IplImage tpl = Cv.LoadImage("speedlimit55.jpg", LoadMode.Color);

            CvPoint minloc, maxloc;

            double minval, maxval;

            while (CvWindow.WaitKey(10) < 0)
            {
                IplImage img = cap.QueryFrame();
                IplImage res = Cv.CreateImage(Cv.Size(img.Width - tpl.Width + 1, img.Height - tpl.Height + 1), BitDepth.F32, 1);
                Cv.MatchTemplate(img, tpl, res, MatchTemplateMethod.CCoeff);
                Cv.MinMaxLoc(res, out minval, out maxval, out minloc, out maxloc, null);
                Cv.Rectangle(img, Cv.Point(minloc.X, minloc.Y), Cv.Point(minloc.X + tpl.Width, minloc.Y + tpl.Height), CvColor.Red, 1, 0, 0);
                w.Image = img;
                Cv.ReleaseImage(res);
                Cv.ReleaseImage(img);
            }
        }
    }
}

关于c# - OpenCVsharp:实时流式传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30167201/

相关文章:

c# - 使用 protobuf-net 序列化基类属性

opencv - 使用OpenCV重建3D对象

c# - 强制所有 ASP.NET 缓存过期

c# - RouteConfig 设置接受可选参数

c# - 将 Eval 的值从 int 转换为 string

c - 如何从图像的直方图中过滤感兴趣的对象?

java - JAVA (Android) 中的 OpenCV 绘制轮廓

c# - 无法将返回值类型的方法分配给 Func<dynamic>

c# - 什么时候int?和 Nullable<int> 是相同的,为什么它们的行为方式不同?

.net - 相互通知模式