블로그 이미지
Leeway is... the freedom that someone has to take the action they want to or to change their plans.
maetel

Notice

Recent Post

Recent Comment

Recent Trackback

Archive

calendar

1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
  • total
  • today
  • yesterday

Category

2010. 5. 27. 20:53 Computer Vision
virtual object rendering test
가상의 그래픽 합성 시험

OpenGL 그래픽과 OpenCV 이미지 합성

camera로부터의 입력 이미지를 OpenCV 함수로 받아 IplImage 형태로 저장한 것과 OpenGL 함수로 그린 그래픽 정보를 합성하기


Way #1.

OpenCV의 카메라 입력으로 받은 image frame을 texture로 만들어 OpenGL의 디스플레이 창에 배경 (평면에 texture mapping)으로 넣고 여기에 그래픽을 그려 display하는 방법
ref. http://cafe.naver.com/opencv/12266

여차저차 조사 끝에 정리하면,
OpenGL에서 texture mapping을 실행하는 함수 glTexImage2D( )의 입력 텍스처로 OpenCV의 image data structure인 IplImage를 넣어 줄 수 있으면 끝난다.
ref.
http://www.gamedev.net/community/forums/topic.asp?topic_id=205527
http://www.rauwendaal.net/blog/opencvandopengl-1
ARTag source code: cfar_code/OpenGL/opengl_only_test/opengl_only_test.cpp
ARTag source code: cfar_code/IntroARProg/basic_artag_opengl/basic_artag_opengl.cpp

테스팅 중 발견한 문제점:
cvRetrieveFrame() 함수를 while 아래에서 돌려 cvShowImage() 함수로 보여 주는 대신 glutDisplayFunc() 함수에서 불러 glutMainLoop() 함수로 돌리면 시간이 많이 걸린다. (* cvGrabFrame() 함수의 경우는 괜찮음.)


ref. OpenGL Programming Guide - Chapter 9 - Texture Mapping
Textures are simply rectangular arrays of data - for example, color data, luminance data, or color and alpha data. The individual values in a texture array are often called texels.

The data describing a texture may consist of one, two, three, or four elements per texel, representing anything from a modulation constant to an (R, G, B, A) quadruple.

A texture object stores texture data and makes it readily available. You can now control many textures and go back to textures that have been previously loaded into your texture resources.


6일 동안의 갖은 삽질 끝에 몇 줄 되지도 않는 source code. ㅜㅜ

glLoadMarix( ) 함수




Way #2.

OpenCV에서 카메라로부터 얻은 image frame과 이로부터 계산한 OpenGL의 그래픽 정보를 OpenCV의 Iplimage로 넘기는 방법

ref.
http://cafe.naver.com/opencv/12622


http://webcache.googleusercontent.com/search?q=cache:xUG17-FlHQMJ:www.soe.ucsc.edu/classes/cmps260/Winter99/Winter99/handouts/proj1/proj1_99.html+tsai+opengl&cd=5&hl=ko&ct=clnk&gl=kr


http://www.google.com/codesearch/p?hl=ko#zI2h2OEMZ0U/~mgattass/ra/software/tsai.zip%7CsGIrNzsqK4o/tsai/src/main.c&q=tsai%20glut&l=9

http://www.google.com/codesearch/p?hl=ko#XWPk_ZdtAX4/classes/cmps260/Winter99/handouts/proj1/cs260proj1.tar.gz|DRo4_7nUzpo/CS260/camera.c&q=tsai%20glut&d=7


posted by maetel