수요일, 12월 02, 2009

Delphi: TBitmap, BMP, DIB

Delphi: TBitmap, BMP, DIB
 - 자주 사용하는 것인데 아래 site 에서 정리 및 link 가 제법 잘 되어있기에 여기에 posting 한다.

Source:
http://www.efg2.com/Lab/Library/Delphi/Graphics/BMP.htm




TBitmap, BMP, DIB



general info
1. In D1/D2, a bitmap was a DIB (device independent bitmap) after loading, but became a DDB (device dependent bitmap) on the first screen draw -- the DIB was tossed and the DDB format was kept. The pixel format could (and usually did) change across load/modify/save sequences.

In D3, Danny Thorpe (Borland) reimplemented TBitmap to use a DIBSection to solve the load/modify/save problem present in D1/D2. The use of DIBs provided direct access to pixel memory (using the Scanline property) and the bitmap handle at the same time.

2. In D3/D4 if you load an RLE compressed bitmap, it is loaded as a DDB, but when it gets written out, it is written an an uncompressed (screen pixel format) DIB.

3. Getting a strange compile-time error with a TBitmap? There's a TBitmap defined in both the Windows and Graphics unit and they may be in the wrong order in your USES statement. Normally you want the one from the Graphics unit (put in last in your USES), unless you're directly using API functions.]4.  The standard windows glyphs are stored within comctl32.dll as bitmaps.
5.  TBitmap is defined in both windows.pas and graphics.pas units.  Since the compiler automatically recognizes the last one in the "Uses" statement, make sure "Graphics" follows "Windows" in the "Uses" statement.
Example of comparing two TBitmaps and counting number of pixels that match and differ.
Bitmaps and InterBase BLOB Fields (TI 797D)
Converting a BMP to a JPEG and Vice Versa (TI 4582D)
Creating a bitmap from a pixel array (FAQ 1205D)
Creating temporary canvas (FAQ 1277D)
Drawing transparent text onto a TBitmap (FAQ 2079D)
Extracting a Bitmap from A BLOB Field (TI 791D)
Extracting Icons (FAQ 1778D)
Handling bitmap display (FAQ 2418D) [size limitations]
See also Very Large Bitmap Lab Report
Delphi Pool TBitmap Tips
www.lmc-mediaagentur.de/dpool/graph04.htm
How can I create a bitmap from an icon? (FAQ 2752D)
How can I place a bitmap in a metafile? (FAQ 1842D)
How to paint a form with a bitmap (TI 551D)
Loading Bitmaps and Cursors from RES Files (TI1081D) [explains palette problem]
Loading bitmaps into dBASE and Paradox BLOB Fields (TI 779D)
Non VCL Bitmap buffering (FAQ 2774D)
Stretchdraw on an icon (FAQ 1818D)
Using the Win API GetObject to get a bitmap (FAQ 2518D)
  How to create a Bitmap from numeric data? (D5)
Patrick Martin's example TBitmap descendant using memory mapped files
Background Bitmaps on Forms by Robert Vivrette
www.undu.com/DN961001/00000006.htm
Big Bitmap Viewer by Grahame Marsh
www.undu.com/DN970101/00000013.htm
Load Bitmap Resource by Ray Lischner. Look for bmpres10.zip www.tempest-sw.com/freeware or via ftp at ftp://ftp.tempest-sw.com/pub/delphi/bmpres10.zip
Storing bitmaps as resources, pp. 525-531, Delphi Programming Problem Solver, Neil Rubenking
"Displaying your bitmaps quickly", Delphi Developer's Journal, July 1998, pp. 12-15. (Double buffering using Pixels instead of Scanline. This technique is not very quick compared to using Scanline!) File 98Jul/DDJ9873.ZIP at ftp.zdjournals.com/ddj
"Eliminate flicker when painting on a form or a TPaintBox control, " www.bcbdev.com/faqs/faq34.htm
Mike Shkolnik's UseNet Post:   Bitmap to TGraphicField
Joe Hecht's UseNet Post with BltTBitmapAsDib procedure
Rund um TBitmap
http://delphi.pjh2.de/articles/graphic/bitmap.php
efg's UseNet Post about how to create TList of TBitmaps
Assign
Borland example: ..\Delphi n\Demos\Doc\GraphEx.dpr
Transparent property to work for a CoolBar background bitmap (FAQ 1390D)
Extracting a Bitmap from A BLOB Field (TI 791D)
Converting a BMP to a JPEG and Vice Versa (TI 4582D)

