总体目标是做个一个各类图像预处理的合集,方便自己理解函数。首先第一个问题就是图像获取,原先一直用Afroge的摄像头获取(理由是能看到设备名称),但这次反正是自己用,就直接Emgucv用了。
还是无力吐槽,好端端的Capture改什么VideoCapture。
private void OpenCapture_Click(object sender, EventArgs e)
{
if (cap != null)
{
if (isProcess)
{
Application.Idle -= new EventHandler(ProcessFram);
OpenCapture.Text = "结束";
}
else
{
Application.Idle += new EventHandler(ProcessFram);
OpenCapture.Text = "开始";
}
isProcess = !isProcess;
}
else
{
try
{
capID= Convert.ToInt32(this.comboBox1.Text);
cap = new Emgu.CV.VideoCapture(capID);
string resolution_ratio = this.comboBox2.Text; //我搞了个分辨率设置1920*1080
if (resolution_ratio != null)
{
tempNum1 = Convert.ToInt32(resolution_ratio.Split('*')[0]);
tempNum2 = Convert.ToInt32(resolution_ratio.Split('*')[1]);
}
cap.SetCaptureProperty(CapProp.FrameHeight, tempNum2);
cap.SetCaptureProperty(CapProp.FrameWidth, tempNum1);
}
catch (NullReferenceException expt)
{
MessageBox.Show(expt.Message);
}
}
//this.imageList2.ImageSize = new Size(tempNum1, tempNum2);
}
接着是另一个无力吐槽的listview,若不加个判断,总会出错。
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
this.imageBox1.Image = null;
if (listView1.SelectedItems.Count == 0) return;
else
{
ListView.SelectedIndexCollection tempNum = listView1.SelectedIndices;
this.imageBox1.Image = new Image<Bgr, byte>(imageList2[tempNum[0]]);
}
}
初开博客,目的是交流与合作,本人QQ:273651820。