在 c# 中使用 Pinovke 使用 opencv 捕获视频
Capturing video with opencv using Pinovke in c#
我正在使用openCV用C#编写WindowsForm应用程序。我想从网络摄像头捕获视频并在窗口中显示它,我想使用 P/Invoke 来做到这一点,我得到了 c++ 代码,但我不知道如何在 c# 中做到这一点。
#include "opencv2/opencv.hpp"
using namespace cv;
int main(int, char**)
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
Mat edges;
namedWindow("edges",1);
for(;;)
{
Mat frame;
cap >> frame; // get a new frame from camera
cvtColor(frame, edges, COLOR_BGR2GRAY);
GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
Canny(edges, edges, 0, 30, 3);
imshow("edges", edges);
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}
我在 GitHub 中找到了一个链接,它将从图像人脸检测中检测人脸
与我想从网络摄像头捕获视频的方式完全相同。任何参考链接都会有所帮助。?
#region cameracapture
if (comboBox1.Text == "Capture From Camera")
{
try
{
_capture = null;
_capture = new Capture(0);
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS, 30);
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 240);
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 320);
Time_Label.Text = "Time: ";
Codec_lbl.Text = "Codec: ";
Frame_lbl.Text = "Frame: ";
webcam_frm_cnt = 0;
cam = 1;
Video_seek.Value = 0;
Application.Idle += ProcessFrame;
button1.Text = "Stop";
comboBox1.Enabled = false;
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
#endregion cameracapture
来源:代码项目
相关文章:
- 在macOS Mojave上尝试OpenCV视频捕获时"Abort Trap: 6"
- 当我使用RTSP摄像机流时,OpenCV视频贴中滞后
- 低FPS与OpenCV视频捕获
- OPENCV视频关注设备索引 /设备编号
- Opencv 视频帧.我只能看到最后一帧
- OpenCV视频捕获抓取和检索
- 如何将opencv视频发送到ffmpeg
- 如何在QT中有效显示OpenCV视频
- 由于捕获缓冲液,OpenCV视频贴滞后
- OpenCV视频阅读慢帧率
- OpenCV 视频处理在 iOS 中更换相机
- C/C++OpenCV视频处理
- opencv视频捕获默认设置
- OpenCV视频处理帧速率下降
- 如何:Android OpenCV视频捕获与文件
- 如何在opencv视频中添加圆圈/点
- OpenCV视频稳定算法
- opencv视频采集和虚拟机上的摄像头访问
- Opencv视频帧给我一个错误
- OpenCV视频模块教程