efg's Note: There is a Very Subtle Bug/Feature in the Delphi 3/4 Assign when only using Scanline to access pixel data. Assign should always be a "deep copy" (all data copied) versus a "shallow copy" (only a pointer copied), but this isn't always true! The kludge fix is to copy a single pixel from one bitmap to the other using the Pixels property to force unique references. See Assign.Txt.  (Fixed in D5)
Create/Free
Creating temporary canvas (FAQ 1277D) Francesco Savastano's UseNet Post about initializing bitmap to specified color
Dormant
Problem with complex implementation that allows DDB and DIB Section to exist simultaneously in Single TBitmap as described in UseNet Post by Takuo Nakamura.  This note gives an example of when Dormant is needed. Nick Hodges' UseNet Post answering "How does TBitmap.Dormant work?"
Peter Haas' UseNet Post about using Bitmap.Dormant after setting PixelFormat to fix a problem in D1-D4 with the TBitmaInfoHeader
efg's example of converting TIcon to TBitmap, as well as extracting the icon's "AND" bitmap mask and the "OR" color bitmap.   [This is the first example that I needed "Dormant" but this solution only worked in Windows 2000.  An alternate approach was needed for Windows 98.  --efg]
See the Cursor Overlay Lab report for another Dormant example.
FreeImage
Finn Tolderlund's UseNet Post about Scanline and FreeImage
HandleType
(D3/D4)
THandleType = (bmDDB, bmDIB)

In D3/D4 if you create a TBitmap and DO NOT assign either the PixelFormat or the HandleType, a DDB is created.  If you set HandleType := bmDIB, or if you specify any PixelFormat (other than pfDevice), you get a DIB. 

A BMP loaded from a file is a DIB (HandleType = bmDIB). Problem with complex implementation that allows DDB and DIB Section to exist simultaneously in Single TBitmap as described in UseNet Post by Takuo Nakamura.  This note gives an example of when HandleType is needed.
LoadFromFile
Transparent property to work for a CoolBar background bitmap (FAQ 1390D)
How can I place a bitmap in a metafile? (FAQ 1842D)

See \Program Files\Borland\Delphi n\HELP\Examples\Bitmap\BMPFormU.PAS Using Bitmaps, p. 216, Delphi Component Design by Danny Thorpe:
"When you call TBitmap.LoadFromFile to load a BMP file into a bitmap object, the bitmap object keeps a copy of the original file data in a memory stream.  The bitmap does not create a bitmap handle unless you refer to the bitmap's Handle property in your own code."  [D2.  True in D3 and later?]]
Mask
Shannon Broskie's UseNet Post with DrawTitleBarImage function
Monochrome
Setting Monochrome to TRUE on a pf24bit bitmap changes the PixelFormat to pfDevice. My observation is that all non-white colors become black when Monochome is set to TRUE on a pf24bit bitmap.
 
Palette
efg's UseNet Post about how to create pf8bit TBitmap with 256 shades of gray. Also see Delphi Graphics Color Page
PixelFormat (D3/D4)
TPixelFormat = (pfDevice, pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit, pf32bit, pfCustom);

