기본 콘텐츠로 건너뛰기

4월, 2010의 게시물 표시

[MATLAB]Circle Fit

  http://www.mathworks.com/matlabcentral/fileexchange/5557-circle-fit

[OpenCV]cvCompareHist - CV_COMP_INTERSECT

[code cpp] double CompareHistogram(IplImage* BufSrc, IplImage* BufRef) {  double dfScore;  int nHistoSize = 256;  float ranges[] = { 0, 256 };  float *hist_range[] = { ranges }; CvHistogram *histSrc = cvCreateHist(1, &nHistoSize, CV_HIST_ARRAY, hist_range);  CvHistogram *histRef = cvCreateHist(1, &nHistoSize, CV_HIST_ARRAY, hist_range);  cvCalcHist(&BufSrc, histSrc, 0, NULL );  cvCalcHist(&BufRef, histRef, 0, NULL );  cvNormalizeHist( histSrc, 100);  cvNormalizeHist( histRef, 100);     // Score = 0.0 ~ 100.0  dfScore = cvCompareHist( histSrc, histRef, CV_COMP_INTERSECT ); return dfScore; } [/code]

[OpenCV]cvDrawContours

cvDrawContours 함수는 contour 를 그려주는 함수이며 thickness 가 0 이상일 경우에는 외곽선만을 그려주고 0 미만일 경우에는 내부를 채워준다 .   원형 void cvDrawContours ( CvArr *img, CvSeq* contour,                                 CvScalar external_color, CvScalar hole_color,                                 int max_level, int thickness=1,                                 int line_type=8, CvPoint offset=cvPoint(0,0) );   패러미터 img contour 를 그릴 IplImage 구조체의 포인터를 넘겨준다 . 다른 그리기 함수와 마찬가지로 contour 는 ROI 로 클리핑된다 . contour CvSeq 구조체의 포인터를 넘겨준다 external_color 외부 contour 의 색상을 설정한다 . hole_color 내부 hole 의 색상을 설정한다 . max_level 그려질 contour 의 최대 단계를 설정한다 . 만약 0 이면 contour 만이 그려질 것이고 1 이면 모든 contour 를 같은 레벨에 그려준다 . 2 이면 다음 레벨까지 그려줄 것이다 . 만약 음수이면 max_level 값에 절대값을 취한 것에서 1 을 뺀 만큼의 자식 contour 를 그려준다 . thickness 라인의 두께를 설정한다 . 만약 음수 (CV_FILLED) 이면 내부를 채운다 . line_type 라인의 그리기 방식을 설정한다 . 8 - 8 방향으로 연결된 라인으로 그린다 . 4 - 4 방향으로 연결된 라인으로 그린다 . CV_AA - 안티앨리어싱을 적용한다 . off

[OpenCV]자주쓰는 기능..

[code cpp] //Exec Notepad CFileFind ff; //if( ff.FindFile( _T("C:\\WINDOWS\\notepad.exe") ) && ff.FindFile( _T("C:\\TEST\\temp.txt") ) ) // WinExec( "C:\\WINDOWS\\notepad.exe C:\\PARMI\\temp.txt", SW_SHOW );if( ff.FindFile( _T("C:\\WINDOWS\\notepad.exe") ) && ff.FindFile( strFilePath ) ) {  CString strCmd;  strCmd.Format( _T("C:\\WINDOWS\\notepad.exe ") );  strCmd += strFilePath;  USES_CONVERSION;  WinExec( W2A(strCmd), SW_SHOW ); } [/code] [code cpp] //Show Image void cvShowImageWindow(CString title, CvArr* image) {  USES_CONVERSION;  cvNamedWindow( W2A(title), CV_WINDOW_AUTOSIZE);  cvShowImage( W2A(title), image);  HWND hWnd = ::FindWindow(NULL, title);  if (hWnd)   ::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); } [/code] [code cpp] //Save Image CString strFileName; std::string szFileName = CStringA( strFileName ); cvSaveImage( szFileName.c_str(), iplImage ); [/code]     [code cpp] ///////

[OpenCV]accumulation_of_background

출처 : http://opencv.jp/sample/accumulation_of_background.html#background_sub   [code cpp] #include <cv.h> #include <highgui.h> #include <ctype.h> #include <stdio.h> int main (int argc, char **argv) {   int i, c, counter;   int INIT_TIME = 100;   int w = 0, h = 0;   double B_PARAM = 1.0 / 50.0;   double T_PARAM = 1.0 / 200.0;   double Zeta = 10.0;   CvCapture *capture = 0;   IplImage *frame = 0;   IplImage *av_img, *sgm_img;   IplImage *lower_img, *upper_img, *tmp_img;   IplImage *dst_img, *msk_img;   CvFont font;   char str[64];   // (1)コマンド引?によって指定された番?のカメラに?するキャプチャ構造?を作成する   if (argc == 1 || (argc == 2 && strlen (argv[1]) == 1 && isdigit (argv[1][0])))     capture = cvCreateCameraCapture (argc == 2 ? argv[1][0] - '0' : 0);   // (2)1フレ?ムキャプチャし,キャプチャサイズを取得する.   frame = cvQueryFrame (capture);   w = frame->width;   h = frame->height;   // (3)作業用の領域を生成する   av_img = cvCreateImage (cvSize (w, h), IPL_DEPTH_32F, 3);   sgm_im

[XML]Quick notes on how to use RapidXML

There’s a C++ XML library called RapidXML which is perfect for most non-enterprise uses of XML. I wouldn’t call this a tutorial, but I hope this ends up helping someone. The documentation isn’t very explicit on how to output an XML declaration, for example. How to create your XML from scratch and then output this XML into a string, with an XML declaration: [code xml]<?xml version="1.0" encoding="utf-8"?> <rootnode version="1.0" type="example">   <childnode/> </rootnode>[/code][code cpp]using namespace rapidxml;   xml_document<> doc;   // xml declaration xml_node<>* decl = doc.allocate_node(node_declaration); decl->append_attribute(doc.allocate_attribute("version", "1.0")); decl->append_attribute(doc.allocate_attribute("encoding", "utf-8")); doc.append_node(decl);   // root node xml_node<>* root = doc.allocate_node(node_element, "rootnode"); root-

Homogeneous Transformations Matrix

로봇동역학과제어chapter2.pdf 2.2 계의 표시법 매니퓨레이터가 작업대상물에 대하여 작업을 하기 위해서는 공구단을 대상물로 움직 여야 한다. 따라서, 매니퓨레이터의 각 부분, 혹은 작업대상물의 위치와 자세를 기준좌표 계로 나타내는 것이 필요하다. 2.2.1 위치의 표시 이러한 것들의 위치는 주어진 좌표계를 기준으로 나타낼 수 있다. 여기서는 기준좌표계를 {A}라고 하면, 주어진 점 a의 위치는로 나타내어진다고 가정한다. 즉 이때 및 는 각각 좌표계 {A} 상의 원점에서 축 방향의 거리를 나타내고 있다. 이러한 위치 벡터 는 매니퓨레이터의 형태 혹은 필요에 의 해서 구좌표 및 원통좌표로도 나타낼 수 있다. 2.2.2 자세의 표시 2.2.2.1 기본회전 대상물의 기준 좌표계에 대한 자세는 대상물에 새로운 좌표계를 설정하여, 이 좌표계의 기 준 좌표계에 대한 회전으로 나타낼 수가 있다. 즉 기준 좌표계에 대한 상대 좌표계의 것을 말한다. 편의상 3축에 의한 자세 변화는 3 X 3 행렬로 나타내며 이러한 행렬을 회전행렬 이라 하며 로써 나타낸다. 정의에 의해서 이러한 회전행렬 R은 행의 크기가 1이며, 서 로 직교인 정규직교행렬이다. 기준 좌표계를 {A}, 상대 좌표계를 {B}라면, 좌표계 {B}의 좌표계 {A}에 대한 자세 는 로 나타낼 수 있다. 만일 고정된 좌표계 {A}에 대해 움직이는 좌표계 {B}를 고려하면, 다음 그림 2.2.1과 같이 공간상에 표시할 수가 있다. 그림 2.2.1 공간에서의 좌표계 {B}의 좌표계 {A}에 대한 기본회전 이 경우 공간상의 임의의 점는 각 좌표계에서 다음과 같이 나타낼 수 있다. 여기서 행렬 이다. 따라서 고정 좌표계 {A}의 축을 1 중심으로 만큼 회전시켰을 경우 이동 좌표계 {B}의 회전 행렬은 다음과 같이 나타낼 수 있다. 여기서 이 a y * b x = a z * b x = a x * b y = a x * b z =0, a x * b x =1되므