Windows named pipe to VideoCapture

Ask question on using Emgu CV with C#
Post Reply
SB3NDER
Posts: 2
Joined: Mon Dec 23, 2019 5:36 am

Windows named pipe to VideoCapture

Post by SB3NDER » Mon Dec 23, 2019 5:42 am

I want to show a h264 video stream in C# with emgu CV. I send the stream from a raspberry pi with netcat, if I use netcat+vcl I can see the stream but not from the c# program (I'm new to emgu CV, started yesterday).

Code: Select all

        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) =>
        {
            image.Image = videoCapture.QueryFrame().Bitmap;
        });
        playerTimer.Start();
Exception thrown: 'Emgu.CV.Util.CvException' in Emgu.CV.World.dll

[ERROR:0] global D:\bb\cv_x86\build\opencv\modules\videoio\src\cap.cpp (122) cv::VideoCapture::open VIDEOIO(CV_IMAGES): raised unknown C++ exception!

Post Reply