【发布时间】:2019-12-21 17:59:29
【问题描述】:
我想用 emguCV 在 C# 中显示一个 h264 视频流。我使用 netcat 从 raspberry pi 发送流,如果我使用 netcat+vcl 我可以看到流,但不能从 c# 程序中看到(我是 emgucv 的新手)。
NamedPipeServerStream ncatPipe = new NamedPipeServerStream(
"ncatPipe",
PipeDirection.InOut,
NamedPipeServerStream.MaxAllowedServerInstances,
PipeTransmissionMode.Message,
PipeOptions.None,
1024,
1024
);
Process ncat = new Process();
ncat.StartInfo.FileName = "CMD.exe";
ncat.StartInfo.Arguments = "/C ncat -v -l 5000 >\\\\.\\pipe\\ncatPipe 2>nul";
ncat.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
ncat.Start();
ncatPipe.WaitForConnection();
VideoCapture videoCapture = new VideoCapture("\\\\.\\pipe\\ncatPipe");
videoCapture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FourCC, VideoWriter.Fourcc('h', '2', '6', '4'));
videoCapture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps, 60);
videoCapture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight, 480);
videoCapture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth, 640);
Timer playerTimer = new Timer();
playerTimer.Interval = 1000 / 60;
playerTimer.Tick += new EventHandler((object sender1, EventArgs e1) =>
{
Bitmap captureBmp = videoCapture.QueryFrame().Bitmap;
if (captureBmp != null)
{
picture.Image = captureBmp;
}
else
{
picture.Image = null;
playerTimer.Stop();
ncatPipe.Disconnect();
ncatPipe.Dispose();
ncat.Kill();
ncat.Dispose();
videoCapture.Dispose();
}
});
playerTimer.Start();
抛出异常:Emgu.CV.World.dll 中的“Emgu.CV.Util.CvException”
[ERROR:0] 全局 D:\bb\cv_x86\build\opencv\modules\videoio\src\cap.cpp (122) cv::VideoCapture::open VIDEOIO(CV_IMAGES): 引发未知 C++ 例外!
编辑 1:现在我正在尝试使用 FFMPEG 从管道中获取位图帧。
编辑 2:FFMPEG 有效,但我的延迟约为 4000 毫秒。
【问题讨论】:
标签: c# windows pipe emgucv named-pipes