#include "cv.h"
#include "highgui.h"
#include "cvaux.h"
#include "cxcore.h"
#include #include using namespace std;
using namespace cv;
#define pi 3.14159f
void drawbox(cvbox2d box,iplimage* img)
cvline( img, pt[0], pt[1],cv_rgb(255,0,0), 2, 8, 0 );
cvline( img, pt[1], pt[2],cv_rgb(255,0,0), 2, 8, 0 );
cvline( img, pt[2], pt[3],cv_rgb(255,0,0), 2, 8, 0 );
cvline( img, pt[3], pt[0],cv_rgb(255,0,0), 2, 8, 0 );
}void main()
} printf("hu矩:%f,%f,%f,%f,%f,%f,%f\n",humonents1->hu1,humonents1->hu2,humonents1->hu3,humonents1->hu3,humonents1->hu5,humonents1->hu6,humonents1->hu7);
printf("\n圖2:\n\n");
printf("輪廓數:%d\n\n",nc2);
printf("遍歷三階矩:\n");
cvmoments*moments2=new cvmoments();
cvmoments(contour2,moments2,0);
cvhumoments *humonents2=new cvhumoments();
cvgethumoments(moments2,humonents2);
for (int xorder = 0; xorder <= 3; xorder++)
for (int yorder = 0; yorder <= 3; yorder++)
}printf("hu矩:%f,%f,%f,%f,%f,%f,%f\n",humonents2->hu1,humonents2->hu2,humonents2->hu3,humonents2->hu3,humonents2->hu5,humonents2->hu6,humonents2->hu7);
//hu矩匹配
double hu = cvmatchshapes(contour1,contour2,cv_contours_match_i1,0);
printf("\n\nhu矩匹配:%f\n",hu);
//輪廓樹匹配
cvmemstorage* storage3 = cvcreatememstorage();
cvmemstorage* storage4= cvcreatememstorage();
cvcontourtree* tree1 = cvcreatecontourtree(contour1,storage3,200);
cvcontourtree* tree2 = cvcreatecontourtree(contour2,storage4,200);
double tree = cvmatchcontourtrees(tree1,tree2,cv_contours_match_i1,200);
printf("\n輪廓樹匹配:%.4f\n\n",tree);
//將輪廓線畫出
double s1,len1,h1,d1;
cvrect rect1;
cvbox2d box1,ellipse1;
cvpoint2d32f center1;
float radius1;
iplimage* mask1=cvcreateimage(cvgetsize(img1),8,1);
iplimage* dst1=cvcreateimage(cvgetsize(img1),8,3);
//輪廓的成對幾何直方圖匹配
int sizes[2] = ;
float ranges[2][2] = , };
float** rangesptr = new float* [2];
rangesptr[0] = ranges[0];
rangesptr[1] = ranges[1];
cvhistogram* hist1,*hist2;
hist1 = cvcreatehist(2, sizes, cv_hist_array, rangesptr, 1);
hist2 = cvcreatehist(2, sizes, cv_hist_array, rangesptr, 1);
cvcalcpgh(contour1, hist1);
cvcalcpgh(contour2, hist2);
cvnormalizehist(hist1, 1);
cvnormalizehist(hist2, 1);
double hist= cvcomparehist(hist1,hist2, cv_comp_intersect);
printf("\n成對幾何直方圖匹配:%.2f\n\n\n", hist);
printf("圖1:\n\n");
for( int i=1; contour1!= 0; contour1 = contour1->h_next,i++)
cvreleasememstorage(&storage1);
cvreleasememstorage(&storage2);
cvreleasememstorage(&storage3);
cvreleasememstorage(&storage4);
}
關於各種dc的例項簡單使用
用win32api畫線 hdc hdc hdc getdc m hwnd movetoex hdc,m porigin.x,m porigin.y,null lineto hdc,point.x,point.y releasedc m hwnd,hdc 用封裝的cdc畫線 cdc pdc getdc...
關於HsahMap的各種方法使用總結
1,map是與collection同級的介面,我們常用它的hashmap實現類 hashmap是通過鍵值對應的關係來儲存資訊的,與我們之前的list和set都不一樣 每乙個key都對應乙個value,可以儲存不同的物件 我們獲取它儲存的value就只能通過get key 方法來獲取 遍歷也一樣的,必...
關於各種Formatting context
我們把網頁看作是由很多個盒子組成的,而這些盒子的展示方式,就是由display這個屬性來決定的。這裡出現了乙個概念,叫做formatting context 格式上下文 formatting context 是 w3c css2.1 規範中的乙個概念。它是頁面中的一塊渲染區域,有一套渲染規則決定了其...