수요일, 11월 25, 2009

[CV][IP][ALL] Graphics paper

Graphics paper

ACM SIGGRAPH
Source:
http://trowley.org/


Graphics paper indexes:

Other graphics paper indexes maintained by Ke-Sen Huang:
Other indexes:

-----
Cheers,
June

Unity: It's FREE!

Unity

Unity is
a multiplatform game development tool, designed from the start to ease creation. A fully integrated professional application, Unity just happens to contain the most powerful engine this side of a million dollars.

Source:
http://unity3d.com/


-----
Cheers,
June

UDK: Unreal Development Kit (it's FREE!)

UDK: Unreal Development Kit

What is it?
UDK is Unreal Engine 3 – the complete professional development framework. All the tools you need to create great games, advanced visualizations and detailed 3D simulations. The best tools in the industry are in your hands.

Source:
http://www.udk.com/

Partner-hosted downloads:
Intel 
New! Beta 2
(http://software.intel.com/en-us/articles/unreal-development-kit-download/)
NVIDIA
New! Beta 2
(http://developer.nvidia.com/object/udk.html)



-----
Cheers,
June

[CV][IP][NPR] Non-Photorealistic Rendering

Non-Photorealistic Rendering

Reference:

// An Educational Non-Photorealistic Rendering System Using 2D Images by Java Programming
http://nis-lab.is.s.u-tokyo.ac.jp/nis/cdrom/pg/j11h2kond.pdf

// 2D Animation Style Rendering of Water
http://vml.kaist.ac.kr/publication/thesis/YouMi_MS_Thesis.pdf

// Non-Photorealistic Rendering and Content-Based Image Retrieval
http://www1.i2r.a-star.edu.sg/~zyhuang/review/research/others/pg03_jixw.pdf

// A Survey of Pen-and-Ink Illustration in Non-photorealistic Rendering
http://www.icg.seas.gwu.edu/cs367/nonphoto.pdf

// Stylized and Abstract Painterly Rendering System Using a Multiscale Segmented Sphere Hierarchy
http://graphics.csie.ncku.edu.tw/Paper_Video/TVCG/NPR_2006/2006-TVCG-Stylized%20and%20Abstract%20Painterly%20Rendering.pdf

// 15-462 Computer Graphics I Lecture 22: Non-Photorealistic Rendering
http://www.cs.cmu.edu/~fp/courses/graphics/pdf-6up/21-npr.pdf

// A Cartoon Based 3 Dimensional Model Generator
http://mnet.skku.ac.kr/data/2003data/HCI2004/Proceed/P0287.pdf

// Cartoon-style Rendering of Motion from Video
http://personal.ee.surrey.ac.uk/Personal/J.Collomosse/pubs/Collomosse-VVG-2003.pdf


-----
Cheers,
June

화요일, 11월 24, 2009

What is p-code?

p-code 와 byte code 의 혼동을 피하기 위해 작성 해 놓는다.

Paul Clement said:
P-code is an intermediate compilation that is translated at runtime to native (machine) code format so that it can be executed at machine level. Byte code is an intermediate language, like p-code, and is also interpreted at runtime.
Source:
http://forums.devx.com/archive/index.php/t-9101.html


-----
Cheers,
June

[CV] Augmented Sketches (What's Next In Augmented Reality?)

Augmented Sketches

What's Next In Augmented Reality?

Source:
http://www.technologyreview.com/blog/editors/24253/?a=f

Tuesday, October 20, 2009
What's Next In Augmented Reality?
Projects presented at a major conference show how augmented reality can improve.
By Kristina Grifantini

As the sensors and chips in portable electronics become more powerful, augmented reality (AR) is starting to give consumers new ways to blend virtual and real-world information.

The iPhone and devices powered by Google's Android OS already have some AR apps, but these are mostly limited to overlaying directions or tourist information on a view of the real world.

At this week's International Symposium on Mixed and Augmented Reality (ISMAR 09) in Orlando, Florida, leading researchers will present systems designed to push the boundaries of AR--allowing users to interact with and manipulate virtual data, share real and virtual space with others, and see real time information around them.

Here are some of the most exciting projects presented at ISMAR 09.

Augmented Sketches

Researchers in the Human Interface Technology Laboratory(http://www.hitlabnz.org/wiki/Home) at the University of Canterbury in New Zealand have developed a system that brings sketches to life with AR. "This work aims at encouraging people to create and interact with 3D content in a fun way, using sketching as a means for communication," says Oriel Bergig(http://www.vml.cs.bgu.ac.il/), a researcher at the Visual Media Lab at the Ben-Gurion University in Israel, who collaborated on the project. The technology could be used in games, advertisements, and educational applications, according to the team.


Multi-Touch Interaction

To accurately augment the real world, AR systems will need to become better at tracking the position of objects. Most commercial systems rely on GPS, which works for directions but can be crude for exact positioning.Another interactive AR system developed at the HIT lab, called SSTT Touch, lets users manipulate dynamic, 3D objects with their fingers.


Tracking Multiple Objects

Another research project is focused on simultaneously(http://www.robots.ox.ac.uk/%7Ebob/research/research_optamm.html), another important feature if AR is to be used for more complicated, real-world tasks. This video shows multiple-object-recognition software created by Oxford University professor David(http://www.robots.ox.ac.uk/%7Edwm/) Murray and Robert Castle(http://www.robots.ox.ac.uk/%7Ebob/), a researcher at the computing vision company 2d3.

http://link.brightcove.com/services/player/bcpid263777539?bctid=45073705001

Maintaining Personal Virtual Space

The next video shows a project developed by researcher Ohan Oda(http://www1.cs.columbia.edu/%7Eohan/) and professor Steven Feiner(http://www1.cs.columbia.edu/%7Efeiner/) at Columbia University. It demonstrates a way for users to share the same virtual environment in an AR game without bumping into each other. A technique called Redirected Motion displaces each user's virtual display as illustrated in this virtual domino-toppling game. This lets users, whose eyes are fixed on a screen--engage in AR systems withough not interfering with each other.

http://link.brightcove.com/services/player/bcpid263777539?bctid=45086586001

Adding Real-Time Information

And finally, here's a pretty cool AR mapping system from the Georgia Institute of Technology's Computational Perception Laboratory(http://www.cc.gatech.edu/cpl/projects/augearth/). This system adds dynamic, real-time information, such as traffic or weather, to aerial Earth from Google Maps or Microsoft Virtual Earths, turning these mapping applications into an impressive augmented environment.



-----
Cheers,
June

[CV] [IP] [OCR] OCR Algs Study

OCR (Optical Character Recognition)

Reference:
// 차량의 종류와 자동차번호판 인식을 위한 영상처리 알고리즘개발
http://www.piel.co.kr/board/down/ASS/the_lpw.pdf

// 차영상과 신경망을 이용한 자동차 번호판 지역 문자 인식
http://mnet.skku.ac.kr/data/2007data/KIPS2007/PDF/papers/KIPS_C2007A_0148_F.pdf

// Basic OCR in OpenCV
http://blog.damiles.com/?p=93

// OCR with MODI in VC++
http://msdn.microsoft.com/en-us/library/aa167607(office.11).aspx
http://www.codeproject.com/KB/recipes/OCRwithMODI.aspx
http://tacfire.tistory.com/11
http://www1.devpia.com/Maeul/Contents/Detail.aspx?BoardID=274&MAEULNo=19&no=29012&ref=29012


// Tesseract OCR
http://code.google.com/p/tesseract-ocr/

// Tesseract OCR: Japanese
http://tomoakioshima.blogspot.com/2008/11/webocr_17.html
http://appsv.ocrgrid.org/nhocr/
http://code.google.com/p/ocropus/
http://code.google.com/p/nhocr/


// --------------------------------------------------------
#
# Tesseract
#
# godmode2k@hotmail.com
# 2010.03.12
#
// --------------------------------------------------------
# Tesseract OCR Engine - Technical Talk at OpenFest’2009
http://www.nakov.com/blog/2009/11/08/tesseract-ocr-engine-technical-talk-at-openfest2009/

# Get Source
aaa@aaa:/tmp$ svn checkout http://tesseract-ocr.googlecode.com/svn/trunk tesseract-ocr

# Get Language Data
# r310 Thought better of having the large CJK data files in svn
aaa@aaa:/tmp$ svn checkout -r 309 http://tesseract-ocr.googlecode.com/svn/trunk tesseract-ocr-r309

aaa@aaa:/tmp/tesseract-ocr$ ./runautoconf
aaa@aaa:/tmp/tesseract-ocr$ ./configure
aaa@aaa:/tmp/tesseract-ocr$ make
aaa@aaa:/tmp/tesseract-ocr$ mv tessdata tessdata_bak
aaa@aaa:/tmp/tesseract-ocr$ cp -r ../tesseract-ocr-r309/tessdata/ .
aaa@aaa:/tmp/tesseract-ocr$ cp -r ../tesseract-ocr-r309/tessdata/ /usr/local/share/
aaa@aaa:/tmp/tesseract-ocr$ api/tesseract test.tif test_out -l kor
Tesseract Open Source OCR Engine with LibTiff
aaa@aaa:/tmp/tesseract-ocr$ cat test_out.txt
...

// --------------------------------------------------------





// 템플릿 매칭에 기반한 한글 지문자 인식
http://www.robotian.net/akaii/publication/paper/KSPC2007.pdf


-----
Cheers,
June

[CV] CV/IP Algs Study

Prewitt, Roberts, Scharr, Sobel, Laplace Operator and Canny Edge Detection

Reference:
// Sobel Edge Detection with C++ & CImage
http://www.pranaypatel.com/?page_id=99
http://en.wikipedia.org/wiki/Sobel_operator

// Edge Detection Tutorial
http://www.pages.drexel.edu/~weg22/edge.html

// Canny Edge Detection Tutorial
http://www.pages.drexel.edu/~nk752/cannyTut2.html#Step%204

// Canny, Sobel, Laplace Edge, Threshold, AdaptiveThreshold
http://www.agness4u.com/tc/entry/Canny-Sobel-Laplace-Edge-Threshold-AdaptiveThreshold?category=32

// 2005 Fall Digital Signal Processing: Assignment #2: Image Enhancement
http://ricanet.com/new/data/hw/vision/document-2.pdf

// Fast Edge Detection Open Source
http://code.google.com/p/fast-edge/
http://code.google.com/p/fast-edge/source/browse/trunk/%20fast-edge/fast-edge.c


Reference ebook and book
// Computer Vision: Algorithms and Applications - (c) Richard Szeliski, Microsoft Research
http://research.microsoft.com/en-us/um/people/szeliski/Book/
Latest draft
November 23, 2009 (image-based rendering chapter)
http://research.microsoft.com/en-us/um/people/szeliski/Book/drafts/SzeliskiBook_20091123_draft.pdf

// IP 및 CV 책 추천 (abroad)
http://blog.naver.com/jjaktung/60059246161

:: 영상처리

1. 제목: Computer Imaging "Digital Image Analysis and Processing"
   출판사: CRC PRESS BOOK
   저자: Scott E Umbaugh
   추천이유: 책의 내용은 이론을 바탕으로 예제 중심으로 잘 만들었다고 생각하며 Low Processing에만 국한되지 않고 high processing 적인 요소까지 다루고 있기 때문에 유용할 것이라는 생각이 듭니다. 영상처리와 관련된 왠만한 알고리즘들은 CVIP 툴 킷을 이용하여 유용하게 쓸 수 있습니다. 특히, 개발 중간 단계에서 자신이 직접 구현한 영상처리 알고리즘이 맞는지 결과를 확인 할 때 CVIP 툴 킷을 이용하면 아주 유용하답니다.

2. 제목: Digital Image Analysis "selected techniques and applications"
   출판사: Springer
   저자: Walter G. Kropatsch, Horst Bischof
   추천이유: 일반적인 영상처리 서적이 기본적인 이론을 다루는 반면에 이 책은 알려지지 않은 유용한 techniques을 많이 소개하고 어느 분야에 적용하였을 때 유용한지 잘 기술되어 있습니다. (개인적으로 가장 아끼는 책중에 하나입니다.)

3. 제목: The Image Processing Handbook
   출판사: CRC PRESS BOOK
   저자: John C. Russ
   추천이유: 전반적으로 다루는 내용은 곤잘레스의 DIP와 비슷하지만 DIP가 중급 이상의 독자에 초점을 맞추고 있는 반면에 이 책은 초보자도 쉽게 접근하여 읽을수 있다는 장점을 가지고 있습니다.

4. 제목: Digital Image Processing Algorithms And Applications
   출판사: Prentice Hall
   저자: PITAS
   추천이유: 영상처리와 관련된 기본적인 알고리즘을 C로 구현해놨으며 오래된 책이지만 입문자들에게 유용한 책이라고 생각을 합니다.

5. 제목: Practical Algorithms For Image Analysis "Description, Example, And Code"
   출판사: CAMBRIDGE
   저자: Michael Seul, Lawrence O` Gorman, Michael J. Sammon
   추천이유: 제목에서 볼 수 있듯이 영상 분석과 관련된 알고리즘의 이론과 예, 그리고 코드까지 직접 제공하는 책입니다.

6. 제목: Feature Extraction & Image Processing
   출판사: Newes
   저자: Mark Nixon & Alberto Aguado
   추천이유: 영상처리에서 가장 중요한 영역중에 하나인 특징 추출에 관한 내용을 자세하게 다루었으며 관련된 알고리즘 또한 제공하고 있습니다.

7. 제목: Dealing with Texture
   출판사: WILEY
   저자: Maria Petrou & Pedro Garcia Sevilla
   추천이유: 일반적인 영상처리 서적들이 Texture에 대해 교과서적인 내용만을 다루는데 비해서 영상에서 가장 유용한 정보를 제공하    는 특징 중 하나인 Texture에 대해서 이론적 접근을 통해서 깊이 있는 내용을 다루고 있습니다. 개인적으로 어렵긴 하지만 참 잘 만든 책이라고 생각을 합니다. 영상 분류의 기본이 되는 Texture에 관심이 있으신 분들은 참고하시면 좋은 서적이 될 것 같습니다.


:: 컴퓨터 비전

1. 제목: COMPUTER VISION
   출판사: Prentice Hall
   저자: Linda G. Shapiro & George C. Stockman
   추천이유: 컴퓨터 비전과 관련하여 개인적으로 곤잘레스의 DIP 처럼 Bible라고 생각하는 책입니다. 아주 최신적인 내용을 다루고 있지는 않지만 개념을 잡고 전반적인 이해를 하는데 유용한 책이 될 것입니다.

2. 제목: Emerging Topic In Computer Vision
   출판사: Prentice Hall
   저자: Gerard Medioni & Sing Bing Kang
   추천이유: 컴퓨터 비전의 전통적인 내용부터 Tensor Voting과 같은 최신 내용까지 포괄적으로 잘 다루고 있으며 컴퓨티 비전에 관해 기본적인 내용이 들어간 툴 킷을 제공하고 있습니다.

3. 제목: Computer Vision and Applications
   출판사: ACADEMIC PRESS
   저자: Bernd Jahne, Horst Haubecker
   추천이유: 센서부터 패턴 인식 및 시스템 적용까지 전반적인 내용을 잘 다루고 있으며 특히 응용 및 적용 분야에서 참고하시면 유용한 책이라고 생각을 합니다.

4. 제목: Introduction Techniques for 3-D Computer Vision
   출판사: Prentice Hall
   저자: Emanuele Trucco, Alessandro Verri
   추천이유: 컴퓨터 비전과 관련된 기본적인 알고리즘을 이론과 함께 설명하고 있으며 소스코드도 제공하고 있습니다. 책이 오래되서 최신 내용까지 반영하지 못하지만 비전 관련 기본적인 알고리즘을 익히는데는 상당히 유용한 책이라고 생각을 합니다.

5. 제목: 3-D IMAGE PROCESSING ALGORITHMS
   출판사: WILEY
   저자: Nikolaidis, Pitas
   추천이유: 컴퓨터 비전과 관련된 최신적인 알고리즘까지 자세하게 제공하고 있으며 꼭 필요한 내용만을 충실하게 다룬 것 같습니다.

6. 제목: Computer Vision Algorithms In Image Algebra
   출판사: CRC PRESS
   저자: Gerhard X. Ritter, Joseph N. Wilson
   추천이유: 제 3판까지 나와 있으며 일반적인 서적들이 수학적인 내용에 깊이가 없는 반면에 컴퓨터 비전과 관련된 알고리즘을 수학적으로 접근하여 순차적으로 자세히 표현하고 있다는게 이책의 매력인 것 같습니다.

7. 제목: Dictionary of Computer Vision and Image Processing
   출판사: WILEY
   저자: R.B. Fisher 외 다수
   추천이유: 스테레오 정합과 관련된 연구를 시작하면서 Ground truth라는 용어를 몰라서 오랫동안 웹을 검색한 적이 기억납니다. 영상처리와 컴퓨터 비전에 관련된 용어들을 사전으로 만들어서 개념을 제공하고 있으며 paper나 원서를 보실 때 혹시나 단어에 내재된 뜻을 모르신다면 이 사전을 참고하시면 왠만한 용어들은 다 설명이 되어 있을 것입니다.


[Algorithm and Code]

----------------------------------
:: Thinning
----------------------------------
Source:
http://cafe.naver.com/ArticleRead.nhn?clubid=11534583&articleid=7621&menuid=80&boardtype=L&page=1

* OpenCV Source Code *
IplImage* src = 0;
src = cvLoadImage("2\\rkdur.jpg", 3);  

IplImage* temp1=cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 1);
IplImage* temp2=cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 1);

cvCvtColor(src, temp1, CV_RGB2GRAY); // 명암도 영상이라면 이건 필요없겠죠.
cvThreshold(temp1, temp1, 125, 255, CV_THRESH_BINARY); // 이진화합니다.

temp2 = Thinning(temp1); // 세선화입니다.

cvNamedWindow( "1", CV_WINDOW_AUTOSIZE );
cvShowImage( "1", temp1 );
cvNamedWindow( "2", CV_WINDOW_AUTOSIZE );
cvShowImage( "2", temp2 );

사용하실예정이던 '기' 그림을 그대로 사용하시겠다면

cvThreshold(temp1, temp1, 125, 255, CV_THRESH_BINARY_INV);

로 바꾸시면 됩니다.

   [결과]

----------------------------------

----------------------------------
:: Morphology
----------------------------------
Source:
Morphology-based Operations
----------------------------------

[Theory]
----------------------------------
Raster, Interlacing Scan
Source: http://www.sparkysworld.co.uk/interlacing.htm


----------------------------------
QR code
----------------------------------
Android QR Code
http://com.google.zxing.qrcode.encoder
qrCode.getMatrix().getArray();
http://code.google.com/apis/chart/types.html#qrcodes
http://stackoverflow.com/questions/2050263/using-zxing-to-create-an-android-barcode-scanning-app
http://code.google.com/p/zxing/source/browse/#svn/trunk/core/src/com/google/zxing
http://marumarusan003.blog8.fc2.com/blog-entry-115.html
http://www.codeproject.com/KB/cs/qrcode.aspx
http://qrcode.sourceforge.jp/


-----
Cheers,
June

[CV] Microsoft to Demo Augmented Reality at TechFest

Microsoft's Core Tools for Augmented Reality

Source:
http://research.microsoft.com/en-us/projects/augmented/default.aspx

We aim to enable people with mobile devices to receive continuously updated information about their surroundings by pointing a camera. The system is able to use image recognition to augment what a person sees on the screen with 2D or 3D graphics that track their environment in real time.

We demonstrate this using a treasure hunt game which guides the user along a previously authored path indoors or outdoors using geo-located arrows or floating 3D bubbles. Applications include games, city tours, and self-localization for mobile robotics. At its core, this is based on a technology for rapidly extracting distinctive features in images and matching them into a database of locations. This has already formed the backbone of released products such as Live Labs Photosynth(http://livelabs.com/photosynth/) and Microsoft Image Composite Editor(http://research.microsoft.com/en-us/um/redmond/groups/ivm/ICE/).

:: Technology
Our current technology extracts "interest points" and "invariant descriptors" from images to provide characteristic information about a visual scene and therefore allows matching from one scene to another. We used this to automatically stitch together many photographs in Microsoft Image Composite Editor, a tool for assembling panoramas. We also used it together with 3D reconstruction methods to create 3D scenes from collections of photographs in Live Labs Photosynth. Now that hand-held devices have video cameras and powerful processors we are developing real time solutions that are able to continuously match what is seen by the camera of a mobile device against a database of known views of locations, obtained for example from Windows Live Street-side imagery. This provides localization for the device that adds significant detail to any information gained from GPS.

Augmented reality is the process of adding computer graphics elements to images of real scenes to provide all kinds of information to the user. Since we are able to track the moment-by-moment mapping between the camera view and stored views, we can add any location-related data to the user's screen and make it look like it is part of the world. It is possible to imagine a virtual tour guide who points out the details of the city as we walk around. This is just one of many applications.

:: Video footage
Source:














-----
Cheers,
June

목요일, 11월 05, 2009

Fatal error: C3049U: out of store [cc_alloc(1207959560)]

Windows 용 ADS 1.2  에서 build 를 하다 보면 아래와 같이 error 가 나면서 종료 되는 경우가 있다. 엄청난 memory size 다. -_-;;;

Fatal error: C3049U: out of store [cc_alloc(1207959560)]
Compilation abandoned.

보통의 경우엔 아래의 solution 과 같이 compile 시에 '-g' option 을 제거 해주는 것인데 '-g' 가 없음에도 불구하고 동일한 error 가 나타나는 경우가 있다.

[SOLUTION]
Source: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0435a/index.html
C3048U: out of store [cc_alloc(N)] while compiling -g
C3049U: out of store [cc_alloc(N)]
A storage allocation request by the compiler failed.  Compilation of the debugging tables requested with the -g option may require a great deal of memory. Recompiling without -g, or with the program broken into smaller pieces, may help.
C3050U: Compilation aborted.

뚜렷한 방법은 없지만, ASD 1.2 가 아닌 Cygwin 용 ARM toolchain 을 이용하면 error 없이 build 가 가능 했다.

[Cygwin 용 ARM Toolchain Link]
* Source: http://forum.falinux.com/zbxe/?document_srl=507956
* Cygwin arm-toolchain 파일(cygwin-arm-linux-gcc-4.1.1.tar.gz): ftp://ftp.falinux.com/cygwin/recommendation/cygwin-arm-linux-gcc-4.1.1.tar.gz



하지만, 분명 ADS 1.2 에도 방법이 있지 않을까 싶다.


-----
Cheers,
June

일요일, 11월 01, 2009

[CV] OpenCV

앞으로 OpenCV 에 관련된 글은 이곳에 작성 하도록 하겠다.


//---------------------------------------------------
// [OpenCV] 각종 Tutorial
// --------------------------------------------------
* CYLOD Vision & Robot 에서 제공
// --------------------------------------------------


//---------------------------------------------------
// [OpenCV] 자주쓰는 기능들 모음
// --------------------------------------------------
Source: http://kimhj8574.egloos.com/4734597


기억력의 한계로 자주쓰는 기능들을 자꾸 까먹어 애먹을 때가 많아 자주쓰는 기능들을 정리해 놓는다.
*** IplImage 관련,  생성과 해제 등
//생성
IplImage *srcimg_R  = NULL;
srcimg_R  = cvCreateImage(cvSize(m_width,m_height), 8, 3);   //cvSize(640,480) 같은 것도 됨
srcimg_R  = cvCreateImage(cvGetSize(src_color), 8, 3);           //요것도 됨.  다른 IplImage 사이즈 받아와서

//요런것도 됨
CvSize img_size;   
img_size.height = ImageHeight;
img_size.width  = ImageWidth;
IplImage* BGR_image = cvCreateImage(img_size, IPL_DEPTH_8U, 3); 

//이미지 복사하기
src = cvCloneImage(src_img);  //src가 비어있어야 함.  아니면 메모리 계속 쌓인다
cvCopy(src_img, src_img2);

//0으로 초기화
cvZero(src_img);

//해제
if(srcimg_R)
  cvReleaseImage(&srcimg_R);

*** IplImage 안의 이미지 화소 조절하기
...
cvGetReal2D(srcimg, i, j);             //높이가 i, 폭이 j
cvSetReal2D(srcimg, i, j, value);    //value는 설정할 값
...

*** 이미지 불러오기, 저장하기
//불러오기
TmpLImg = cvLoadImage("img_InElevator_1_L.bmp");    //간단하게, TmpLImg는 IplImage

//복잡하게
if ((TmpLImg = cvLoadImage("img_InElevator_1_L.bmp")) == 0)  // load left image
{
   printf("%s", "left image file read has failed!! \n");
   return 0;
}

//저장하기
char file_name[20];
sprintf(file_name,"img_R.bmp");            //파일이름 맹글기
cvSaveImage(file_name,srcimg_R);   //srcimg_R 이라는 IplImage를 저장

*** 창 만들고 닫기 등등
//생성
cvNamedWindow("Right Original", CV_WINDOW_AUTOSIZE);

//창 움직이기 - uv 좌표로 배치함
cvMoveWindow("source_color",610,0);

//보이기
cvShowImage( "Right Original", srcimg_R );

//창 닫기
cvDestroyAllWindows();  //모든 OpenCV 윈도우 닫기

//특정 윈도우만 닫기
cvDestroyWindow("Right Original");

*** canny edge detect 사용하기
...
IplImage *canny_R   = NULL;
canny_R    = cvCreateImage(cvSize(m_width,m_height), 8, 1);
...
cvCvtColor(srcimg_R, grayimg_R, CV_BGR2GRAY);   //원본 컬러이미지를 흑백으로 변환하고
cvCanny( grayimg_R, canny_R, 40, 130, 3 );             //그 흑백이미지를 캐니로 변환

*** HLS 이미지로 변환하기
...
IplImage* src_hlsimg = cvCreateImage(cvSize(m_width,m_height), 8, 3);  //HLS 저장할 곳

//각 속성들 저장할 곳 선언
IplImage* Hue         = cvCreateImage(cvSize(m_width,m_height), 8, 1);
IplImage* Intensity   = cvCreateImage(cvSize(m_width,m_height), 8, 1);
IplImage* Saturation = cvCreateImage(cvSize(m_width,m_height), 8, 1);

cvCvtColor(srcimg, src_hlsimg, CV_BGR2HLS);   //src_hlsimg IplImage 구조체에 HLS 이미지 담긴다

cvCvtPixToPlane( src_hlsimg, Hue, Intensity, Saturation, NULL );  //HLS 이미지 각 속성별로 나눔
cvCvtPlaneToPix( Hue, Intensity, Saturation, NULL, hsvVideo2 );  //도로 합치기

*** 창으로 부터 키 입력 받기
...
pressed_key=cvWaitKey(0) ;
  if(pressed_key=='q')    //q 키가 누르면 빠져나가기
    break;
  else if(pressed_key=='c')  //캡쳐 키 누르면 캡쳐
  {
    timer=time(NULL);  //현재시간저장
    t=localtime(&timer); //지역시간
    sprintf(file_name,"img_%4d%02d%02d%02d%02d%2d.bmp",t->tm_year + 1900, t->tm_mon +1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); //파일이름 맹글기
    cvSaveImage(file_name, src_color);
    //확인메시지출력
    printf("%s file saved is success!!\n",file_name);
  }

*** 이미지 크기 줄이기
//생성
pEviMonitor = cvCreateImage(cvSize(m_pImgWidth, m_pImgHeight), IPL_DEPTH_8U, 1);
pEviMonitor2 = cvCreateImage(cvSize(m_pImgWidth/2, m_pImgHeight/2), IPL_DEPTH_8U, 1);  //  1/2 크기로 생성

//크기 줄이기
cvResize(pEviMonitor, pEviMonitor2, CV_INTER_LINEAR);  // For Resize

*** 화면에 글자 쓰기
char s_output_result[50];
CvFont font;
...
sprintf(s_output_result,"sum vector x:%1.3f  y:%1.3f",sumvector_x,sumvector_y );    //우선 sprintf로 문자열 생성
cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX|CV_FONT_ITALIC, 0.5, 0.5, 0, 1);  //이런 저런 설정.
cvPutText(src_color, s_output_result ,cvPoint(15,20),&font,cvScalar(0,255,0));   //cvPoint로 글자 시작 위치 설정(uv)
//void cvInitFont(CvFont* font, int font_face, double hscale, double vscale, double italic_scale, int thickness)

*** 트랙바 생성
int hue_threshold=139;  //Hue 값의 피부색 threshold
cvNamedWindow( "HLS_image", CV_WINDOW_AUTOSIZE );
cvCreateTrackbar("Hue","HLS_image",&hue_threshold,255, NULL );  //중요한 부분은 요거

*** 마우스 입력
void on_mouse( int event, int x, int y, int flags, void* param );
......

cvSetMouseCallback( "LKTracker", on_mouse, NULL );
......

void on_mouse( int event, int x, int y, int flags, void* param )
{
    if( !image )
        return;
    if( image->origin )
        y = image->height - y;
    if( event == CV_EVENT_LBUTTONDOWN )
    {
        pt = cvPoint(x,y);
        add_remove_pt = 1;
    }
}

*** 인클루드 하는 것들
#include          //영상처리를 위한 헤더
#include   //카메라로 영상을 입력받거나 이미지를 읽어들이고 화면에 보여주기 위한 헤더

*** good feature to track
IplImage *eig_image = NULL; 
IplImage *temp_image = NULL; 
eig_image  = cvCreateImage(cvSize(width,height), 32, 1);
temp_image = cvCreateImage(cvSize(width,height), 32, 1);

CvPoint2D32f frame1_features[4000];  //추출된 점들 저장하는 장소
int number_of_features; 
number_of_features = 400;  //추출되는 점의 개수를 제한

//안됨.  버전마다 매개변수 다른듯
//cvGoodFeaturesToTrack(src_gray, eig_image, temp_image, frame1_features, &number_of_features, .01, .01, NULL);
cvGoodFeaturesToTrack(src_gray, eig_image, temp_image, frame1_features, &number_of_features, 0.01, 5, 0, 3, 0, 0.04 );
//&number_of_features 로 추출된 점의 개수 나온다.  추출되는 점의 개수를 입력으로 제한함과 동시에 출력도...

*** 캠 입력받기
IplImage *src;       //source 이미지니까 src로 이름지음

//capture for cam
 CvCapture* capture = cvCaptureFromCAM(0);
 //get init scene
 cvGrabFrame(capture);
 src=cvRetrieveFrame(capture);
......
cvGrabFrame(capture);
src=cvRetrieveFrame(capture);
......
cvReleaseCapture( &capture );

//다른 방법
IplImage *src;
CvCapture* capture = cvCaptureFromCAM(0);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH,640);    //잘 안됨
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT,480); 
...
src = cvQueryFrame( capture );.
...

*** Optical Flow
voidcvCalcOpticalFlowPyrLK(
    const CvArr* prev,   // 첫 번째 이미지
    const CvArr* curr,   // 두 번째 이미지
    CvArr* prev_pyr,   // 첫 번째 이미지의 피라미드
    CvArr* curr_pyr,   // 두 번째 이미지의 피라미드
    const CvPoint2D32f* prev_features,   // 첫 번째 이미지에서 원래 점의 위치
    CvPoint2D32f* curr_features,   // 두 번째 이미지에서 찾은 점의 위치
    int count,   // 찾으려는 점의 갯수
    CvSize win_size,   // 탐색 윈도우의 크기
    int level,   // 피라미드의 레벨 지정
    char* status,  // status=1:이동된 위치를 찾은 경우, status=0:이동된 위치를 찾지 못한 경우
    float* track_error,  // NULL
    CvTermCriteria criteria,   // 종료조건
    int flags);   // CV_LKFLOW_INITIAL_GUESSES 등

*** Line Fitting  (polar 코디네이트가 아니라 단점 있음)
int count = 0;        // total number of points   
float *line;     

CvPoint  left, right;    

//CvMat point_mat = cvMat( 1, count, CV_32SC2, mid_points );     
//cvFitLine( &point_mat, CV_DIST_L2 , 0, // line[0]:vector_x, line[1]:vector_y                
// 0.01, 0.01,  line );        // line[2]:x_n, line[3]:y_n     
//
long double a, b, c, d, e, f; 
////b가 기울기, a가 절편 
//b = line[1]/ line[0];        
//a = line[3]- b*line[2];        
b=((float)right.y-(float)left.y)/((float)right.x-(float)right.y);
//left.x=mid_points[0].x;
//left.y=b*left.x+a;
//right.x=mid_points[count-1].x;
//right.y=b*right.x+a;
//CvPoint center;     
//center.x = line[2];     
//center.y = line[3];     // can draw from left to right directly     
//cvLine( processed_image, center, left, CV_RGB(255,255,255), 1, 8 );     
cvLine( Draw_results, left, right, CV_RGB(255,0,0), 1, 8 );     

*** Mean-Shift Segmentation
//입출력 IplImage, spatial과 color radius 매개변수, level of scale pyramid(2 또는 3 적당) 
cvPyrMeanShiftFiltering(src_color, src_result, 2, 40, 3);

*** OpenCV 외 유용한 코드들
//파일에서 불러오기
FILE *fp = fopen(".\img.txt", "r");

if(fp == NULL) 
    return false;
while (fgets(buffer,BUFFERSIZE,fp))
{
    label = strtok(buffer,ct);
    if(label == NULL) 
        continue;
    pDPT[p_index*NUMOFDIMESION] =  (float)atof(label);
    pDPT[p_index*NUMOFDIMESION + 1] = (float)atof(strtok(NULL,ct));
    pDPT[p_index*NUMOFDIMESION + 2] = (float)atof(strtok(NULL,ct));
    pBGR[c_index*NUMOFDIMESION] = (unsigned char)atoi(strtok(NULL,ct));
    pBGR[c_index*NUMOFDIMESION +1] = (unsigned char)atoi(strtok(NULL,ct));
    pBGR[c_index*NUMOFDIMESION +2] = (unsigned char)atoi(strtok(NULL,ct));
    pGray[c_index] = pBGR[c_index*NUMOFDIMESION];
    strtok(NULL,ct);
    strtok(NULL,ct);
    temp = strtok(NULL,ct);
    if(atoi(&temp[1]) <= 0)
    {
        // zero disparity or invalid 3D point
        pDPT[p_index*NUMOFDIMESION] =  INVALID_DEPTH_INFO;
        pDPT[p_index*NUMOFDIMESION + 1] = INVALID_DEPTH_INFO;
        pDPT[p_index*NUMOFDIMESION + 2] = INVALID_DEPTH_INFO;
    }

    p_index++;
    c_index++;
}
fclose(fp);

//3D만 가져올 때
char buffer[1024];
char *label;
char ct [] = " ,\t\n";
int index=0;

FILE *fp = fopen(".\img.txt", "r");
if(fp == NULL) 
    return;

while (fgets(buffer,1024,fp))
 {
  label = strtok(buffer,ct);
  if(label == NULL) 
   continue;
  p_3Dpt[index*3    ] = (float)atof(label);
  p_3Dpt[index*3 + 1] = (float)atof(strtok(NULL,ct));
  p_3Dpt[index*3 + 2] = (float)atof(strtok(NULL,ct));
  index++;
  if(index>=307200)
   break;
 }

fclose(fp);

//메모리, 용량 절약형 가져올 때
FILE *fp;
fp = fopen(file_name,"rt");
if(!fp)
{
  printf("\ncan not open 3dmfile\n");
  return false;
}
while (fgets(buffer,2000,fp))
{
  label = strtok(buffer,ct);
  if(label == NULL) continue;
  if(!strcmp("ImageWidth",label))
  {
    //m_imagewidth = atoi(strtok(NULL,ct));///samplingratio;
  }
  else if(!strcmp("ImageHeight",label))
  {
    //m_imageheight = atoi(strtok(NULL,ct));///samplingratio;
  } 
  else if(!strcmp("F",label))
  {
    double x,y;
    double x3,y3,z3;
    x  = atof(strtok(NULL,ct));
    y  = atof(strtok(NULL,ct));
    
    x3  = (double)atof(strtok(NULL,ct));
    y3  =  (double)atof(strtok(NULL,ct)); 
    z3  = (double)atof(strtok(NULL,ct));
    m_p3Dpt[3*(GetWidth() * (int)y + (int)x)  ] = x3;
    m_p3Dpt[3*(GetWidth() * (int)y + (int)x)+1] = y3;
    m_p3Dpt[3*(GetWidth() * (int)y + (int)x)+2] = z3;
    //y3  = -(double)atof(strtok(NULL,ct));
    // SVS ver 3.2 used mm scale
    //x3DPoints.push_back((float)x3*scale);
    //y3DPoints.push_back((float)y3*scale);
    //z3DPoints.push_back((float)z3*scale);
    // SVS ver 4.4 use m scale (model is saved by using m scale)
    //x3DPoints.push_back((float)x3);
    //y3DPoints.push_back((float)y3);
    //z3DPoints.push_back((float)z3);
    //if(idxDB == WCCup) printf("\nx=%f,\ty=%f,\tz=%f",x3,y3,z3);
  } 
}
fclose(fp);

//파일로 저장하기
FILE *fp = fopen("@@_FilterResult.txt", "at+");
fprintf(fp, "%d %f\n", nFrameNum, pEstimatedObjectPose[11]);
fclose(fp);

//메모리 카피
memcpy(src_color->imageData, m_pColorImage, sizeof(unsigned char)*width*height*3); 

//3D를 2D로 그리기 (대충)
for(int i=0;i
{
    for(int j=0;j
    {
        if((m_p3Dpt[3*(i+width*j)+2]>0.5)&(m_p3Dpt[3*(i+width*j)+2]<2.0))
            view_3D->imageData[i+width*j]=((m_p3Dpt[3*(i+width*j)+2]-0.5)/1.5)*255;
        else
            view_3D->imageData[i+width*j]=0;
    }
}

// --------------------------------------------------



-----
Cheers,
June