2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height pixels void glreadpixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum t

Similar documents
2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height pixels void glreadpixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum t

2 2 GLUI 2 GLUI 2.1 GLUI GLUI OpenGL OpenGL glut OpenGL glut C++ Linux, Windows (Visual C++, gcc), Macintosh glut glut GUI glut GUI CG glmultmatrix()

TA TA TA abcdefgh abcdefgh C PC Wii bluetooth 2.2 Bluetooth USB Princeton PTM-UBT3S 1 1

2 2 2 OpenGL Linux Linux Video for Linux(Video4Linux, v4l ) API Video4Linux USB IEEE1394 API Linux Video for Linux 2(Video4Linux2, v4l2 ) OpenCV API U

2 2 OpenGL ( ) 2 OpenGL ( ) glclearcolor(glclampf red, GLclampf green, GLclampf blu

第7章 レンダリング

第7章 レンダリング

1 1. Program 1 OpenCV (OpenCV Sample001) 1 /* 2 - > - > - >VC++ 3 ( ) 4 C:\opencv\build\include 5 ( ) 6 C:\opencv\build\x86\vc10\lib 7 - > - > - > - >

libaux.dvi

/*p7-1-1*/

OpenGL & GLUTの基本関数の説明

第3章 OpenGL の基礎

第3章 OpenGL の基礎

j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E

#include <stdio.h> 2 #include <stdlib.h> 3 #include <GL/glut.h> 4 Program 1 (OpenGL GameSample001) 5 // 6 static bool KeyUpON = false; // 7 sta

$ ls -l $ ls -l -a $ ls -la $ ls -F $ ls <dirname> <dirname> $ cd <dirname> <dirname> $ cd $ pwd $ cat <filename> <filename> $ less <filename> <filena

2 Eclipse 2.1 Eclipse 1. Eclipse 2. 3 ( 4) E:Yworkspace OK 3 Eclipse 4 3. Eclipse 5 5 Eclipse Eclipse 2. 7 C 2

PowerPoint Presentation

3D グラフィックス処理の一般過程 1. 3D グラフィックス処理の一般過程

コンピュータグラフィックスS 演習資料

演算増幅器

2 : 2008/12/ /01/ G :

演算増幅器

untitled

2 3 OpenGL 2 OpenGL OpenGL(Open Graphics Library) Silicon Graphics (SGI) 3D OpenGL SGI HP, SUN, IBM UNIX Linux, FreeBSD PC UNIX Windows, Mac OS API PD

OpenGL Programming Course OpenGL Programming Course FAQ

2 2 OpenGL OpenGL OpenGL(Open Graphics Library) Silicon Graphics (SGI) 3D OpenGL SGI HP, SUN,

OpenCV IS Report No Report Medical Information System Labratry

謗域・ュ逕ィppt

スライド 1

2 2 OpenGL ( ) OpenGL ( ) glclearcolor(glclampf red, GLclampf green, GLclampf

( ) 1 1: 1 #include <s t d i o. h> 2 #include <GL/ g l u t. h> 3 #include <math. h> 4 #include <s t d l i b. h> 5 #include <time. h>

1) OOP 2) ( ) 3.2) printf Number3-2.cpp #include <stdio.h> class Number Number(); // ~Number(); // void setnumber(float n); float getnumber();

/* drawing function */ function_graph();// drawing graph glflush(); int main(int argc, char **argv ) glutinit( &argc, argv ); glutinitdisplaymode( GLU

準備 計算結果を可視化するために OpenGL を 利用する. 2

19_OpenGLES.key

1 OpenGL OpenGL OpenGL OpenGL

$ pwd /home1/t0/t0903 / / /home1/t0/t0903 / / /home1/t0/t0903 / /... ~ $ ls $ ls -a

JAPLA研究会資料 2010/4/24

Condition DAQ condition condition 2 3 XML key value

1 level Level swtich ButtonPress ButtonRelease Expose Level

Microsoft PowerPoint - CV03.ppt [互換モード]

2 T ax 2 + 2bxy + cy 2 + dx + ey + f = 0 a + b + c > 0 a, b, c A xy ( ) ( ) ( ) ( ) u = u 0 + a cos θ, v = v 0 + b sin θ 0 θ 2π u = u 0 ± a