PixelFormat and Scanline are discussed at length in
Manipulating Pixels With Delphi's ScanLine Property  Peter Haas' UseNet Post about using Bitmap.Dormant after setting PixelFormat to fix a problem in D1-D4 with the TBitmapInfoHeader
Ian Martin's UseNet Post about PhotoShop's problem with pf16bit bitmaps
See also Monochrome.
Resource Files
See Resource Files on Delphi Graphics Algorithms page
SaveToClipboardFormat
The example in the D3 online help compiled (with a warning), but the online help example of SaveToClipboardFormat has never been quite right and does not compile (see efg's UseNet Post about this).  Here's a version of the online example that will compile in D3..D7:
USES clipbrd;  // I wish Borland showed what unit is needed in the help
procedure TForm1.Button1Click(Sender: TObject);
var
  MyFormat : Word;
  Bitmap   : TBitMap;
  AData    : THandle;
  APalette : hPalette;  // Wrong in D3-D7 online example
begin
  Bitmap := TBitmap.Create;
  try
    Bitmap.LoadFromFile('c:\Program Files\Common Files\Borland Shared\Images\Splash\256color\factory.bmp');
    Bitmap.SaveToClipBoardFormat(MyFormat,AData,APalette);
    ClipBoard.SetAsHandle(MyFormat,AData);
  finally
    Bitmap.Free;
  end;
end;
SaveToFile
Converting a BMP to a JPEG and Vice Versa (TI 4582D)
Scanline (D3)
The PixelFormat defines the layout of a Scanline. PixelFormat and Scanline are discussed at length in
Manipulating Pixels With Delphi's ScanLine Property
Scanline Enigma working with pf24bit Bitmaps (fixed in D4.02 and D5)
Finn Tolderlund's UseNet Post about Scanline and FreeImage
See also Monochrome.
Transparent
TransparentColor
TransparentMode
The Transparent property of a TBitmap works only if you use the Draw method to draw it on a canvas. If Transparent := TRUE, and TransparentMode := tmAuto, then the transparent color is the color of the bottom-leftmost pixel of the bitmap. If TransparentMode := tmFixed, then the transparent color is defined by the TransparentColor property.

Dynamically drawing a transparent image (FAQ 1794D)Also see "Transparency" in Section B of Delphi Graphics Algorithms.


 

BMP and DIB File Formats


File Format
Description/Comments
Archives
Bitmap Archives
Raize Button Glyphs
www.raize.com/DevTools/Tools/RzBmps.htm
Glyphs und Icons im Internet
http://community.borland.com/article/0,1410,25911,00.html
Images in BMP format -- 16800 images (8 MB)
www.eldos.org/files/bitmaps.zip 
9452 glyphs from Richey's Delphi-Box
http://inner-smile.com/dl_div.htm#glyph
More than 400 glyphs from MS Office Applications
ftp://ftp.scalabium.com/pub/officebtns.zip
Raize Button Glyphs
www.raize.com/RzBmps.htm 
1000 glyphs for free
www.rwakelin.freeserve.co.uk/sharedfiles/bmpiconz.zip

Links to various bitmap/icon collections
www.torry.net/docs_graphics.htm 
BMP
Bitmap and Metafile Functions, Tomes Graphical, pp. 273-356Windows Bitmap used with Microsoft Paint
Delphi 3 or 4: ..\Demos\Imagview
To create a RES file with Bitmaps: 
Edit a file name.RC and add a line like this for each bitmap:
NAME  BITMAP  "NAME.BMP"
all in upper case.  Replace "NAME" above with the appropriate bitmap name.   Once you have the name.RC file, use the resource compiler:  BRC32 name.RC
The file name.RES will be created.  Add {$R name.RES} to the unit needing the resource.
Loading Bitmaps and Cursors from RES files (TI 1081D)
Tried TI 1081D and you now see the message "Bitmap Image is not valid"?  Be sure to add the comment {$R name.RES} to the unit where you're using LoadResource.
Example of comparing two TBitmaps and counting number of pixels that match and differ.
efg's Resource Demo application shows how to use the following file types in resource files:  BMP, ICO, JPG, GIF (requires Anders Melander's TGIFImage), EMF, TXT, AVI, WAV and cursors
Peter Haas' UseNet Post about determining a bitmap's size without loading the complete TBitmap, and Joe Hecht's Reply Post with certain precautions 
Bitmap Orientation and biHeight
www.webartz.com/fourcc/fccbihgt.htm
biHeight and Video Formats in DirectShow (problem with inverted video images)
http://www.microsoft.com/hwdev/desinit/biheight.htm 
Scanline Tech Note explains accessing pixel data quickly for the various PixelFormats
24 bits/pixel to 8 bits/pixel bitmaps using the ReduceColors function.  See Anders Melander's UseNet Post about using TGIFImage to reduce colors.
RGB Formats
www.webartz.com/fourcc/fccrgb.htm
Encryption / Decryption
CryptImage.jpg (948 bytes)   efg's ImageCrypt Lab Report:  BMP Section
efg's Aspect Ratio Lab Report
Resource-Grabber will scan the directories and drives on your computer and extract all Bitmaps, Glyphs (button images), Icons, Cursors, JPG/JPEG images, WAVE and RMI sound files as well as AVI video clips it finds inside the programs and DLL files in any directory of your choice.  http://inner-smile.com/dl_res.htm
Glyph Viewer facilitates the search in large Glyph directories.  In a list all bit-maps of a directory as well as their file names and creation dates are displayed. The list can be sorted according to file names and creation dates. In a tree representation you can select the desired directory.
http://www.pics-software.de/swglyph.htm 
BMP Technical Tutorial: 
www.geocities.com/SiliconValley/Haven/7041/tp/showbmp.txt
Microsoft's "Error 481: Invalid Picture" Err Viewing BMP File
Danny Thorpe's UseNet Post about RLE BMPs
Rafe Aldridge's UseNet Post about Bug in D5 loading RLE BMPs
Bob Villiers' UseNet Post with VarArrayLoadFile, which loads a bitmap into a variant
efg's PelsPerMeter example with GetPelsPerMeter procedure to return biXPelsPerMeter and biYPelsPerMeter values, and an example based on a UseNet Post by Peter Klein that returns these same values.
Biff Kadidlehopper's UseNet Post to get/set the dpi in a bitmap file or bitmap image (the biXPelsPerMeter and biYPelsPerMeter values)
The biXPelsPerMeter is a 4-byte integer at an offset of 38 bytes from the start of the file; biYPelsPerMeter is a 4-byte integer at an offset of 42 bytes from the start of the file.
Example from Robert Poyntz with SpecialBMP routine to set the biXPelsPerMeter and biYPelsPerMeter values.  SpecialGIF procedure by Robert Poyntz with biXPelsPerMeter and biYPelsPerMeter example.
Supported by ImageLib www.imagelib.com
 
