수요일, 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

화요일, 10월 27, 2009

Windows 7 SDK Issue

앞으로 Windows 7 SDK 에 관한 내용은 여기에 작성 하겠음

* Windows 7 SDK Download Page
http://www.microsoft.com/downloads/details.aspx?familyid=71DEB800-C591-4F97-A900-BEA146E4FAE1&displaylang=en


-----
Cheers,
June

old Linux Repository

Ubuntu Linux Repository

* Ubuntu 7.10 (Gutsy Gibbon) // October 26, 2009, present, [works good]
http://ubuntu-mirror.cs.colorado.edu/ubuntu/
deb http://ubuntu-mirror.cs.colorado.edu/ubuntu gutsy main multiverse restricted universe
deb-src http://ubuntu-mirror.cs.colorado.edu/ubuntu gutsy main multiverse restricted universe

deb http://ubuntu-mirror.cs.colorado.edu/ubuntu gutsy-backports main multiverse restricted universe
deb-src http://ubuntu-mirror.cs.colorado.edu/ubuntu gutsy-backports main multiverse restricted universe

deb http://ubuntu-mirror.cs.colorado.edu/ubuntu gutsy-proposed main multiverse restricted universe
deb-src http://ubuntu-mirror.cs.colorado.edu/ubuntu gutsy-proposed main multiverse restricted universe

deb http://ubuntu-mirror.cs.colorado.edu/ubuntu gutsy-security main multiverse restricted universe
deb-src http://ubuntu-mirror.cs.colorado.edu/ubuntu gutsy-security main multiverse restricted universe

deb http://ubuntu-mirror.cs.colorado.edu/ubuntu gutsy-updates main multiverse restricted universe
deb-src http://ubuntu-mirror.cs.colorado.edu/ubuntu gutsy-updates main multiverse restricted universe

-----
Cheers,
June

linux command-line tip

앞으로 command-line 관련 usage 나 tip 을 적겠다.

// ---------------------------------------------------------
// readelf
// ---------------------------------------------------------
$ readelf -S test2.o
There are 8 section headers, starting at offset 0x40:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al

  [ 0]                   NULL            00000000 000000 000000 00      0   0  0

  [ 1] .data             PROGBITS        00000000 000180 000009 00  WA  0   0  4

  [ 2] .text             PROGBITS        00000000 000190 00000e 00  AX  0   0 16

  [ 3] .comment          PROGBITS        00000000 0001a0 00001f 00      0   0  1

  [ 4] .shstrtab         STRTAB          00000000 0001c0 00003a 00      0   0  1

  [ 5] .symtab           SYMTAB          00000000 000200 000080 10      6   6  4

  [ 6] .strtab           STRTAB          00000000 000280 000020 00      0   0  1

  [ 7] .rel.text         REL             00000000 0002a0 000010 08      5   2  4

Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

// [3] .comment
$ readelf -x 3 test2.o

Hex dump of section '.comment':
  0x00000000 73734120 65646977 74654e20 65685400 .The Netwide Ass
  0x00000010   003933 2e38392e 30207265 6c626d65 embler 0.98.39.

$
// ---------------------------------------------------------

// ---------------------------------------------------------
// paste
// ---------------------------------------------------------
1.txt
AAAAAAAAAA
BBBBBBBBBB

2.txt
A'A'A'A'A'A'A'A'A'A'
B'B'B'B'B'B'B'B'B'B'

1 + 2 = ?
Result
3.txt
[1.txt]    [2.txt]
AAAAAAAAAA A'A'A'A'A'A'A'A'A'A'
BBBBBBBBBB B'B'B'B'B'B'B'B'B'B'

$ paste 1.txt 2.txt > 3.txt  ('&gt' is '<')
or
$ awk '{ printf $0" "; getline < "2.txt"; print }' 1.txt   ('&gt' is '<')
// ---------------------------------------------------------

// ---------------------------------------------------------
// VIM
// ---------------------------------------------------------
* Print:
:set number
:set printoptions=number:y
:ha

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

