OpenCVsharp:直播
OpenCVsharp: Live streaming
我正在做一个需要使用 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);
}
}
}
}
我正在做一个需要使用 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);
}
}
}
}