首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >OpenCVsharp:现场直播

OpenCVsharp:现场直播
EN

Stack Overflow用户
提问于 2015-05-11 12:04:49
回答 1查看 2.1K关注 0票数 1

我正在进行一个项目,它需要使用RTSP或RTMP向wowza流服务器流。我知道怎么拍录像。我试过使用CvVideoWrier。但这没什么用。

代码语言:javascript
运行
复制
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;
            }

这就是我到现在为止所做的。请帮帮我..。我在这点上被困了超过两天。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-25 13:27:35

代码语言:javascript
运行
复制
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);
            }
        }
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30167201

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档