// ---------------------------------------------------------
// Perl
// ---------------------------------------------------------
* Perl Range Operator
* Reference: http://www.perlmonks.org/?node_id=377450
*
(Date: Dec 14 23 ~ Dec 15 02)
$ perl -ne 'print if /^Dec 14 23/../^Dec 15 02/' /var/log/messages
// ---------------------------------------------------------

-----
Cheers,
June

화요일, 10월 20, 2009

SKT WIPI SDK in VS2005, VS2008

SKT WIPI SDK 를 VS2005, VS2008 에서 사용하기

 - VC++ 6.0 은 2 번은 pass, VC++ 7.0 ? ~ VC++ 9.0 은 모두 해당 된다.

1. SDK Bin directory 에 Macro directory 만들기
  - MIF 파일을 batch script 에서 사용할 때 발생할 수 있는 문제를 피하기 위한 trick 이다.
 C:/Program Files/WIPI20 SDK/Bin/> mkdir Macro

2. VS2005, VS2008 의 crtdefs.h 에서 time_t 문제
 - VS2008 기준: c:/program files/microsoft visual studio 9.0/vc/include/crtdefs.h
 - SKT WIPI SDK 의 MCstd.h 파일에서 typedef unsigned long M_Time_t; 가
 VC++ 와 같은 이름인 time_t 로 type definition 되어 있어서 linking 할 때
 VC++ 의 header crtdefs.h 에서 redefinition error 가 난다.
 이를 피하기 위해 다음과 같이 SKT WIPI SDK 의 header MCstd.h 파일의
 일부분을 수정한다.

 C:/Program Files/WIPI20 SDK/Include/API/MCstd.h: 70

 변경 전
 #define time_t         M_Time_t

 변경 후
 #define time_t_wipi    M_Time_t

3. VS2005~2008 Project Property
 A. Debugging -> Command:  $WIPI20 SDK/Bin/WIPIEmulator.exe
 B. C/C++ -> General -> Additional Include Directories: $WIPI20 SDK/Include;$WIPI20 SDK/Include/API;$WIPI20 SDK/Include/API/WFC
 C. Linker -> General -> Additional Library Directories: $WIPI20 SDK/Lib

4. ADS 1.2 에서 compile 시에 extern 관련 error 가 많이 난다면 다음과 같이 하자

 C:/Program Files/WIPI20 SDK/Include/API/MCtypes.h:58

 변경 전
 typedef    signed char    M_Char;

 변경 후
 typedef    char    M_Char;



나의 경우엔 이렇게 해서 잘 사용하고 있다.

-----
Cheers,
June

월요일, 10월 19, 2009

일기 (2009.10.19)






























2009년 10월 17일 오랜만에 종묘공원을 지나서 창경궁에 다녀왔다.

아침까지만 해도 번개가 치고 비바람이 불었는데,
언제 그랬냐는 듯이 다시 맑아졌다.

그래서 오랜만에 바람도 쐐고 머리도 식힐겸 외출을 했다.

경복궁에 들려 근정전에서 산책을 한 뒤 경복궁 밖에 있는
박물관에서 관람하는 것도 좋지만 개인적으로 종묘공원을 지나
창경궁으로 산책을 하는 것이 너무 좋다.

옛 조상들이 느꼈을 듯한 차갑지만 시원한 바람 소리, 깨끗한 하늘과 구름,
그리고 여기저기에서 지저귀는 새소리 들...

정말이지 근심 걱정 없이 편안한 느낌으로 산책할 수 있는 곳이다.
이번이 두 번째 인데 역시나 카메라를 들고 이곳저곳 촬영을 하며 정취를 느껴본다.



촬영해온 사진 중에 위의 사진이 가장 마음에 드는 사진 이지만,
quality 만을 보았을 땐 불만족이다.

하늘의 구름이 보이게 하면 너무 어둡고, 조금 밝게 하면 구름이 보이지 않고... 아잉...
Camera specification 의 한계 때문에 ... 음.. 이러면 핑계이고.. ^^;