DIB
Windows Device-Independent Bitmap Delphi Programming & Assembly Language (DIBULTRA)
http://perso.magic.fr/sleon/prog/DIBUltra/DIBUltraE.htm
Joe Hecht's UseNet Post with BltTBitmapAsDib procedure
Chris Hill's UseNet Post explaining two ways the term DIB is used
efg's examples of working with DIBs while converting Lead Tool's BitmapHandle to TBitmap
Delphi Graphics Programming by Peter Dove and Don Peer in Delphi Informant:
Part IV, Apr 97, "Getting DIBs on Speed" (pp. 45-56)
DIBs. A class that provides easy access to Device Independent Bitmaps. Delphi Super Page: http://delphi.icm.edu.pl/ftp/d10free/dibs.zip
Wie ist eine DIB aufgebaut (How a DIB is structured)
http://delphi.pjh2.de/articles/graphic/bitmap.php#DIB
Supported by ImageLib www.imagelib.com
Non-Delphi:
DIBs and Their Use:
http://msdn.microsoft.com/library/techart/msdn_dibs2.htm 
Using Device-Independent Bitmaps and Palettes http://support.microsoft.com/support/kb/articles/q72/0/41.asp
"More Fun with MFC: DIBs, Palettes, Subclassing, and a Gamut of Reusable Goodies", Part I (Jan 97), www.microsoft.com/MSJ/0197/mfcp1/mfcp1.htm
www.microsoft.com/msj/code1993to1997/MSJJAN97.EXE
More Fun With MFC: DIBs, Palettes, Subclassing and a Gamut of Goodies, Part II (Mar 97)
www.microsoft.com/msj/0397/mfcp2/mfcp2.htm
www.microsoft.com/msj/code1993to1997/MSJMAR97.EXE
More Fun with MFC: DIBs, Palettes, Subclassing, and a Gamut of Goodies, Part III (Jun 97)
www.microsoft.com/msj/0697/mfc3/mfc3.htm 



Conversions


