In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to use the camera to read and save video in C#+EmguCV". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use the camera to read and save video in C#+EmguCV" can help you solve the problem.
The VideoCapture class is needed to call the camera in Emgucv
This class can be overloaded in four ways
1. If the parameters are not written, the default camera will be called during initialization.
2. A number of int type, which means the index of the camera. The camera will be initialized according to the index.
3. A string that means file name or video stream name. Initialization reads a video file or video stream
4. Enumeration of CaptureType
There are a lot of contents in this enumeration, so I won't repeat it here.
Create a new console application to read and save the video, as follows
Class Program {static void Main (string [] args) {show ();} private static void show () {/ / VideoCapture cap = new VideoCapture ("AVSEQ02.avi"); / / VideoCapture cap = new VideoCapture (CaptureType.Any); VideoCapture cap = new VideoCapture () VideoWriter writer = new VideoWriter ("save.avi", 20, new Size (640,480), true); if (! cap.IsOpened) {Console.WriteLine ("Open failure"); return;} Mat mat = new Mat () While (true) {cap.Read (mat); if (mat.IsEmpty) {Console.WriteLine (read finished); break;} CvInvoke.Imshow ("video", mat); writer.Write (mat) CvInvoke.WaitKey (30);} CvInvoke.WaitKey (0);}}
Here, VideoCapture's Read () method is used to read each frame of the video. Save it in the object Mat. And CvInvoke.Imshow () out. Then the Write method of VideoWriter is used to save the image of each frame into a video.
One thing to note here is that you need to stay in the loop for 30 milliseconds, otherwise the video will not be displayed. CvInvoke.WaitKey (30)
After running the program, you can see that the video read by the camera has been saved.
This is the end of the content about "how to use the camera to read and save video in C#+EmguCV". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.