아직 technique 이 많이 부족한 모양이다.
연습을 많이 하고 경험을 쌓다 보면 분명 좋은 결과물이 있을 것이라 믿는다.


궁에 들어서면 항상 조상님들께 감사한 마음을 마음으로 전한다.
나의 간절한 바람이 택도 없겠지만, 나라도 잘 보살펴 주시고
우리가족 모두 다치지 않고 아프지 않게 건강 꼭 챙겨 주시고
가족 모두 하는 일 모두 잘 될 수 있도록 돌보아 주셨으면 좋겠다.

-----
Cheers,
June

목요일, 10월 01, 2009

ActiveX Tip

이곳엔 ActiveX Tip 을 작성한다.

// ------------------------------------------------------------------
// 내가 사용하는 Cabinet 생성 Batch Script 이다.
//
// * 사용방법
//     @echo off
//     REM actx_pack.bat clean
//     actx_pack.bat actx_pack ocx n
// ------------------------------------------------------------------
@echo off

REM
REM Purpose: ActiveX Script
REM Note:
REM Filename: actx_pack.bat
REM Date: Dec. 13. 2006
REM Author: HoJung Kim (godmode2k@hotmail.com)
REM

set APP_NAME=%0
set BASE_PATH=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin
set CHECK_PATH=C:\codesign

REM set CABARC_BIN=%BASE_PATH%\cabarc.exe
REM set MAKECERT_BIN=%BASE_PATH%\makecert.exe
REM set CERT2SPC_BIN=%BASE_PATH%\cert2spc.exe

set CABARC_BIN=%CHECK_PATH%\cabarc.exe
set MAKECERT_BIN=%CHECK_PATH%\makecert.exe
set CERT2SPC_BIN=%CHECK_PATH%\cert2spc.exe

set SIGNCODE_BIN=%CHECK_PATH%\signcode.exe
set SETREG_BIN=%CHECK_PATH%\setreg.exe
set CHKTRUST_BIN=%CHECK_PATH%\chktrust.exe

echo ----------------------------------------------------
echo [%APP_NAME%]: ActiveX Pack Script
echo ----------------------------------------------------
if "%1" == "" goto ERROR
if "%2" == "" goto ERROR
if "%3" == "" goto ERROR

if "%1" == "clean" goto CLEAN

REM NOTE:
REM    USING binary from "C:/Program Files/Microsoft Platform SDK for Windows Server 2003 R2/Bin"
echo [%APP_NAME%]: CAB
if "%2" == "ocx" %CABARC_BIN% N %1.cab ..\%1.ocx %1.inf .\*.DLL
if "%2" == "dll" %CABARC_BIN% N %1.cab ..\%1.dll %1.inf .\*.DLL
if "%3" == "n" goto ALL
if "%3" == "y" goto SIGNONLY

:ALL
echo [%APP_NAME%]: MAKECERT
%MAKECERT_BIN% -sv "%1.pvk" -n "CN=actx_pack ActiveX" %1.cer

echo [%APP_NAME%]: CERT2SPC
%CERT2SPC_BIN% %1.cer %1.spc

:SIGNONLY
REM NOTE:
REM    USING binary from "C:/codesign"
echo [%APP_NAME%]: SIGNCODE
REM %SIGNCODE_BIN% -v %1.pvk -spc %1.spc %1.cab -t http://timestamp.comodoca.com/authenticode
%SIGNCODE_BIN% -v %1.pvk -spc %1.spc %1.cab

echo [%APP_NAME%]: SETREG
%SETREG_BIN% -q 1 TRUE

echo [%APP_NAME%]: CHKTRUST
%CHKTRUST_BIN% %1.cab
goto CLOSE

:CLEAN
echo [%APP_NAME%]: Clean
del /q *.cab *.cer *.pvk *.spc
goto CLOSE

:ERROR
echo Usage: %APP_NAME% Filename(without .ext) FileType[ocx, dll] SignOnly[y|n]
goto CLOSE