Conversion(s)
Description/Comments
411 to BMP
efg's 411 Lab Report to read .411 file and convert to a TBitmap
AVI to BMPs
Eddie Shipman's UseNet Post with Example of how to convert the following "common" AVIs into BMPs:   FindFolder, iFindFile, FindComputer, CopyFiles,iCopyFile, RecycleFile, EmptyRecycle,   DeleteFile
Toni Martir's notes and complete VFW example (see ShevinE's improvement below).   (Note:  to get Toni's complete example to compile in D3-D5, make sure you can compile with USES OLE2:

Tools | Environment Options | Library | Library Path
D3: C:\Program Files\Borland\Delphi 3\Lib\Delphi2
D4-5: $(DELPHI)\Lib\Delphi2)
Use Lizard.AVI or another AVI file with Toni's example.
ShevinE's improvements to Toni Martir's example (D3-D5 source).   Saves AVI to  BMP files as FrameXX.BMP.  Includes VFW.PAS file used in Toni's example.  (Requires USES OLE2 -- see above notes for details.)  [Use Lizard.AVI or another AVI file.]
efg's AVItoBMP example project (Delphi 3-5 source code). 
(Assumes "Jesus Lizard" AVI is present.)
The "Jesus Lizard" AVI file shows a lizard walking on water.
Download from here  
Bitmap to DIB Handle
Takuo Nakamura's UseNet Post with BitmapToDIBHandle routine
BitmapHandle to/from TBitmap
efg's example of converting from Lead's BitmapHandle with a BMP to several formats including CMP, EPS, JPG, PCT, PCX, PNG, RAS, TGA, TIF, WMF, or from TBitmap to BitmapHandle
BitmapToWMF
Procedure in ImageLib Suite DLL.Harm's UseNet Post about converting bitmap to EMF/WMF
BMPs to AVI
Tilo Arnold's UseNet PostSee Rob Anderson's AVIBUILD.
Current version does not handle pf24bit BMPs correctly.
Includes vfw.pas (Video for Windows) interface unit for avifil32.dll.
VB Info:  BMPs to AVI
www.shrinkwrapvb.com/avihelp/avihlp_5.htm
BMP to ICO
Tomes Graphical, pp. 359-361
Ignacio Alvarez's UseNet Post with BitmapToIcon function

How do I create an icon from a bitmap?  (FAQ 2748D)
BMP to GIF
TGIFImage from www.melander.dk/delphi/gifimage
BMP to JPG
Quick Conversion between Bitmaps and JPEG
www.undu.com/Articles/010119c.html
efg's TBitmap in TImage to JPG file
    
PROCEDURE ConvertBMPtoJPG (CONST BMPName: STRING; JPGName: STRING);
  VAR
    Bitmap: TBitmap;
    JPEG : TJPEGImage;
BEGIN
  Bitmap := TBitmap.Create;
  JPEG := TJPEGImage.Create;
  TRY
    Bitmap.LoadFromFile(BMPName);
    JPEG.CompressionQuality := 80;
    JPEG.Assign(Bitmap);
    JPEG.SaveToFile(JPGName);
  FINALLY
    Bitmap.Free;
    JPEG.Free
  END
END {ConvertBMPtoJPG};

Converting a BMP to a JPEG and Vice Versa (TI4528D)
efg's UseNet Post to convert TJPEGImage to TBitmap, change size of TBitmap, and convert back to TJPEGImage
efg's BMPJPG Lab Report. Interactively convert BMPs to JPGs or vice versa. Nearly all the JPEG compession options cn be controlled via the user interface, including image quality and progressive encoding and display.

efg's Command-line utility for batch conversion of BMPs to JPGs: BMPtoJPG.PAS
BMP to TIFF
Save BMP as TIFF 6.0  (D1-D5, updated Sept 2000)
http://delphi.icm.edu.pl/ftp/d10free/bmp2tiff.zip
http://community.borland.com/homepages/dsp/ftp/d10free/bmp2tiff.zip 
BMP to TXT
Example of how to convert BMP file to a TXT file of RGB values, and how to convert such a TXT file to RGB values in a TBitmap for display.
BMP to WMF
Non-Delphi:  AlgoLab Photo Vector turns raster images (.bmp, .jpg, and .png files) into vector images (.wmf files) with a minimum of fuss. www.zdnet.com/downloads/stories/info/0,,001EP8,.html 
Cursor to Bitmap
Thomas' UseNet Post about how to extract the cursor image from a cursor file for drawing on a bitmap
DIBtoBitmap
Procedure in ImageLib Suite DLL.  Also see hDIB to TBitmap.
hDIB to TBitmap
efg's Lead Tools-to-Delphi conversions show two ways to start with a hDIB and end up with a TBitmap.
- Method 1. hDIB to TBitmap resulting in bmDDB using StretchDIBits
- Method 2. hDIB to TBitmap resulting in bmDIB using MemoryStream 

