C# Emgu CV中的纵向模式
我正在创建一个基于摄像头的winforms应用程序,其中我使用了EmguCV 我想在单击按钮时以纵向模式拍摄图像 我试过:C# Emgu CV中的纵向模式,c#,winforms,emgucv,C#,Winforms,Emgucv,我正在创建一个基于摄像头的winforms应用程序,其中我使用了EmguCV 我想在单击按钮时以纵向模式拍摄图像 我试过: cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 190); cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 250); 但是图像仍然保持在横向模式,只是尺寸从640x480降低到一
cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 190);
cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 250);
但是图像仍然保持在横向模式,只是尺寸从640x480
降低到一些176x130
但我想要纵向图像
有谁能告诉我如何处理这个问题吗
cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 190);
cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 250);
上面的代码您正在使用的代码只会更改图像(捕获帧)的大小,您无法获得所述的确切大小可能是因为保持了纵横比
现在进入纵向模式拍摄,In建议在拍摄后将当前帧旋转90度,然后重新调整大小以适合图像框
代码是这样的
public Form1()
{
InitializeComponent();
_capture = new Capture();
Application.Idle += ProcessFrame;
}
private void ProcessFrame(object sender, EventArgs arg)
{
Image<Bgr, Byte> currentFrame = _capture.QueryFrame();
currentFrame =currentFrame.Rotate(90,new Bgr(255,255,255),true);
// other code to the task you want to achieve like displaying in ImageBox etc.
}
public Form1()
{
初始化组件();
_捕获=新捕获();
Application.Idle+=ProcessFrame;
}
私有void ProcessFrame(对象发送方、事件args arg)
{
Image currentFrame=_capture.QueryFrame();
currentFrame=currentFrame.Rotate(90,新Bgr(255255),真);
//要实现的任务的其他代码,如在ImageBox中显示等。
}
检查官方文件