WebGL OpenGL GLSL Kageyama (Kobe Univ.) Visualization / 57

_openglcl

manual.dvi

adv99_4.PDF

イントロダクション

Microsoft Word - C.....u.K...doc

DrawArrays DrawElements References Kageyama (Kobe Univ.) Visualization / 34

Kageyama (Kobe Univ.) Visualization / 32

double float

double rx[natom], ry[natom], rz[natom]; 原子の座標 速度 力 ポテンシャルエ double vx[natom], vy[natom], vz[natom]; ネルギーを受ける配列を準備 double fx[natom], fy[natom], fz[natom

(4) モデルの消去 mqodeletemodel( model ); (5) 終了処理 ( プログラム終了時にやってください ) mqocleanup(); 3. 使い方 (2) 連番ファイルを読み込んで表示する場合 (1) 初期化 (ARToolKit の場合,argInit() の後に使用 )

untitled

Graphics Performance Tuning () Z 2

Kageyama (Kobe Univ.) / 36

新・明解C言語 ポインタ完全攻略

新版明解C言語 実践編

2 2 Gtk+ GUI (widget ) GUI Gtk+ GUI Gtk+ GUI 2.2 Gtk GUI sample1.c Web ( tani/class/mech enshu/) enshu2009gui1.tar.gz

opencv-linux Linux 1.1pre1 % tar zxvf opencv-1.1pre1.tar.gz % cd opencv %./configure --with-apps % make % su # make install 2.2 Windows Windows

C B

C

1 3 2 OpenGL 4 3 OpenGL 5 4 OpenGL 6 OpenGl : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 6 : : : : : : : : : : : : : : : : : : : : :

ex01.dvi

OpenGL GLSL References Kageyama (Kobe Univ.) Visualization / 58

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

(300, 150) 120 getchar() HgBox(x, y, w, h) (x, y), w, h #include <stdio.h> #include <handy.h> int main(void) { int i; double w, h; } HgO

謗域・ュ逕ィppt

comment.dvi

ex01.dvi

slide5.pptx

r07.dvi

(search: ) [1] ( ) 2 (linear search) (sequential search) 1

謗域・ュ逕ィppt

Microsoft Word - mediaJikkenCG_no2_2007.doc

ohp07.dvi

tuat1.dvi

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

Microsoft Word - mediaJikkenCG_no2_2012.doc

Microsoft Word - opengl講義資料ha.doc

main main Makefile Makefile C.5 Makefile Makefile Makefile A Mech (TA ) 1. Web ( iku

3. OpenGL を利用するための準備作業 1) Tao Framework をダウンロードしてインストールする. Download から taoframework setup.exe をダウン

Fair Curve and Surface Design System Using Tangent Control

プログラミング及び演習 第1回 講義概容・実行制御

新・明解C言語 実践編

ゲームグラフィックス特論

joho07-1.ppt

Microsoft Word - ggbook.docx

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

CM-3G 周辺モジュール拡張技術文書 MS5607センサ(温度、気圧)

Microsoft Word - opengl講義資料2013.doc

TEOライブラリによる画像処理プログラミング入門

WinHPC ppt

r08.dvi

x h = (b a)/n [x i, x i+1 ] = [a+i h, a+ (i + 1) h] A(x i ) A(x i ) = h 2 {f(x i) + f(x i+1 ) = h {f(a + i h) + f(a + (i + 1) h), (2) 2 a b n A(x i )

\\afs001-0m0005\project02\A32\M

program.dvi

Transcription:

1 24 (2) 3DCG TA 2012 10 12 1 OpenGL USB (3DCG) OpenCV 1.1 http://www.cyber.t.u-tokyo.ac.jp/~tani/class/mech_enshu/ 1.2 TA 1.3 USB (2012/11/19( ),20( )) USB

2 2 2 OpenGL (R,G,B,A) 2.1 OpenGL (x y) width height pixels void glreadpixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); format (RGBA ) type GL COLOR INDEX GL RGB GL RED GL GREEN GL BLUE GL ALPHA GL LUMINANCE GL LUMINANCE ALPHA GL STENCIL INDEX GL DEPTH COMPONENT 1 glreadpixels(),gldrawpixels() glrasterpos*() width height

2.1 OpenGL 3 GL UNSIGNED BYTE GL BYTE GL UNSIGNED SHORT GL SHORT GL UNSIGNED INT GL INT GL UNSIGNED BYTE 8 8 16 16 32 32 2 glreadpixels(),gldrawpixels() void gldrawpixels(glsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); void glrasterpos234sifd(type x, TYPE y, TYPE z, TYPE w); void glrasterpos234sifdv(type *coords); format type glreadpixels() glreadpixels() gldrawpixels() void glcopypixels(glint x, GLint y, GLsizei width, GLsizei height, GLenum buffer); buffer GL COLOR, GL STENCIL, GL DEPTH 1 4 format 2 3 glpixelstore*()

4 2 void glpixelstoreif(glenum pname TYPE param); GL UNPACK* gldrawpixels(),glteximage1d(),glteximage2d(),gltexsubimage1d(), gltexsubimage2d() GL PACK* glreadpixels(),glgetteximage() GL UNPACK SWAP BYTES, GL PACK SWAP BYTES GLboolean FALSE TRUEFALSE GL UNPACK LSB BYTES, GL PACK LSB BYTES GLboolean FALSE TRUEFALSE GL UNPACK ROW LENGTH, GL PACK ROW LENGTH GLint 0 GL UNPACK SKIP ROWS, GL PACK SKIP ROWS GLint 0 GL UNPACK SKIP PIXELS, GL PACK SKIP PIXELS GLint 0 GL UNPACK ALIGNMENT, GL PACK ALIGNMENT GLint 4 1,2,3,4 *ROW_LENGTH *SKIP_PIXELS ª æ œ *SKIP_ROWS æ œ 1 void glpixelzoom(glfloat zoom_x GLfloat zoom_y); (gldrawpixels(),glcopypixels()) x y zoom x zoom y 1.0 2.0 4

2.2 5 2.2 gldrawpixels() sample-image.c #include <GL/glut.h> #include <stdlib.h> #define checkimagewidth 64 #define checkimageheight 64 GLubyte checkimage[checkimageheight][checkimagewidth][3]; static GLdouble zoomfactor = 1.0; static GLint height; void makecheckimage(void) int i, j, c; for (i = 0; i < checkimageheight; i++) for (j = 0; j < checkimagewidth; j++) c = ((((i&0x8)==0)^((j&0x8)==0)))*255; checkimage[i][j][0] = (GLubyte) c; checkimage[i][j][1] = (GLubyte) c; checkimage[i][j][2] = (GLubyte) c; void init(void) glclearcolor (0.0, 0.0, 0.0, 0.0); glshademodel(gl_flat); makecheckimage(); glpixelstorei(gl_unpack_alignment, 1);

6 2 void display(void) glclear(gl_color_buffer_bit); glrasterpos2i(0, 0); gldrawpixels(checkimagewidth, checkimageheight, GL_RGB, GL_UNSIGNED_BYTE, checkimage); glflush(); 2.3 Independent JPEG Group s software JPEG Linux (http://www.ijg.org/) JPEG JPEG OpenGL viewjpeg.c: OpenGL readjpeg.h, readjpeg.c: JPEG testimg.jpg: JPEG Makefile TARGET OBJS = viewjpeg = viewjpeg.o readjpeg.o CC = gcc CFLAGS = -g -Wall -O2 LIBS = -lglut -lglu -lgl -ljpeg TARGET:$(OBJS) $(CC) -o $(TARGET) $(OBJS) $(LIBS).c.o: $(CC) $(FLAGS) -c $< clean: rm -f *.o *~ $(TARGET)

7 3 OpenGL 6 A N J K H A 2 H E E J E L A @ A 2 5? A A I K H B =? A B > K E @ E C I K H B =? A B M = J H A A 3.1 3 0.0...1.0 gltexcoord() void gltexcoord1,2,3,4s,i,d,f(type coords); void gltexcoord1,2,3,4s,i,d,fv(type *coords); 3.2 (sample-checker.c) glteximage2d()

8 3 3 #include <GL/glut.h> #include <stdlib.h> /* Create checkerboard texture */ #define checkimagewidth 64 #define checkimageheight 64 GLubyte checkimage[checkimagewidth][checkimageheight][3]; void makecheckimage(void) int i, j, c; for (i = 0; i < checkimagewidth; i++) for (j = 0; j < checkimageheight; j++) c = ((((i&0x8)==0)^((j&0x8)==0)))*255; checkimage[i][j][0] = (GLubyte) c; checkimage[i][j][1] = (GLubyte) c; checkimage[i][j][2] = (GLubyte) c; void myinit(void) glclearcolor (0.0, 0.0, 0.0, 0.0); glenable(gl_depth_test); gldepthfunc(gl_less); makecheckimage(); glpixelstorei(gl_unpack_alignment, 1);

3.2 9 glteximage2d(gl_texture_2d, 0, 3, checkimagewidth, checkimageheight, 0, GL_RGB, GL_UNSIGNED_BYTE, &checkimage[0][0][0]); gltexparameterf(gl_texture_2d, GL_TEXTURE_WRAP_S, GL_CLAMP); gltexparameterf(gl_texture_2d, GL_TEXTURE_WRAP_T, GL_CLAMP); gltexparameterf(gl_texture_2d, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gltexparameterf(gl_texture_2d, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gltexenvf(gl_texture_env, GL_TEXTURE_ENV_MODE, GL_DECAL); glenable(gl_texture_2d); glshademodel(gl_flat); void display(void) glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glbegin(gl_quads); gltexcoord2f(0.0, 0.0); glvertex3f(-2.0, -1.0, 0.0); gltexcoord2f(0.0, 1.0); glvertex3f(-2.0, 1.0, 0.0); gltexcoord2f(1.0, 1.0); glvertex3f(0.0, 1.0, 0.0); gltexcoord2f(1.0, 0.0); glvertex3f(0.0, -1.0, 0.0); gltexcoord2f(0.0, 0.0); glvertex3f(1.0, -1.0, 0.0); gltexcoord2f(0.0, 1.0); glvertex3f(1.0, 1.0, 0.0); gltexcoord2f(1.0, 1.0); glvertex3f(2.41421, 1.0, -1.41421); gltexcoord2f(1.0, 0.0); glvertex3f(2.41421, -1.0, -1.41421); glend(); glutswapbuffers(); void myreshape(int w, int h) glviewport(0, 0, w, h); glmatrixmode(gl_projection); glloadidentity(); gluperspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30.0); glmatrixmode(gl_modelview); glloadidentity(); gltranslatef(0.0, 0.0, -3.6);

10 3 int main(int argc, char** argv) glutinit(&argc, argv); glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH); glutcreatewindow("checker"); myinit(); glutreshapefunc (myreshape); glutdisplayfunc(display); glutmainloop(); return 0; /* ANSI C requires main to return int. */ makecheckimage GLubyte (unsigned char) WIDTH HEIGHT 3 1 RGB 3 2 64 64 makecheckimage myinit glpixelstorei() image[ ] gltexparameteri, gltexparameterf GL TEXTURE MAG FILTER GL TEXTURE MIN FILTER (MAG) (MIN) GL LINEAR GL NEAREST GL TEXTURE WRAP S(T) s, t GL REPAET (GL CLAMP) 3 0.0..3.0 gltexenvf GL DECAL GL MODULATE

3.2 11 glteximage2d void glteximage2d(glenum target, GLint level, GLint format, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); target GL TEXTURE 2D GL PROXY TEXTURE 2D level 0 format (RGBA )GL RGB GL RGBA width height OpenGL 2 1 2 4 8 16 32 64 128 256 64x64 1024x1024 border 0 format pixels RGB GL RGB PNG GL RGBA type pixels GL UNSIGNED BYTE width,height,pixel width,height 2 pixels ( image) display() glenable(gl TEXTURE 2D) gldisable(gl TEXTURE 2D)

12 3 3.3 OpenGL ( ) 1. 2. 3. 4. OpenGL void glgentextures(glsizei n, GLuint *texturenames); glgentextures() n texturenames void glbindtexture(glenum target, GLuint texturename); target GL TEXTURE 1D GL TEXTURE 2D texturename glteximage2d() 2 gltexsubimage2d()

3.3 13 void gltexsubimage2d( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); target GL TEXTURE 2D level 0 xoffset x yoffset y (0, 0) width height format type gldrawpixels() format type pixels gltexsubimage2d() glteximage2d() 2 2 n GLU gluscaleimage() int gluscaleimage( GLenum format, GLint widthin, GLint heightin, GLenum typein, const void * datain, GLint widthout, GLint heightout, GLenum typeout, void * dataout ); format widthin heightin typein datain widthout heightout typeout dataout

14 3 1 1. sampel-checker.c sample-texbind.c 2. JPEG viewjpeg.c, readjpeg.c 3. sample-image.c JPEG 4. glut- SolidTeapot 5. GIMP

15 4 Linux Linux Video for Linux(Video4Linux, v4l ) API Video4Linux USB IEEE1394 API Linux Video for Linux 2(Video4Linux2, v4l2 ) OpenCV API USB (USB Video Class, UVC) USB 2.0 Linux Linux Video4Linux lsmod uvcvideo 51204 0 compat_ioctl32 5569 1 uvcvideo videodev 30785 1 uvcvideo v4l1_compat 17349 2 uvcvideo,videodev v4l2_common 20801 2 uvcvideo,videodev 4.1 OpenCV Video4Linux API OpenCV(Open Source Computer Vision Library) OpenCV OpenGL Video4Linux API OS OpenCV OS OS OpenCV OpenGL 3DCG 3DCG OpenCV OpenCV http://opencv.jp/ http://opencv.jp/sample/

16 4 OpenCV OpenCV IplImage OpenCV 640 480 3 RGB 8bit RGB OpenCV B G R B G R 3 1 nsize nchannels depth origin width height imagesize imagedata widthstep IplImage 1,2,3,4 1 = widthstep * height 3 IplImage cvloadimage IplImage* cvloadimage( const char* filename, int flags=cv_load_image_color ); filename flags / cvcreateimage RGB 8 24 depth 8 IPL DEPTH 8U channels 3

4.1 17 IplImage* cvcreateimage( CvSize size, int depth, int channels ); size depth IPL_DEPTH_8U - 8 IPL_DEPTH_8S - 8 IPL_DEPTH_16U - 16 IPL_DEPTH_16S - 16 IPL_DEPTH_32S - 32 IPL_DEPTH_32F - IPL_DEPTH_64F - channels 1, 2, 3, 4 cvreleaseimage void cvreleaseimage( IplImage** image ); image OpenGL R G B OpenCV OpenGL OpenCV OpenGL (GL BGR EXT GL BGRA ) OpenCV cvcvtcolor() CV BGR2RGB BGR RGB void cvcvtcolor( const CvArr* src, CvArr* dst, int code ); src 8 8u 16 16u 32f dst code CV_<src_color_space>2<dst_color_space>

18 4 OpenCV CvCapture cvcreatecameracapture() OpenCV 0 cvcreatecameracapture() NULL OpenCV cvcapturefromcam() cvcreatecameracapture() CvCapture* cvcreatecameracapture( int index ); index -1 cvcreatecameracapture() cvcreatefilecapture() CvCapture* cvcreatefilecapture( const char* filename ); filename cvsetcaptureproperty() int cvsetcaptureproperty( CvCapture* capture, int property_id, double value ); capture property_id ID

4.1 19 cvgetcaptureproperty() cvqueryframe() double cvgetcaptureproperty( CvCapture* capture, int property_id ); capture property_id ID ID CV CAP PROP POS MSEC CV CAP PROP POS FRAMES CV CAP PROP POS AVI RATIO CV CAP PROP FRAME WIDTH CV CAP PROP FRAME HEIGHT CV CAP PROP FPS CV CAP PROP FOURCC CV CAP PROP FRAME COUNT / 4 4 ID 1 CvCapture 1 cvqueryframe() AVI 1 IplImage IplImage NULL IplImage* cvqueryframe( CvCapture* capture ); capture

20 4 cvcreatecameracapture() cvcreatefilecapture() cvreleasecapture() void cvreleasecapture( CvCapture** capture ); capture 4.2 Window 4) 4 OpenGL OpenCV /* OpenGL */ #include <GL/glut.h> /* OpenCV */ #include <opencv/cv.h> #include <opencv/highgui.h>

4.2 21 IplImage *frame; /* Capture Imege from OpenCV */ CvCapture* capture = 0; /* Video Capture Structure */ int dev_index = 0; /* Capture Device ID */ void my_init(int argc, char **argv) // Initialization Part - OpenCV // Connect to Capture Device capture = cvcreatecameracapture(dev_index); if (capture) frame = cvqueryframe(capture); cap_width = cvgetcaptureproperty(capture, CV_CAP_PROP_FRAME_WIDTH); cap_height = cvgetcaptureproperty(capture, CV_CAP_PROP_FRAME_HEIGHT); else fprintf(stderr, "Found No Camera\n"); exit(-1); // Flip Captured Image if (frame->origin==0) cvflip(frame, frame, 0); // Convert Color Alignment BGR -> RGB cvcvtcolor(frame, frame, CV_BGR2RGB); win_width = cap_width; win_height = cap_height; int my_exit(int e) /* Release Process - OpenCV */ if (capture) cvreleasecapture(&capture); exit(e);

22 4 idle cvqueryframe() OpenGL cvflip() BGR RGB cvcvtcolor() void idle(void) if (capture) frame = cvqueryframe(capture); if (frame->origin==0) cvflip(frame, frame, 0 ); cvcvtcolor(frame, frame, CV_BGR2RGB); glpixelstorei( GL_UNPACK_ALIGNMENT, 1 ); glutpostredisplay(); IplImage cvcloneimage() IplImage* cvcloneimage( const IplImage* image ); image gldrawpixels() void gldrawpixels(glsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); void glrasterpos234sifd(type x, TYPE y, TYPE z, TYPE w);

4.3 23 void display(void) glclear(gl_color_buffer_bit); glpixelstorei(gl_unpack_alignment, 1); glpixelzoom((gldouble)(win_width-2)/(gldouble)cap_width, (GLdouble)(win_height-2)/(GLdouble)cap_height); glrasterpos2i(-win_width/2+1, -win_height/2+1); gldrawpixels(cap_width, cap_height, GL_RGB, GL_UNSIGNED_BYTE, frame->imagedata); glflush(); glutswapbuffers(); 4.3 5 : sample-texture.c 5 3 glteximage2d() 2 gltexsubimage2d()

24 4 void gltexsubimage2d( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); idle gltexsubimage2d() void idle(void) if (capture) frame = cvqueryframe(capture); if (frame->origin==0) cvflip(frame, frame, 0); cvcvtcolor(frame, frame, CV_BGR2RGB); glpixelstorei( GL_UNPACK_ALIGNMENT, 1 ); glbindtexture( GL_TEXTURE_2D, tex_index ); gltexsubimage2d( GL_TEXTURE_2D, 0, 0, 0, frame->width, frame->height, GL_RGB, GL_UNSIGNED_BYTE, frame->imagedata ); glutpostredisplay(); glvertex() gltexcoord() 0.0...1.0 OpenGL 2 2 640 480 1024 512 6 640 480 1024 512 gltexcoord() 0.625(=640/1024) 0.9375(=480/512)

4.3 25 void gltexcoord1,2,3,4s,i,d,f(type coords); void gltexcoord1,2,3,4s,i,d,fv(type *coords); 6 void display(void) glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glcolor3f(1.0, 1.0, 1.0); glenable(gl_texture_2d); glbindtexture( GL_TEXTURE_2D, tex_index ); glpushmatrix(); glbegin(gl_triangle_fan); gltexcoord2f(0.0, 0.0); glvertex3f(-cap_width/2, -cap_height/2, 0.0); gltexcoord2f((float)cap_width/tex_width, 0.0); glvertex3f(cap_width/2, -cap_height/2, 0.0); gltexcoord2f((float)cap_width/tex_width, (float)cap_height/tex_height); glvertex3f(cap_width/2, cap_height/2, 0.0); gltexcoord2f(0.0, (float)cap_height/tex_height); glvertex3f(-cap_width/2, cap_height/2, 0.0); glend(); glpopmatrix();

26 4 3 ( 5) 3 ( 7) 2 1. opencv-sample USB v4l2-sample 2. opencv-texture 5 3. opencv-divtex TODO 2.2 4. 7 5. opencv-dynamic 7 3