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

Similar documents
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 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

1 NUI TA OpenGL Wii Wii OpenGL Kinect URL USB

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()

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 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

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 - > - > - > - >

OpenCV IS Report No Report Medical Information System Labratry

第7章 レンダリング

第7章 レンダリング

スライド 1

第3章 OpenGL の基礎

2 : 2008/12/ /01/ G :

untitled

libaux.dvi

第3章 OpenGL の基礎

OpenGL & GLUTの基本関数の説明

Condition DAQ condition condition 2 3 XML key value

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

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

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

double float

#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

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

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

演算増幅器

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

TA tani/class/mech enshu/ X Window System GUI(Graphical User Interface) GUI (event driven) 2 Gtk

新版明解C言語 実践編

新・明解C言語 実践編

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

Linux XScreenSaver T020074

( ) 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>

Graphics Performance Tuning () Z 2

(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

‚æ4›ñ

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

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

第5回お試しアカウント付き並列プログラミング講習会

謗域・ュ逕ィppt

Linuxデバイスドライバ.PDF

Java updated

/*p7-1-1*/

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

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

Arduino UNO IS Report No. Report Medical Information System Laboratory

<4D F736F F D F6F6C4B D815B834A8C9F8F6F814588CA92758E7090A E C815B836C CC8E6782A295FB2E646

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

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

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

演算増幅器

para02-2.dvi

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B


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

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

2 2 GtkWidget* gtk_drawing_area_new ( void ); /* */ void gtk_drawing_area_size ( GtkDrawingArea *darea, gint width, gint height); realize size allocat

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

programmingII2019-v01

VLD Kazutoshi Kobayashi

MINI2440マニュアル

2008 DS T050049

I 2 tutimura/ I 2 p.1/??

大統一Debian勉強会 gdb+python拡張を使ったデバッグ手法

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

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

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

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

comment.dvi

C

Nios® II HAL API を使用したソフトウェア・サンプル集 「Modular Scatter-Gather DMA Core」

BW BW

C¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç

イントロダクション

OpenGL Programming Course OpenGL Programming Course FAQ

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for

ProVisionaire Control V3.0セットアップガイド

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

Java演習(4) -- 変数と型 --

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

44 6 MPI 4 : #LIB=-lmpich -lm 5 : LIB=-lmpi -lm 7 : mpi1: mpi1.c 8 : $(CC) -o mpi1 mpi1.c $(LIB) 9 : 10 : clean: 11 : -$(DEL) mpi1 make mpi1 1 % mpiru

untitled

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

For_Beginners_CAPL.indd

r07.dvi

ohp07.dvi

Applet java.lang.object java.awt.component java.awt.container java.awt.panel java.applet.applet

untitled

yacc.dvi

SML#³«È¯ºÇÁ°Àþ

SystemC言語概論

slide5.pptx

の 3 つのファイルに #include <functional> を加える 場所は以下の通り diff --git a/modules/calib3d/test/test_affine3d_estimator.cpp b/modules/calib3d/test/test_affine3d_est

A Responsive Processor for Parallel/Distributed Real-time Processing

JIIAセミナー

OpenCV Windows(cygwin) Linux USB PC [1] Inel OpenCV OpenCV 1 Windows Linux OpenCV (a) (b)2 (c) (d) 1: OpenCV 1

顔認識の為のリアルタイム特徴抽出

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

MEDIAEDGE MEDIAEDGE TEL FAX :00 12:00 13:00 17: MEDIAEDGE MEDIAEDGE 8. HDMI HDMIHigh-Definition M

Transcription:

1 22 (2) TA: 2010 12 13 1 OpenGL Wii Wii OpenGL USB (3DCG) 1.1 http://www.cyber.t.u-tokyo.ac.jp/~kuni/enshu2010/ URL USB

2 2 1.2 TA 16 15 TA TA mireport@cyber.t.u-tokyo.ac.jp 20101213 abcdefgh abcdefgh 2 2.1 13C PC Wii bluetooth 2.2 Bluetooth USB Princeton PTM-UBT3S 1 1 USB 2.3 Wii 1 1 2.4 Bluetooth USB USB 2.5 Wii CWiid http://www.cyber.t.u-tokyo.ac.jp/ kuni/enshu2010/cwiid-0.5.03.tgz CWiid

2.5 Wii 3 tar xvzf cwiid-0.5.03.tgz./configure make sudo make install CWiid 00:00:00:00:00:00 Wii Bluetooth cd cwiid-0.5.03/wmgui./wmgui 00:00:00:00:00:00 wmgui File Connect 1 Connect Connect Settings Acc Data Wii

4 3 2 3 Wii Wii Bluetooth Wii 3.1 Wii Wii Wii Wii Wii Fit Wii Wii 3 IC Bluetooth IC CMOS Bluetooth 3 3.2 CWiid CWiid http://abstrakraft.org/cwiid/ Linux C Wii Wiimote) API Wii API Wiimote GTK GUI Download

3.2 CWiid 5 3 Wii http://www.nintendo.co.jp/wii/features/wii remote.html CMOS Wii wiimote command state 1 ON 0 OFF command WIIMOTE CMD RUMBLE WIIMOTE CMD LED LED wiimote_command(wiimote, command, int state); void set_report_mode(void) { uint8_t rpt_mode; rpt_mode = WIIMOTE_RPT_STATUS WIIMOTE_RPT_BTN; rpt_mode = WIIMOTE_RPT_ACC; wiimote_command(wiimote, WIIMOTE_CMD_RPT_MODE, rpt_mode); Wii Wii unionwiimote mesgmesg array mesg arraytype acc zero, acc one zeropoint 1Gpoint

6 3 void wiimote_callback(int id, int mesg_count, union wiimote_mesg *mesg_array[]) { int i; for (i=0; i < mesg_count; i++) { switch (mesg_array[i]->type) { case WIIMOTE_MESG_ACC: wiimote_acc(&mesg_array[i]->acc_mesg); break; case WIIMOTE_MESG_BTN: wiimote_btn(&mesg_array[i]->btn_mesg); break; default: break; Wii mesg > x, mesg > y, mesg > z void wiimote_acc(struct wiimote_acc_mesg *mesg) { printf("x: %d, y: %d, z: %d\t", mesg->x, mesg->y, mesg->z); double a_x, a_y, a_z; a_x = ((double)mesg->x - acc_zero.x) / (acc_one.x - acc_zero.x); a_y = ((double)mesg->y - acc_zero.y) / (acc_one.y - acc_zero.y); a_z = ((double)mesg->z - acc_zero.z) / (acc_one.z - acc_zero.z); Wii

3.2 CWiid 7 void wiimote_btn(struct wiimote_btn_mesg *mesg){ if(mesg->buttons & WIIMOTE_BTN_UP){ WIIMOTE BTN UP WIIMOTE BTN DOWN WIIMOTE BTN RIGHT WIIMOTE BTN LEFT WIIMOTE BTN PLUS WIIMOTE BTN MINUS WIIMOTE BTN A A WIIMOTE BTN B B WIIMOTE BTN HOME HOME WIIMOTE BTN 1 1 WIIMOTE BTN 2 2 Wii Wii 4 Wii http://wiibrew.org/images/9/9e/wiimote axis2.png Yaw, Pitch, Roll Yaw, Pitch, Roll 5 CWiid CWiid Makefile cwiid-0.5.03/wiimote wiimote

8 3 5 Yaw,Pitch,Roll http://sorceryforce.com/programing/mdx/direct3d/stepup/quaternion.html CC = g++ COMMON =. PACKAGE_VERSION = 0.5.03 WIIMOTE_DIR =../../cwiid-0.5.03/wiimote ( RM = rm -f TARGET = sample OBJS = sample.o CFLAGS = -Wall -I${WIIMOTE_DIR \ #-DCWIID_VERSION=\"${PACKAGE_VERSION\" LDFLAGS = -L${WIIMOTE_DIR LDLIBS = -lglut -lgl -lglu -lwiimote.c.o: ${CC -c ${CFLAGS $< ${TARGET: ${OBJS ${CC -o ${TARGET ${OBJS ${LDLIBS ${LDFLAGS clean: ${RM ${TARGET *.o *

3.2 CWiid 9 1 1. kadai.tar.gz kadai1 sample.c Bluetooth 00:00:00:00:00:00 Bluetooth Wii./sample 00:00:00:00:00:00 a Wii A B b 1! 2 Wii LED 1 2 r R] Wii c WireCube 2. kadai2 sample.c Wii Teapot a b B c d 3. kadai3 sample.c Wii.disp flag a b Wii c d

10 3 6 Wii 7 Teapot Wii 8 Wii

11 4 USB OpenGL Linux Linux Video for Linux(Video4Linux, v4l ) API Video4Linux USB IEEE1394 API Linux Video for Linux 2(Video4Linux2, v4l2 ) API USB (USB Video Class, UVC) USB 2.0 Linux Linux Video4Linux lsmod lsmod grep video ) 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

12 4 OpenCV http://opencv.jp/ http://opencv.jp/sample/ 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 1 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 13 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>

14 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 15 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 2 ID 1 CvCapture 1 cvqueryframe() AVI 1 IplImage IplImage NULL IplImage* cvqueryframe( CvCapture* capture ); capture

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

4.2 17 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);

18 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 glrasterpos{234{sifd(type x, TYPE y, TYPE z, TYPE w);

4.3 19 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 10 : sample-texture.c 10 3 glteximage2d() 2 gltexsubimage2d()

20 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 11 640 480 1024 512 gltexcoord() 0.625(=640/1024) 0.9375(=480/512)

4.3 21 void gltexcoord{1,2,3,4{s,i,d,f(type coords); void gltexcoord{1,2,3,4{s,i,d,fv(type *coords); 11 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();

22 A 3 ( 10) 3 ( 12) 2 1. opencv-sample.tar.gz USB 2. opencv-texture.tar.gz 10 3. opencv-divtex.tar.gz TODO 2.3 4. 12 1 5. opencv-dynamic.tar.gz 12 3 A Wii 2007.12, Vol.110, No.1069, pp.6-7 2007