ICO to TBitmap
Howard Moon's UseNet Post with ConvertIconToBitmap procedure
JPG to BMP
Converting a BMP to JPEG and Vice Versa (TI 4582D)
efg's BMPJPG Lab Report (see description above under BMP to JPG)
efg's
command-line utility for batch conversion of JPGs to BMPs: JPGtoBMP.PAS efg's UseNet Post to convert TJPEGImage to TBitmap, change size of TBitmap, and convert back to TJPEGImage
PGM to BMP or JPG
See efg's Interactive PGMP5 "viewer" to display PGM files (P5 format) or the command-line utility ConvertFaces to convert PGM files of the AT&T Laboratories Cambridge Database of Faces (400 images) at www.uk.research.att.com/facedatabase.html to BMP or JPG: PortableGrayMap.ZIP
RichEdit to TBitmap
Peter Haas' UseNet Post
TControl to TBitmap
efg's example of TControl to TBitmap including a TLabel, TPanel and TBitBtn.  
TIFF to BMP
TIFF to BMP
http://delphi.icm.edu.pl/ftp/d20free/tiff2bmp.zip
http://community.borland.com/homepages/dsp/ftp/d20free/tiff2bmp.zip 
TXT to BMP
Example of how to convert BMP file to a TXT file of RGB values, and how to convert such a TXT file to RGB values in a TBitmap for display.      How to create a Bitmap from numeric data? (D5)  Shows gray scale vs. spectrum.
WMF to BMP
Harm's UseNet Post with example







-----
Cheers,
June

화요일, 12월 01, 2009

2009년 11월 26일, 서울 압구정 퓨어 피부과 여직원 분들과의 갑작스런 미팅

음...
2009년 11월 26일 오늘, 예정에 없던 미팅을 하게되었다. ^^
원래 가려고 했던 분이 계셨는데 회의 때문에 불참하게 되었던 걸
내가 채우게 된것이다. 음...

이렇다...
회사의 특정 본부에 여친이 없는 남자를 대상으로 같은 건물 3층에 있는
피어피부과(Pure Esthetic) 여직원 (매니저들 및 간호사?) 들과 7 vs 7 미팅이 이루어졌다.

우선 퇴근 후 시간에 맞추어 3층 퓨어피부과로 갔다.
가볍게 인사를 한 뒤 뽑기(?)를 해서 우선 짝을 지었다.

단체로 몰려가면 재미 없으니 짝을 이루어 미션도 수행하면서
couple 마다 이동수단을 이용해서 도착하면 된다.

내 쪽지는 "장동건" 이렇게 적혀있었다. ^^v
내 짝은 "고소영" 이었다. ㅋㅋㅋ

우린 이렇게 제일 먼저 출발하게 되었다.

나이는 27 인데, 이름을 물어 보지 못한게 너무 미안했다.
기본적인 것인데...

피부과에서 어떤 일을 하는지와 이런저런 얘기를 하다보니 목적지에 거의 도착했다.
날이 조금 쌀쌀해서 내가 택시로 이동 하자고 했다.

우리의 미션은 "손 사진" 을 찍는 것이었다. 이해가 가질 않아서 그냥 손 잡는 모습을
휴대폰 카메라에 담았다. (미션은 그냥이었나 보다. 확인도 하질 않았으니...)

압구정역 2번 출구에 도착해서 목적지에 가려는데 다른 커플들도 보였다.
같이 이동을 하다 약도를 보는데 길이 아닌것 같아서 조금 헤매었지만
다행히 그애가 같이 일하는 언니에게 전화를 해서 쉽게 갈 수 있었다.

사실 도착은 우리가 제일 먼저인데 마지막으로 두 번째로 목적지에 도착을 하게 되었다. (미안 ^^;)

