吉安高端網(wǎng)站建設(shè)公司網(wǎng)站怎么優(yōu)化排名的方法
平時(shí)不怎么玩游戲,有時(shí)消遣就玩玩QQ里的2D桌球,但是玩的次數(shù)少,不能像骨灰級(jí)玩家一樣百發(fā)百中,腫么辦呢?于是某天突發(fā)奇想,決定自己也來做個(gè)“外掛”。說是外掛,其實(shí)只是一個(gè)瞄準(zhǔn)器,畢竟外掛是修改別人的軟件,有點(diǎn)違法的意思,況且自己還沒有能力去那么做,所以自己還是弄個(gè)瞄準(zhǔn)器,做做弊,過下小癮,同時(shí)也提高一下自己的編程能力。
起初(也就是半年前),自己嘗試做一個(gè)瞄準(zhǔn)器的初始版本,用C#做,想法很簡(jiǎn)單:
Step1.把鼠標(biāo)移到洞口,獲取鼠標(biāo)位置;
Step2.將鼠標(biāo)放到要擊打的球的圓心上,獲取鼠標(biāo)當(dāng)前位置
Step3.根據(jù)進(jìn)球時(shí)三點(diǎn)共線的原則按照球的半徑自動(dòng)將鼠標(biāo)移動(dòng)到準(zhǔn)確的擊球點(diǎn)。
示意圖如下:
?
于是當(dāng)初就按照這個(gè)想法做了,開始給自己做了個(gè)C#版,調(diào)用Windows API中的GetDesktopWindow,GetWindowDC,SetCursorPos三個(gè)函數(shù),經(jīng)過簡(jiǎn)單的數(shù)學(xué)運(yùn)算,就基本實(shí)現(xiàn)了功能。代碼如下:
?
- using?System.Drawing;??
- using?System.Windows.Forms;??
- using?System.Windows;??
- using?System.Runtime.InteropServices;??
- using?System;??
- ??
- namespace?TaiqiuGua??
- {??
- ??
- ????public?partial?class?Form1?:?Form??
- ????{??
- ????????const?int?ra=25;??
- ????????[DllImport("user32.dll")]??
- ????????static?extern?IntPtr?GetDesktopWindow();??
- ????????[DllImport("user32.dll")]??
- ????????static?extern?IntPtr?GetWindowDC(IntPtr?hWnd);??
- ????????[DllImport("user32.dll")]??
- ????????static?extern?bool?SetCursorPos(int?X,?int?Y);??
- ??
- ????????public?Form1()??
- ????????{??
- ????????????InitializeComponent();??
- ????????}??
- ??
- ????????Point?startP;??
- ????????Point?endP;??
- ??????????
- ????????private?void?Form1_KeyDown(object?sender,?KeyEventArgs?e)??
- ????????{??
- ????????????switch(e.KeyData)??
- ????????????{??
- ????????????????case?Keys.F1:??
- ????????????????????startP=Control.MousePosition;??
- ????????????????????break;??
- ????????????????case?Keys.F2:??
- ????????????????????endP?=?Control.MousePosition;??
- ????????????????????break;??
- ????????????????case?Keys.D1:??
- ????????????????????int?x1?=?(int)(endP.X?+?ra?*?((endP.X?-?startP.X)?/?Math.Sqrt((endP.X?-?startP.X)?*?(endP.X?-?startP.X)?+?(endP.Y?-?startP.Y)?*?(endP.Y?-?startP.Y))));??
- ????????????????????int?y1?=?(int)(endP.Y?+?ra?*?((endP.Y?-?startP.Y)?/?Math.Sqrt((endP.X?-?startP.X)?*?(endP.X?-?startP.X)?+?(endP.Y?-?startP.Y)?*?(endP.Y?-?startP.Y))));??
- ????????????????????SetCursorPos(x1,?y1);??
- ????????????????????break;??
- ????????????????case?Keys.D2:??
- ????????????????????int?x2?=?(int)(endP.X?-?ra?*?((-endP.X?+?startP.X)?/?Math.Sqrt((-endP.X?+?startP.X)?*?(-endP.X?+?startP.X)?+?(endP.Y?-?startP.Y)?*?(endP.Y?-?startP.Y))));??
- ????????????????????int?y2?=?(int)(endP.Y?+?ra?*?((endP.Y?-?startP.Y)?/?Math.Sqrt((-endP.X?+?startP.X)?*?(-endP.X?+?startP.X)?+?(endP.Y?-?startP.Y)?*?(endP.Y?-?startP.Y))));??
- ????????????????????SetCursorPos(x2,?y2);??
- ????????????????????break;??
- ????????????????case?Keys.D3:??????????????????????
- ????????????????????int?x3?=?(int)(endP.X?+?ra?*?((endP.X?-?startP.X)?/?Math.Sqrt((endP.X?-?startP.X)?*?(endP.X?-?startP.X)?+?(-endP.Y?+?startP.Y)?*?(-endP.Y?+?startP.Y))));??
- ????????????????????int?y3?=?(int)(endP.Y?-?ra?*?((-endP.Y?+?startP.Y)?/?Math.Sqrt((endP.X?-?startP.X)?*?(endP.X?-?startP.X)?+?(-endP.Y?+?startP.Y)?*?(-endP.Y?+?startP.Y))));??
- ????????????????????SetCursorPos(x3,?y3);??
- ????????????????????break;??
- ????????????????case?Keys.D4:??
- ????????????????????int?x4?=?(int)(endP.X?-?ra?*?((-endP.X?+?startP.X)?/?Math.Sqrt((-endP.X?+?startP.X)?*?(-endP.X?+?startP.X)?+?(-endP.Y?+?startP.Y)?*?(-endP.Y?+?startP.Y))));??
- ????????????????????int?y4?=?(int)(endP.Y?-?ra?*?((-endP.Y?+?startP.Y)?/?Math.Sqrt((-endP.X?+?startP.X)?*?(-endP.X?+?startP.X)?+?(-endP.Y?+?startP.Y)?*?(-endP.Y?+?startP.Y))));??
- ????????????????????SetCursorPos(x4,?y4);??
- ????????????????????break;??
- ????????????}??
- ????????????GC.Collect();??
- ????????}??
- ????}??
- }??
使用時(shí),只需要激活瞄準(zhǔn)器窗口,按F1,F2獲取鼠標(biāo)位置,再根據(jù)洞口位置分別選按1、2、3、4數(shù)字鍵就行。
經(jīng)過N次試驗(yàn),成功率還挺高,只是有時(shí)候手動(dòng)放置鼠標(biāo)到被擊打球圓心會(huì)出現(xiàn)誤差,導(dǎo)致?lián)羟虿粶?zhǔn),當(dāng)然,后來我贏了很多場(chǎng)比賽(嘿嘿,有點(diǎn)不道德!)。
再后來,又用C寫了一遍,給同學(xué)用了。代碼如下:
- #include?<windows.h>??
- #include?<math.h>??
- int?ra=26;??
- int?flag=0;??
- POINT?startP,endP;??
- int?x5,y5,x2,y2,x3,y3,x4,y4;??
- LRESULT?CALLBACK?WndProc?(HWND,?UINT,?WPARAM,?LPARAM)?;??
- ??
- int?WINAPI?WinMain?(HINSTANCE?hInstance,?HINSTANCE?hPrevInstance,PSTR?szCmdLine,?int?iCmdShow)??
- {??
- ????static?TCHAR?szAppName[]?=?TEXT?("GUA")?;??
- ????HWND?hwnd?;??
- ????MSG?msg?;??
- ????WNDCLASS?wndclass?;??
- ????wndclass.style?=?CS_HREDRAW?|?CS_VREDRAW?;??
- ????wndclass.lpfnWndProc?=?WndProc?;??
- ????wndclass.cbClsExtra?=?0?;??
- ????wndclass.cbWndExtra?=?0?;??
- ????wndclass.hInstance?=?hInstance?;??
- ????wndclass.hIcon?=?LoadIcon?(NULL,?IDI_APPLICATION)?;??
- ????wndclass.hCursor?=?LoadCursor?(NULL,?IDC_ARROW)?;??
- ????wndclass.hbrBackground?=?(HBRUSH)?GetStockObject?(WHITE_BRUSH)?;??
- ????wndclass.lpszMenuName?=?NULL?;??
- ????wndclass.lpszClassName?=?szAppName?;??
- ????if?(!RegisterClass?(&wndclass))??
- ????{??
- ????????MessageBox?(?NULL,?TEXT?("Program?requires?Windows?NT!"),??
- ????????????szAppName,?MB_ICONERROR)?;??
- ????????return?0?;??
- ????}??
- ????????hwnd?=?CreateWindow?(szAppName,?TEXT?("Programmed?By?DC"),??
- ????????????WS_OVERLAPPEDWINDOW,??
- ????????????CW_USEDEFAULT,?CW_USEDEFAULT,??
- ????????????CW_USEDEFAULT,?CW_USEDEFAULT,??
- ????????????NULL,?NULL,?hInstance,?NULL)?;??
- ????????ShowWindow?(hwnd,?iCmdShow)?;??
- ????????SetForegroundWindow(hwnd);??
- ????????MoveWindow(hwnd,100,100,200,200,TRUE);??
- ????????UpdateWindow?(hwnd)?;??
- ????????while?(GetMessage?(&msg,?NULL,?0,?0))??
- ????????{??
- ????????????TranslateMessage?(&msg)?;??
- ????????????DispatchMessage?(&msg)?;??
- ????????}?????????
- ????????return?msg.wParam?;??
- ????}??
- ??
- void?Draw(HWND?hwnd,LPCSTR?lpString)??
- {??
- ????HDC?hdc?;????
- ????PAINTSTRUCT?ps?;????
- ????RECT?rect?;???
- ????hdc?=?BeginPaint?(hwnd,?&ps)?;????
- ????GetClientRect?(hwnd,?&rect)?;????
- ????DrawText?(hdc,?lpString,?-1,?&rect,??DT_SINGLELINE?|?DT_CENTER?|?DT_VCENTER)?;????
- ????EndPaint?(hwnd,?&ps)?;???
- ????ReleaseDC(hwnd,hdc);??
- }??
- ??
- LRESULT?CALLBACK?WndProc?(HWND?hwnd,?UINT?message,?WPARAM?wParam,LPARAM?lParam)??
- {??
- ????HBRUSH?hBrush?;??
- ????HDC?hdc?;??
- ????PAINTSTRUCT?ps?;??
- ????RECT?rc?;??
- ????switch?(message)??
- ????{??
- ????????case?WM_CREATE:??
- ????????????return?0?;??
- ????????case?WM_PAINT?:??
- ????????????return?0?;??
- ????????case?WM_KEYDOWN:????
- ????????????switch?(wParam)????
- ???????????{????
- ????????????case?VK_F1:????
- ????????????????????GetCursorPos(&startP);??
- ????????????????????flag=1;??
- ????????????????????InvalidateRect?(hwnd,?NULL,?TRUE)?;??
- ????????????????????Draw(hwnd,"第1點(diǎn)已鎖定!");??
- ????????????????????break?;????
- ????????????case?VK_F2:????
- ????????????????????GetCursorPos(&endP);??
- ????????????????????flag=2;??
- ????????????????????InvalidateRect?(hwnd,?NULL,?TRUE)?;??
- ????????????????????Draw(hwnd,"第2點(diǎn)已鎖定!");??
- ????????????????????break?;???
- ????????????case?0x31:???
- ????????????????????x5?=?(int)(endP.x?+?ra?*?((endP.x?-?startP.x)?/?sqrt((endP.x?-?startP.x)?*?(endP.x?-?startP.x)?+?(endP.y?-?startP.y)?*?(endP.y?-?startP.y))));??
- ????????????????????y5?=?(int)(endP.y?+?ra?*?((endP.y?-?startP.y)?/?sqrt((endP.x?-?startP.x)?*?(endP.x?-?startP.x)?+?(endP.y?-?startP.y)?*?(endP.y?-?startP.y))));??
- ????????????????????SetCursorPos(x5,?y5);??
- ????????????????????break;??
- ????????????case?0x32:???
- ????????????????????x2?=?(int)(endP.x?-?ra?*?((-endP.x?+?startP.x)?/?sqrt((-endP.x?+?startP.x)?*?(-endP.x?+?startP.x)?+?(endP.y?-?startP.y)?*?(endP.y?-?startP.y))));??
- ????????????????????y2?=?(int)(endP.y?+?ra?*?((endP.y?-?startP.y)?/?sqrt((-endP.x?+?startP.x)?*?(-endP.x?+?startP.x)?+?(endP.y?-?startP.y)?*?(endP.y?-?startP.y))));??
- ????????????????????SetCursorPos(x2,?y2);??
- ????????????????????break;??
- ????????????case?0x33:??????????????????????
- ????????????????????x3?=?(int)(endP.x?+?ra?*?((endP.x?-?startP.x)?/?sqrt((endP.x?-?startP.x)?*?(endP.x?-?startP.x)?+?(-endP.y?+?startP.y)?*?(-endP.y?+?startP.y))));??
- ????????????????????y3?=?(int)(endP.y?-?ra?*?((-endP.y?+?startP.y)?/?sqrt((endP.x?-?startP.x)?*?(endP.x?-?startP.x)?+?(-endP.y?+?startP.y)?*?(-endP.y?+?startP.y))));??
- ????????????????????SetCursorPos(x3,?y3);??
- ????????????????????break;??
- ????????????case?0x34:??
- ????????????????????x4?=?(int)(endP.x?-?ra?*?((-endP.x?+?startP.x)?/?sqrt((-endP.x?+?startP.x)?*?(-endP.x?+?startP.x)?+?(-endP.y?+?startP.y)?*?(-endP.y?+?startP.y))));??
- ????????????????????y4?=?(int)(endP.y?-?ra?*?((-endP.y?+?startP.y)?/?sqrt((-endP.x?+?startP.x)?*?(-endP.x?+?startP.x)?+?(-endP.y?+?startP.y)?*?(-endP.y?+?startP.y))));??
- ????????????????????SetCursorPos(x4,?y4);??
- ????????????????????break;??
- ????????????}??
- ????????????return?0;??
- ????????case?WM_SIZE?:???
- ????????????if(flag==1)??
- ????????????{??
- ????????????????Draw(hwnd,"第1點(diǎn)已鎖定!");??
- ????????????}??
- ????????????else?if(flag==2)??
- ????????????{??
- ????????????????Draw(hwnd,"第2點(diǎn)已鎖定!");??
- ????????????}??
- ????????????else??
- ????????????{InvalidateRect?(hwnd,?NULL,?TRUE)?;?}??
- ????????????return?0?;??
- ????????case?WM_KILLFOCUS:??
- ????????????InvalidateRect?(hwnd,?NULL,?TRUE)?;??
- ????????????hdc?=?BeginPaint?(hwnd,?&ps)?;??
- ????????????GetClientRect?(hwnd,?&rc)?;??
- ????????????hBrush?=?CreateSolidBrush?(?RGB(255,0,0)?)?;??
- ????????????FillRect?(hdc,?&rc,?hBrush)?;??
- ????????????EndPaint?(hwnd,?&ps)?;??
- ????????????ReleaseDC(hwnd,hdc);??
- ????????????DeleteObject?(hBrush)?;??
- ????????????return?0;??
- ????????case?WM_SETFOCUS:??
- ????????????InvalidateRect?(hwnd,?NULL,?TRUE)?;??
- ????????????if(flag==1)??
- ????????????{??
- ????????????????Draw(hwnd,"第1點(diǎn)已鎖定!");??
- ????????????}??
- ????????????else?if(flag==2)??
- ????????????{??
- ????????????????Draw(hwnd,"第2點(diǎn)已鎖定!");??
- ????????????}??
- ????????????return?0;??
- ????????case?WM_DESTROY?:??
- ????????????PostQuitMessage?(0)?;??
- ????????????return?0?;??
- ????}??
- ????return?DefWindowProc(hwnd,?message,?wParam,?lParam)?;??
- }??
?
但是問題還存在,就是手動(dòng)找圓心太麻煩,一般用觸摸板比鼠標(biāo)方便,但是仍然很不智能,于是一直想著用圖像處理的方法去自動(dòng)找圓心。
這幾天在做數(shù)模,經(jīng)常用到Matlab,剛做了一道要處理圖像的題,正好想起這個(gè)問題來,于是,擱置的瞄準(zhǔn)器繼續(xù)開始完善了。
很快就有了思路,通過C#截圖,然后Matlab進(jìn)行圖像濾波,灰度化,二值化以及邊緣提取,然后進(jìn)行圓曲線擬合,最后找到圓心,返回到C#中使用,代替手動(dòng)找點(diǎn)。
首先,我用Matlab寫了個(gè)函數(shù):
- function?[x,y]=findcenter()??
- %close?all,clear,clc??
- format?short??
- a=imread('E:\360data\重要數(shù)據(jù)\桌面\test.bmp');??
- b=rgb2gray(a);%轉(zhuǎn)化為灰度圖像??
- %figure;imshow(b)??
- b=filter2(fspecial('average',1),b)/255;??
- %b=medfilt2(b);%中值濾波??
- level=graythresh(b);%自動(dòng)獲取灰度圖片的閾值??
- c=im2bw(b,level);%二值化??
- %figure;imshow(c)??
- bw=edge(c,'canny');??
- bw1=~bw;%取反,黑變白,白變黑??
- %figure;imshow(bw1)??
- %figure;imshow(bw1)??
- [yf,xf]=find(bw1==0);??
- xmin=min(xf);??
- xmax=max(xf);??
- ymin=min(yf);??
- ymax=max(yf);??
- %cirPx=[xmin;(xmax-xmin)/2;(xmax-xmin)/2;xmax]??
- %cirPy=[(ymax-ymin)/2;ymin;ymax;(ymax-ymin)/2]??
- %fitellipse(cirPx,cirPy)??
- centerX=(xmax+xmin)/2;??
- centerY=(ymax+ymin)/2;??
- ra=(ymax-ymin)/2;??
- x=centerX;y=centerY;??
- %hold?on??
- %x=0:size(bw1,2);??
- %degree=[0:0.01:pi*2];??
- %degree=[0:0.01:pi*2];??
- %plot(ra*cos(degree)+centerX,ra*sin(degree)+centerY,'r-');??
- %plot(centerX,centerY,'r+');??
然后用Matlab2010b里的deploytool導(dǎo)出.net能使用的程序集dll文件(不知道為什么malab2009b在build時(shí)出現(xiàn).net framework相關(guān)的錯(cuò)誤),通過C#添加引用,調(diào)用其返回的參數(shù),成功完成自動(dòng)拾取圓心。
?
?
改進(jìn)后代碼如下:
- using?System.Drawing;??
- using?System.Windows.Forms;??
- using?System.Windows;??
- using?System.Runtime.InteropServices;??
- using?System;??
- using?MathWorks.MATLAB.NET.Arrays;??
- using?MathWorks.MATLAB.NET.Utility;??
- using?findcenter;??
- ??
- namespace?TaiqiuGua??
- {??
- ??
- ????public?partial?class?Form1?:?Form??
- ????{??
- ????????const?int?ra=25;??
- ????????[DllImport("user32.dll")]??
- ????????static?extern?IntPtr?GetDesktopWindow();??
- ????????[DllImport("user32.dll")]??
- ????????static?extern?IntPtr?GetWindowDC(IntPtr?hWnd);??
- ????????[DllImport("user32.dll")]??
- ????????static?extern?bool?SetCursorPos(int?X,?int?Y);??
- ??
- ????????public?Form1()??
- ????????{??
- ????????????InitializeComponent();??
- ????????}??
- ??
- ????????Point?startP,startP1;??
- ????????Point?endP,endP1;??
- ??????????
- ????????private?void?Form1_KeyDown(object?sender,?KeyEventArgs?e)??
- ????????{??
- ????????????switch(e.KeyData)??
- ????????????{??
- ????????????????case?Keys.F1:??
- ????????????????????startP=Control.MousePosition;??
- ????????????????????break;??
- ????????????????case?Keys.F5:??
- ????????????????????endP?=?Control.MousePosition;??
- ????????????????????break;??
- ????????????????case?Keys.F2:??
- ????????????????????startP1?=?Control.MousePosition;??
- ????????????????????break;??
- ????????????????case?Keys.F3:??
- ????????????????????endP1?=?Control.MousePosition;??
- ????????????????????break;??
- ????????????????case?Keys.D1:??
- ????????????????????int?x1?=?(int)(endP.X?+?ra?*?((endP.X?-?startP.X)?/?Math.Sqrt((endP.X?-?startP.X)?*?(endP.X?-?startP.X)?+?(endP.Y?-?startP.Y)?*?(endP.Y?-?startP.Y))));??
- ????????????????????int?y1?=?(int)(endP.Y?+?ra?*?((endP.Y?-?startP.Y)?/?Math.Sqrt((endP.X?-?startP.X)?*?(endP.X?-?startP.X)?+?(endP.Y?-?startP.Y)?*?(endP.Y?-?startP.Y))));??
- ????????????????????SetCursorPos(x1,?y1);??
- ????????????????????break;??
- ????????????????case?Keys.D2:??
- ????????????????????int?x2?=?(int)(endP.X?-?ra?*?((-endP.X?+?startP.X)?/?Math.Sqrt((-endP.X?+?startP.X)?*?(-endP.X?+?startP.X)?+?(endP.Y?-?startP.Y)?*?(endP.Y?-?startP.Y))));??
- ????????????????????int?y2?=?(int)(endP.Y?+?ra?*?((endP.Y?-?startP.Y)?/?Math.Sqrt((-endP.X?+?startP.X)?*?(-endP.X?+?startP.X)?+?(endP.Y?-?startP.Y)?*?(endP.Y?-?startP.Y))));??
- ????????????????????SetCursorPos(x2,?y2);??
- ????????????????????break;??
- ????????????????case?Keys.D3:??????????????????????
- ????????????????????int?x3?=?(int)(endP.X?+?ra?*?((endP.X?-?startP.X)?/?Math.Sqrt((endP.X?-?startP.X)?*?(endP.X?-?startP.X)?+?(-endP.Y?+?startP.Y)?*?(-endP.Y?+?startP.Y))));??
- ????????????????????int?y3?=?(int)(endP.Y?-?ra?*?((-endP.Y?+?startP.Y)?/?Math.Sqrt((endP.X?-?startP.X)?*?(endP.X?-?startP.X)?+?(-endP.Y?+?startP.Y)?*?(-endP.Y?+?startP.Y))));??
- ????????????????????SetCursorPos(x3,?y3);??
- ????????????????????break;??
- ????????????????case?Keys.D4:??
- ????????????????????int?x4?=?(int)(endP.X?-?ra?*?((-endP.X?+?startP.X)?/?Math.Sqrt((-endP.X?+?startP.X)?*?(-endP.X?+?startP.X)?+?(-endP.Y?+?startP.Y)?*?(-endP.Y?+?startP.Y))));??
- ????????????????????int?y4?=?(int)(endP.Y?-?ra?*?((-endP.Y?+?startP.Y)?/?Math.Sqrt((-endP.X?+?startP.X)?*?(-endP.X?+?startP.X)?+?(-endP.Y?+?startP.Y)?*?(-endP.Y?+?startP.Y))));??
- ????????????????????SetCursorPos(x4,?y4);??
- ????????????????????break;??
- ????????????????case?Keys.F4:??
- ????????????????????//Graphics?g1?=?pictureBox1.CreateGraphics();??
- ????????????????????//g1.CopyFromScreen(startP1.X,startP1.Y,0,0,new?Size(endP1.X-startP1.X,endP1.Y-startP1.Y));??
- ????????????????????int?w=endP1.X?-?startP1.X;??
- ????????????????????int?h=endP1.Y?-?startP1.Y;??
- ????????????????????Bitmap?bmSave?=?new?Bitmap(w,h);??
- ????????????????????Graphics?g=Graphics.FromImage(bmSave);??
- ????????????????????g.CopyFromScreen(startP1.X,startP1.Y,0,0,new?Size(w,h),CopyPixelOperation.SourceCopy);??
- ????????????????????bmSave.Save(@"E:\360data\重要數(shù)據(jù)\桌面\test.bmp");??
- ????????????????????g.Dispose();??
- ????????????????????//g1.Dispose();??
- ????????????????????bmSave.Dispose();??
- ????????????????????findcenter.Class1?f?=?new?findcenter.Class1();???????
- ????????????????????MWArray?centerx?=?f.findcenter();??
- ????????????????????MWArray?centery?=?f.findy();??
- ????????????????????double[,]?x?=?(double[,])centerx.ToArray();??
- ????????????????????double[,]?y?=?(double[,])centery.ToArray();??
- ????????????????????SetCursorPos((int)(x[0,?0]?+?startP1.X),?(int)(y[0,?0]?+?startP1.Y));??
- ????????????????????//int?[]?d=center.Dimensions;??????????????????????
- ????????????????????//int?x=int.Parse((center[1,?1]).ToString());??
- ????????????????????//int?y=?int.Parse((center[1,?2]).ToString());??
- ????????????????????//MessageBox.Show((y[0,0]).ToString());??
- ????????????????????f.Dispose();??
- ????????????????????break;??
- ????????????}??
- ????????????GC.Collect();??
- ????????}??
- ??
- ????????private?void?Form1_Activated(object?sender,?EventArgs?e)??
- ????????{??
- ????????????//this.BackColor?=?Color.Red;??
- ????????}??
- ??
- ????????private?void?Form1_Deactivate(object?sender,?EventArgs?e)??
- ????????{??
- ????????????//this.BackColor?=?Color.Blue;??
- ????????}??
- ??
- ????}??
- }??
經(jīng)試驗(yàn),成功率也很高,偶爾出現(xiàn)不準(zhǔn)(估計(jì)是邊緣提取和計(jì)算精度的問題),但是大多數(shù)偏差可以手動(dòng)修正。
到此為止,改進(jìn)版全部完成。希望以后繼續(xù)改進(jìn),更加智能化。C#?真是碼農(nóng)的利器啊!