机器视觉定位源码_第1页
机器视觉定位源码_第2页
机器视觉定位源码_第3页
机器视觉定位源码_第4页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、机器视觉 - 定位识别源码 (完全基于几何算法的定位 , 精度高、速度快、识别能力及抗干扰能力强 引用地址:注册会员下载VB,VC实现源码,其中对图片的处理代码) ." menu item to system menu.ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX < 0xF000);CMenu* pSysMenu = GetSystemMenu(FALSE);if (pSysMenu != NULL)CString strAboutMenu;(IDS_ABOUTBOX);if (!(

2、) pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);The framework does this automaticallyFor MFC applications using the document/view model,void CKMDVisionDemoDlg:OnPaint()if (IsIconic()CPaintDC dc(this); HCURSOR CKMDVisionDemoDlg:OnQueryDragIcon()

3、 return (HCURSOR) m_hIcon;void CKMDVisionDemoDlg:OnDisplayreal()mp)|*.bmp");CFileDialog opendlg(TRUE, NULL, NULL,OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, sFilter, this); if( ()=IDOK )PathName2 = ();ShowImage();OpenModImg(50);void CKMDVisionDemoDlg:OnSetmodelarea()mp)|*.bmp");CFileDialog opend

4、lg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, sFilter, this); if( ()=IDOK )PathName2 = ();ShowImage();OpenSearchImg(50);void CKMDVisionDemoDlg:OnSetsearcharea()+=().y;=+ =+if(!(TopLeft) && (BottomRight)InvalidateRect(&rectStaticClient, false);if (pt) != )if (&m_ViewWnd,

5、pt)STopLeft= SBottomRight= +=().x;+=().y;=+ =+ if(!(STopLeft) &&(SBottomRight)InvalidateRect(&rectStaticClient, false);CDialog:OnLButtonDown(nFlags, point);void CKMDVisionDemoDlg:DrawResult(float x,float y,int Width,int Height)CDC* pDC;pDC=();CPen NewPen(PS_SOLID,2,0x0000ff);pDC->Sele

6、ctObject(&NewPen);pDC->MoveTo(int)x,(int)y+10);pDC->LineTo(int)x,(int)y-10);pDC->MoveTo(int)x+10,(int)y);pDC->LineTo(int)x-10,(int)y);pDC->MoveTo(int)(x-(Width-8)/2),(int)(y-(Height-8)/2);pDC->LineTo(int)(x-(Width-8)/2),(int)(y+(Height-8)/2);pDC->MoveTo(int)(x-(Width-8)/2),(

7、int)(y-(Height-8)/2);pDC->LineTo(int)(x+(Width-8)/2),(int)(y-(Height-8)/2);pDC->MoveTo(int)(x+(Width-8)/2),(int)(y+(Height-8)/2);pDC->LineTo(int)(x+(Width-8)/2),(int)(y-(Height-8)/2);pDC->MoveTo(int)(x+(Width-8)/2),(int)(y+(Height-8)/2);pDC->LineTo(int)(x-(Width-8)/2),(int)(y+(Height-

8、8)/2); pDC->SelectStockObject(BLACK_PEN);ReleaseDC(pDC);void CKMDVisionDemoDlg:OnChangeScore()UpdateData(TRUE);SetMinScores(m_Score);void CKMDVisionDemoDlg:OnChangeZoomsedit()UpdateData(TRUE); SetMinScales(m_DownZoom);void CKMDVisionDemoDlg:OnChangeZoombedit()UpdateData(TRUE);SetMaxScales(m_UpZoo

9、m);void CKMDVisionDemoDlg:OnChangePyrlevel()UpdateData(TRUE);SetpyramidLevels(m_PyrLevel);void CKMDVisionDemoDlg:OnChangeMatchnum()UpdateData(TRUE);SetSearchNums(m_MatchNum);void CKMDVisionDemoDlg:OnOK()gbBlue = (BYTE)i; m_pBmpInfo->bmiColorsi.rgbGreen = (BYTE)i; m_pBmpInfo->bmiColorsi.rgbRed

10、= (BYTE)i; m_pBmpInfo->bmiColorsi.rgbReserved = 0;/*=Initial video parameter =*/void CKMDVisionDemoDlg:initImageParam()memset(&m_CapInfo, 0, sizeof(CapInfoStruct);= m_pRawData;= 640;= 480;= 0;= 0;= 100;0 =17;1 =9;2 = 0;15;= 0; memset, 0, 8); 0 = 2;1void CKMDVisionDemoDlg:initcamera()int nInde

11、x=0;ULONG i=0;int rt = MV_Usb2Init("MVC-F", &nIndex, &m_CapInfo, &m_hMVC1000); if(ResSuccess != rt)AfxMessageBox("Can not open USB camera! "); MV_Usb2Uninit(&m_hMVC1000); m_hMVC1000 = NULL;return;MV_Usb2SetOpMode(m_hMVC1000, 0, FALSE);MV_Usb2SetRawCallBack( m_hMVC

12、1000, RawCallBack, this );void CKMDVisionDemoDlg:Start() MV_Usb2StartCapture(m_hMVC1000,TRUE);void CKMDVisionDemoDlg:Stop() MV_Usb2StartCapture(m_hMVC1000,FALSE);int CKMDVisionDemoDlg:SaveRawAsBmp( CapInfoStruct *pCapInfo, LPCTSTR szFileName )BITMAPINFOHEADER FrameBmi;MakeBmpInfoHeader( pCapInfo, (B

13、ITMAPINFO*)(&FrameBmi) ); DWORD dwRowLength = 4 * ( * 8 + 31)/32 );DWORD dwFrameSize= dwRowLength * ;FILE *fp; BITMAPFILEHEADER pf; fp = fopen( szFileName, "wb" ); if (fp = NULL) return -1;= 0x4d42;= sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD) + dwFrameS

14、ize;= 0;= 0;= sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);fwrite( &pf, sizeof(BYTE), sizeof(BITMAPFILEHEADER), fp );RGBQUAD *pPallete = (RGBQUAD*)new BYTE 256 * sizeof(RGBQUAD); for(int i=0 ; i<256; i+)pPalletei.rgbRed = (BYTE)i; pPalletei.rgbBlue = (BYTE)i; pP

15、alletei.rgbGreen = (BYTE)i; pPalletei.rgbReserved = (BYTE)0;fwrite( &FrameBmi,sizeof(BYTE), sizeof(BITMAPINFOHEADER), fp ); fwrite( pPallete,sizeof(BYTE), 256*sizeof(RGBQUAD),fp );fwrite( pCapInfo->Buffer, sizeof(BYTE), dwFrameSize, fp ); delete pPallete;fclose(fp);return 0;int CKMDVisionDemo

16、Dlg:MakeBmpInfoHeader(CapInfoStruct *pCapInfo, BITMAPINFO *pBmpInfo)UCHAR btScale = ( pCapInfo->Control & 0x18 ); int nScaleMode;switch( btScale )case 0:nScaleMode = 1; break;case 8:nScaleMode = 4; break;case 16:nScaleMode = 8; break;case 24:nScaleMode = 2; break;default:nScaleMode = 1;break; pCapInfo->Width /= nScaleMode; pCapInfo->Height /= nScaleMode; pBmpInfo-> = sizeof(BITMAPINFOHEADER);pBmpInfo-> =pBmpInfo->pBmpInfo->= 1;= BI_RGB; = 0;pBmpInfo->pBmpInfo->= 0;= 0;pBmpInfo-> pBmpInfo-> pBmpInfo-> return 0;= 8;pB

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论