-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Capturing Video
shimat edited this page Jan 19, 2019
·
2 revisions
public static void Main(string[] args)
{
VideoCapture capture = new VideoCapture(0);
using (Window window = new Window("Camera"))
using (Mat image = new Mat()) // Frame image buffer
{
// When the movie playback reaches end, Mat.data becomes NULL.
while (true)
{
capture.Read(image); // same as cvQueryFrame
if (image.Empty())break;
window.ShowImage(image);
Cv2.WaitKey(30);
}
}
}
// Opens MP4 file (ffmpeg is probably needed)
VideoCapture capture = new VideoCapture("aaa.mp4");
int sleepTime = (int) Math.Round(1000 / capture.Fps);
using (Window window = new Window("capture"))
using (Mat image = new Mat()) // Frame image buffer
{
// When the movie playback reaches end, Mat.data becomes NULL.
while (true)
{
capture.Read(image); // same as cvQueryFrame
if (image.Empty())
break;
window.ShowImage(image);
Cv2.WaitKey(sleepTime);
}
}