:CLOSE
echo [%APP_NAME%]: Finish...
pause

REM _EOF_

-----
Cheers,
June

Compiler, Language Tip

이곳엔 앞으로 Compiler 및 Language 에 대해 작성한다.

----------------------------------------------------------------------------------
* Using and Porting the GNU Compiler Collection (GCC)
Source:
http://sunsite.ualberta.ca/Documentation/Gnu/gcc-3.0.2/html_mono/gcc.html
* Welcome to the IBM Linux compiler information center (XL C/C++)
Source:
http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp
* MS Visual Studio2010, Visual C++ 10 and C++0x White Paper (Korean)
Source:
http://download.microsoft.com/download/1/9/4/194B6F74-8A72-482D-AF0E-31CE9D855372/VisualC.PDF
* MS Visual Studio 2010 (C++0x Only)
Source:
http://vsts2010.net/category/Visual%20Studio%202010
----------------------------------------------------------------------------------

----------------------------------------------------------------------------------
* Byte Alignment(Pading Alignment)
----------------------------------------------------------------------------------
1. GNU/Linux
typedef struct _TypeA {
    int a;
    long b;
    double c;
    char d[10];
    unsigned short e;
}__attribute__(packed) DATA;

2. MS Visual C++
#pragma pack(push)
#pragma pack(1)
typedef struct _TypeA {
    int a;
    long b;
    double c;
    char d[10];
    unsigned short e;
}__attribute__(packed) DATA;
#pragma pack(0)
#pragma pack(pop)

----------------------------------------------------------------------------------
* Labeled Element Extension
----------------------------------------------------------------------------------
1. ANSI-C standard extension
DATA data = {
    .a = 10,
    .b = 11,
    .c = 12,
};


2. GCC Labeled Element Extension
DATA data = {
    a: 10,
    b: 11,
    c: 12
};

----------------------------------------------------------------------------------
* Bitwise Operation
----------------------------------------------------------------------------------
#include  "stdio.h"

void main(void) {
    // 0xFF 0xE0 (2byte Big-endian)
    printf( "Little-Endian: %d", (0xe0 << 8 | 0xff) );
    /*
    * 4bytes Big-endian to Little-endian
    int val = ((int)0x01 << 24) & 0xFF000000;
    val |= ((int)0x01 << 16) & 0xFF0000;
    val |= ((int)0x01 << 8) & 0xFF00;
    val |= ((int)0x01);
    */
}


-----
Cheers,
June

Shell Tip

여기엔 Linux Shell Tip 을 모아 본다.
여러개의 내용으로 따로 관리를 하다 보니 찾기도 조금 어렵고 급하게 사용하려고 하면 늘 사용하던게 아니니 잊어 버린다.


=== [awk tip] ===

./700a.210.1 ==변환==> ./700a.210.5

$ find . -name "700*" -print | awk -F. '{print "mv", $0, $1"."$2"."$3"."5}' | ksh -x


//! file 내용 수정 자동화 [
// -------------------------------------------------------------------------------------
// 조건
// -------------------------------------------------------------------------------------
---_---,03.00,0,00,___001,2000010100091723,2000010100091723,255.255.255.0:30,,,,,1,0,0,00,00N0,,00,,4000904200,,0,0,00,218857295723,KRW,,,,,,,,400,0,,0,X,,,X,99,01012345678,1,0,01012345678,1,0,,X,0,,,255.255.255.0,0,,01,,,0,0,,,

KRW,,,,,,,,50
KRW,,,,,,,,100
KRW,,,,,,,,400
255.255.255.0,0,,    // ,5,