서로 자세히 얼굴도 보고 자기소개의 시간이 되었다. 아주 간단한 소개이다. 나는 이름, 나이, 그냥 한마디 했다. ㅠ.ㅠ

식사를 하면서 이런저런 얘기들이 오가고 술이 한 잔씩 들어가니 서로 말문이 트였나 보다.
^^ 장난도 많이 치고... 음... 나는 그냥 앉아있었다.
사람들이 허물없이 얘기하며 장난도 치는 모습이 어찌나 보기 좋으면서 즐거웠던지,
보고 듣는 내내 마음이 참 따뜻해졌다.

내가 최근에 이렇게 어울려 본적이 언제였던가 할 정도로 기억이 가물가물하다.
거의 없었던것 같다. 인생이란 간단하게 생각하면 이렇게 단순 하면서도 즐거울텐데
왜이리 알게 모르게 근심이 있는지 모르겠다.

누군가 "피할 수 없으면 즐겨라"고 했던가?... 그 말에 동의한다.
하지만, 근심은 조금 다른 것 같다. 즐기기엔 내가 너무 성숙 해 버린건 아닌지...
그 시절이 그립다. 부모님과 내 동생과 함께 지내며 밥먹고 하는 그런 시간...

지금도 그렇게 할 수는 있지만,.. 서울을 떠나 집으로 내려가서 가족과 살고 싶지만,
마음 먹은대로 쉽지만은 않다.
어쩌면 다른 속마음으론 미련이 남아있어서 그럴지도 모르겠다.

지금 내가 할수 있는건 하루에 한번 씩 부모님께 안부 전화 드리는 일,
휴가 내는 날은 꼭 집에 내려가기... 그리고 가족을 위해 기도하기 이다.
그저 우리 가족 모두 다치지 않고 아프지 않으며 항상 하는 일 모두 잘 될 수 있기를
바랄뿐이다. 이게 나에 전부 이다.

음...
다시 본론으로 돌아와서...
그렇게 보고 듣는 것 만으로도 나는 즐거웠다.
다른 사람들이 보기엔 성의가 없어 보였는지도 모르겠지만, 그렇게 보였다면
너무 죄송스럽다. 초면이며 내가 낯을 많이 가리다 보니 물어보기 전에는 말을 잘 못한다.

그러서 일까? 퓨어피부과 여자분들이 각자 선물을 준비 했는데, 그 중 나이가
제일 많으신 매니저분께서 나에게 선물을 주셨다. 응. 알고있다. 일부러 나게에 준 것을...
그분께 너무 감사하다. 말 없이 그냥 있던 날 위해 "Vibe" 콘서트 ticket 을 얻을 수 있는 기회지만, 그냥 나에게 주셨다.

찻잔이었는데 너무 예뻤다. 소중히 보관 할테야~  ㅎㅎ

오늘 너무 졸린다.
참,,, 퓨어피부과 여성분들의 캐릭터가 중복이 되지 않고 너무 unique 해서 그분들을 주제로 재주는 없지만 짧막한 글을 써보려고 한다. 그냥 sitcom 형태의 대본이다. 아직 시작은 하지 않았지만, 조만간 틈틈히 써볼 생각이다.

서울 강남 압구정 "퓨어 피부과 (Pure Esthetic)" 여직원분들... 실제로 만나서 이런저런 얘기도 듣고 보고 해보니, 내가 보기엔 모두들 참하고 순수하고, 항상 웃고(직업 상?) 착해 보인다. 물론 다를 예쁘시다.

이런 말 하면 좀 그렇지만, 나는 언제나 여자를 볼 땐 "그림에 떡" 이라는 생각을 갖는다. 나는 이런 쪽으론 자신이 없나 보다. 언젠가는 여친이 생기고 결혼도 하겠지만, 흑흑(ㅠ.ㅠ) 그때가 언제 일지는 모르지만, 아무튼... 항상 바르게, 상대방에게 부끄러운 짓은 하지 않으며 차분히 기다리려 한다.

나에게 우연, 인연이라는 것이 있다는 걸 꼭 알게 해주었으면 하는 바람이다.
風がある日に。。。

-----
Cheers,
June

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