我正在一个项目中,该项目需要使用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/