KRW,,,,,,,,900
KRW,,,,,,,,1000
255.255.255.0,0,,    // ,x,
// -------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------
// test 1
// -------------------------------------------------------------------------------------
guest@cygwin ~/_tmp_/x2
$ cat x.dat | awk -FKRW,,,,,,,,400 '{print $2}' | awk -F255.255.255.0,0, '{print $1"255.255.255.0,0,""A"$2}'
,0,,0,X,,,X,99,01012345678,1,0,01012345678,1,0,,X,0,,,255.255.255.0,0,A,01,,,0,0,,,
// -------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------
// test 2
// -------------------------------------------------------------------------------------
guest@cygwin ~/_tmp_/x2
$ awk -FKRW,,,,,,,,400 '{ if($2){print "echo " $0 " | sed -e \"s/255.255.255.0,0,/255.255.255.0,0,5/g\" >> 1-1.dat"} else{print "echo " $0 ">> 1-1.dat"} }' 1.dat | sh
// -------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------
// test 3
// -------------------------------------------------------------------------------------
guest@cygwin ~/_tmp_/x2
$ awk -FKRW,,,,,,,, '{ if($2){print "echo " $2; if($2 ~ /^50/){print "echo [NEW]"}} }' 1.dat
// -------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------
// 응용 test
// -------------------------------------------------------------------------------------
SRC_FILENAME=%1
DST_FILENAME=`awk -F./ '{print "./_RES_/"%2 }' $SRC_FILENAME`
echo ---------[START] $SRC_FILENAME---------
awk -FKRW,,,,,,,, '{
if($2){
if($2 ~ /^50/ || $2 ~ /^100/ || $2 ~ /^400/ ){
print "echo " $0 " | sed -e \"s/255.255.255.0,0,/255.255.255.0,0,5/g\" >> $DST_FILENAME"
}
if($2 ~ /^900/ || $2 ~ /^1000/ ){
print "echo " $0 " | sed -e \"s/255.255.255.0,0,/255.255.255.0,0,X/g\" >> $DST_FILENAME"
}
}
}' $SRC_FILENAME | sh
echo ---------[FINISH] $SRC_FILENAME---------
// -------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------
// 최종 완성 test
// -------------------------------------------------------------------------------------
guest@cygwin ~/_tmp_/x2/zzz
$ cat m5.sh
#!/bin/sh

AWK_BIN=awk
SRC_FILENAME=$1
DST_FILENAME=`$AWK_BIN -F./ '{print "./_RES_/"%2 }' $SRC_FILENAME`

echo '---------[START] $SRC_FILENAME---------'
$AWK_BIN -FKRW,,,,,,,, '{
if($2){
if($2 ~ /^50/ || $2 ~ /^100/ || $2 ~ /^400/ ){
print "echo " $0 " | sed -e \"s/255.255.255.0,0,/255.255.255.0,0,5/g\" >> $DST_FILENAME"
}
if($2 ~ /^900/ || $2 ~ /^1000/ ){
print "echo " $0 " | sed -e \"s/255.255.255.0,0,/255.255.255.0,0,X/g\" >> $DST_FILENAME"
}
}
}' $SRC_FILENAME | sh
echo '---------[FINISH] $SRC_FILENAME---------'


guest@cygwin ~/_tmp_/x2/zzz
$
// -------------------------------------------------------------------------------------

// -------------------------------------------------------------------------------------
// Test
// -------------------------------------------------------------------------------------
$ find . -name "*.dat" -exec ./m5.sh {} \; -print
// -------------------------------------------------------------------------------------
// ]


-----
Cheers,
June

masm, nasm test code

MASM, NASM Assembler Test Code 이다.
테스트용으로만 사용하자.
NASM 의 Syscall 은 GNU/Linux 에서만 사용가능 하다.

; -------------------------------------------------------------
; @Project:
; @Purpose: Assembler Test Code
; @Author: HoJung Kim (godmode2k@hotmail.com)
; @Date: Since September 11, 2009
; @Lastest Modified:
; -------------------------------------------------------------
; @Build:
;    [MASM]
;    c:/masm5_0/MASM %1.asm,,,,
;    c:/masm5_0/LINK %1.obj,,;
;     [MASM32 BUILD]
;     @16 Bit
;        $ ml.exe /c /Zm %1.asm
;        $ link16.exe %1.obj,,;
;     @32 Bit
;        $ ml.exe /coff /c %1.asm
;        $ link.exe /SUBSYSTEM:CONSOLE %1.obj    // {CONSOLE|WINDOWS|...}
;
;    [NASM]
;    $ nasm -fh
;    // Linux
;    $ nasm -f aout .asm
;    $ ld -s -o $1 $1.o
;    // Cygwin
;    $ nams gnuwin32 $1.asm
;    $ ld -s -o $1 /lib/crt0.o $1.o
; -------------------------------------------------------------



