目的:输出两台摄像头图像和两路设备图像,每一路设备截图6张
主要知识:
1.通过SDK调取摄像头图像,并对图像进行剪裁;
2.WPF中定时器DispatcherTimer用法;
3.WPF中跨线程访问控件方法
Dispatcher.Invoke((Action)delegate{});
区别于winform中
this.Invoke((Action)delegate{});
4.xml操作:
XmlDocumentxmlDoc=newXmlDocument();xmlDoc.Load(AppDomain.CurrentDomain.BaseDirectory+"\\config.xml");XmlNodesettingNode=xmlDoc.DocumentElement;XmlElemente=settingNode.SelectSingleNode("DeviceType")asXmlElement;if(e==null){deviceType="tps";}else{deviceType=e.InnerText;}
5.带多个参数的委托
DP1=newDataProcess(DeviceIP1,LocalPort1,0);DP1.ShowEvent1=DrawControls1;DP1.Start();//启动线程
6.多线程操作
Threadt1=newThread(newThreadStart(DataRevThread));//开启DataRevThreadt1.Name="DataRevThread";//线程名字t1.Start();t1.IsBackground=true;//后台运行
7.UDP接收,解码;
8.emgucv使用;
9.工厂模式:
ModelFactoryMF=newModelFactory();DM=MF.CreateDataModelFactory_v1(sNeed.ToString());
10.信号量线程间同步
SemaphoreTaskSemaphoreData=newSemaphore(0,);//数据缓存队列缓存区TaskSemaphoreRev.WaitOne();//等待接收队列
11.Bitmap转换为ImageSource
[System.Runtime.InteropServices.DllImport("gdi32.dll")]publicstaticexternboolDeleteObject(IntPtrhObject);publicstaticImageSourceChangeBitmapToImageSource(Bitmapbitmap){IntPtrhBitmap=bitmap.GetHbitmap();ImageSourcewpfBitmap=System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap,IntPtr.Zero,Int32Rect.Empty,BitmapSizeOptions.FromEmptyOptions());if(!DeleteObject(hBitmap)){thrownewSystem.ComponentModel.Win32Exception();}returnwpfBitmap;}
12.Queue和list的操作
包括但是不限于以上内容
代码如下:
MainWindow.xaml:
Fluent:RibbonWindowx:Class="thzSoftware.MainWindow"xmlns="