; -------------------------------------------------------------
; [MASM]
; -------------------------------------------------------------
; --------------------------------------------
; 16 Bit
; --------------------------------------------
;.MODEL SMALL
;.STACK 100h
;
; --------------------------------------------
; 32 Bit
; --------------------------------------------
;.386
;.MODEL flat, stdcall
; --------------------------------------------
; PRESET
; --------------------------------------------
;option casemap: none    ; Upper/Lower Letter
; --------------------------------------------
; INCLUDE HEADER AND LIBRARY
; --------------------------------------------
;include        .\xxx.inc        ; Header
;includelib        .\xxx.lib        ; Library
;include        .\m32v10r\ml\include\user32.inc
;include        .\m32v10r\ml\include\kernel32.inc
;includelib    .\m32v10r\ml\lib\user32.lib
;includelib    .\m32v10r\ml\lib\kernel32.lib
;
;.DATA
;    CR        EQU        0Dh
;    LF        EQU        0Ah
;    MSG        DB        'STRING...!', '$', CR, LF
;    MSG2    DB        'Res = ', '$'
;    MSG3    DB        ?, '$', CR, LF
;
;.CODE
;MAIN PROC    ; 16 Bit
;_start:    ; 32 Bit
;    mov ax, @data
;    mov ds, ax
;    mov ah, 9
;    lea dx, MSG
;    int 21h
;
;    mov ax, 4c00h
;    int 21h
;MAIN ENDP
;END MAIN
;END _start
; -------------------------------------------------------------



; -------------------------------------------------------------
; [NASM]
; -------------------------------------------------------------
section .data
    CR:            EQU        0Dh
    LF:            EQU        0Ah
    ; Max Size
    g_STR_BUF_MAX_LENGTH:    EQU        255
    ; String
    strPrompt:                DB        '?', CR, LF
    strPromptLength:        EQU        $-strPrompt
;
section .bss
; Variables
    bufRead:                RESB    g_STR_BUF_MAX_LENGTH    ; Array of 255 bytes
; Macros
    %macro _EXIT        1
        ; [NOTE]
        ;    - Parameter Count: For fake
        mov eax, 1        ; System Call
        mov ebx, 0        ; [in] Parameter 0:
        int 80h
    %endmacro
    %macro _READ        2
        ; [RETURN]
        ;    @%1:        String
        ;    @%2:        Length
        ;    @eax:        Length
        mov eax, 3        ; System Call
        mov ebx, 0        ; [in] Parameter 0: File Descriptor 0 (stdin)
        mov ecx, %1        ; [out] Parameter 1: String
        mov edx, %2        ; [out] Parameter 2: Length
        int 80h
    %endmacro
    %macro _WRITE        2
        ; [RETURN]
        ;    @eax:        none
        mov eax, 4        ; System Call
        mov ebx, 1        ; [in] Parameter 0: File Descriptor 1 (stdout)
        mov ecx, %1        ; [in] Parameter 1: String
        mov edx, %2        ; [in] Parameter 2: Length
        int 80h
    %endmacro
;
section .text
    global _start    ; Linux
    ;global _main    ; Cygwin
;
_start:    ; Linux
;_main:    ; Cygwin
    _WRITE strPrompt, strPromptLength
    _READ bufRead, g_STR_BUF_MAX_LENGTH   
    push eax
    _WRITE strPrompt, strPromptLength
    pop edx
    _WRITE bufRead, edx

    _EXIT    0
; -------------------------------------------------------------



; __EOF__


-----
Cheers,
June