Presentation is loading. Please wait.

Presentation is loading. Please wait.

Embedded System Lab. Web CAM 경희대학교 컴퓨터공학과 조 진 성. Embedded System Lab. 2 Web CAM application program 제작 Device driver 는 매우 고난이도의 기술을 요구 Web CAM 으로부터 읽은.

Similar presentations


Presentation on theme: "Embedded System Lab. Web CAM 경희대학교 컴퓨터공학과 조 진 성. Embedded System Lab. 2 Web CAM application program 제작 Device driver 는 매우 고난이도의 기술을 요구 Web CAM 으로부터 읽은."— Presentation transcript:

1 Embedded System Lab. Web CAM 경희대학교 컴퓨터공학과 조 진 성

2 Embedded System Lab. 2 Web CAM application program 제작 Device driver 는 매우 고난이도의 기술을 요구 Web CAM 으로부터 읽은 데이터를 TFT-LCD 화면에 출력 Web CAM

3 Embedded System Lab. 3 Frame Buffer 란 frame buffer 란 linux system 에서 그래픽을 표현할 수 있는 hardware 를 말함. PC 라면 그래픽 카드, PXA255 같으면 LCD controller 를 frame buffer 장치라 고 함. frame buffer 를 user level application 이 제어할 수 있도록 만들어진 device driver 를 frame buffer driver 라고 함 Frame buffer 의 개요

4 Embedded System Lab. 4 LCD 에 출력하는 원리 User level 에서 전송한 frame buffer data 를 LCD driver 가 수신하여 LCD controller 가 TFT-LCD 에 출력한다. User level 과 driver 간에 “/dev/fb0” 라는 node 를 통하여 data 를 전송하며, driver 가 할당한 memory 를 user application 에서도 사용할 수 있도록 memory mapping 을 한다. LCD 에 출력하는 원리 User application TFT-LCD LCD driver (frame buffer driver) LCD controller (frame buffer) Frame buffer data

5 Embedded System Lab. 5 이미지 수집과 디스플레이 과정 grab image sem_wait(&g_grab1) pthread_lock(freeze_mutex) pthread_lock(iscam_mutex) pthread_lock(pref_mutex) Update camera pthread_unlock(pref_mutex) Read from camera pthread_unlock(freeze_mutex) pthread_unlock(iscam_mutex) sem_post(&g_draw) display sem_wait(&g_draw) Update camera sem_post(&g_grab1) Display

6 Embedded System Lab. 6 Mutex thread 동기화에 사용되는 방법 semaphore 와 비슷하지만 mutex 는 오로지 한 thread 만이 특정 영역을 실행하게 할 때 사용 한 mutex 가 잠겨 있을 때 그 mutex 를 잠그려는 다른 thread 는 방지된다. 그리고 mutex 가 해제되면 그 다른 thread 가 다시 잠그고 영역에 진입 int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr); mutex 를 초기화 int pthread_mutex_lock(pthread_mutex_t *mutex); Mutex 를 잠금 int pthread_mutex_unlock(pthread_mutex_t *mutex); Mutex 를 해제 int pthread_mutex_destroy(pthread_mutex_t *mutex); Mutex 를 제거

7 Embedded System Lab. 7 Semaphore 0 과 1 값을 감소 시키거나 증가시키며 특정 자원을 특정 thread 만이 접근할 수 있도록 한다 int sem_init(sem_t *sem, int pshared, unsigned int value); semaphore 를 생성하고 초기화 int sem_wait(sem_t *sem); semaphore 값이 0 이상 이면 1 감소 시키고 계속 실행, 그렇지 않을 경우 대기 int sem_post(sem_t *sem); semaphore 의 값을 1 증가 시킨다 int sem_destroy(sem_t *sem); semaphore 소멸 다른 thread 가 semaphore 를 대기 중 이라면 에러가 발생

8 Embedded System Lab. 8 cam_test.h #include struct Save_Struct{ int isinfo; int quality; int smoothness; int optimize; int format; //png_byte interlace; int compression; }; #define FRAME_SIZE 640*480 enum Save_Types { PNG = 0, PPM = 1, JPEG = 2, GIF = 3 };

9 Embedded System Lab. 9 cam_test.h (2) enum Ppm_Types { RAW = 0, ASCII = 1 }; struct Camera { int dev; int greyscale; int draw; int frozen; int update_camera; int capture; int saving; int savetype; int docked; int dump; int speed_fastest; int on_timer;

10 Embedded System Lab. 10 cam_test.h (3) int timeout; int swapcolors; int autobright; struct video_capability vid_caps; struct video_window vid_win; struct video_picture vid_pic; struct video_clip vid_clips[32]; unsigned char *pic; unsigned char *picbuff; char devname[256]; char savefile[256]; char savefileclean[256]; pthread_mutex_t iscam_mutex, pref_mutex, freeze_mutex; int fps_avg; int fps_current; struct Save_Struct save_struct; };

11 Embedded System Lab. 11 cam_test.c #include #include //use thread #include //use semaphore #include //#include #include #include "cam_test.h"

12 Embedded System Lab. 12 cam_test.c (2) #include char version[] = VERSION; #define CAMERA_RECONFIG 1 sem_t s_draw; sem_t s_grab1, s_grab2; int plsquit = 0; int x_frames = 0; int y_frames = 0; char *fb_dev_name = "/dev/fb"; static struct fb_var_screeninfo fb_vinfo,fb_vinfo_org; static struct video_buffer temp_buffer; static unsigned char *frame_buffe''''r; static unsigned int fb_size; static int fb_dev_fd,picture_fd,fb_tty_fd;

13 Embedded System Lab. 13 cam_test.c (3) void init_cam(struct Camera *camera); void print_usage(); int dump_pict( struct Camera *camera, char *filename, int brightness, int contrast, int whiteness ); void open_cam(struct Camera *camera); void get_cam_info(struct Camera *camera); void set_cam_info(struct Camera *camera); void grab_image(struct Camera *camera); void close_cam(struct Camera *camera, int quiting); void jpeg_save(struct Camera *camera); void ppm_save(struct Camera *camera); void display(struct Camera *camera); void swap_rgb16(struct Camera *camera);

14 Embedded System Lab. 14 cam_test.c (4) int main(int argc, char *argv[]) { static struct Camera camera; pthread_t grab_thread;// 이미지 수집 쓰레드 pthread_t draw_thread;// 이미지 출력 쓰레드 int i, brightness=180, contrast=104, whiteness=155; unsigned char buff[3]; char *filename = NULL, readfile[255]; int done = 0; FILE *preffile; unsigned char picture[640*480*2]; init_cam(&camera);//CAM 초기화 while( !done ) { static struct option long_options[] ={

15 Embedded System Lab. 15 cam_test.c (5) { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { "swap", no_argument, NULL, 's' }, { "autobright", no_argument, NULL, 'a' }, { "video", required_argument, NULL, 'v' }, { "dump", required_argument, NULL, 'd' }, { "type", required_argument, NULL, 't' }, { "bright", required_argument, NULL, 'b' }, { "white", required_argument, NULL, 'w' }, { "contrast", required_argument, NULL, 'c' }, { "maxfps", required_argument, NULL, 'm' }, { "fullspeed", no_argument, NULL, 'F' }, { 0, 0, 0, 0 }}; int c; c = getopt_long( argc, argv, "FhVsav:d:b:w:c:m:t:", long_options, NULL );

16 Embedded System Lab. 16 cam_test.c (6) switch ( c ) { case 'h' : print_usage(); exit(0); break; case 'V' : printf( "gqcam version %s\n", version ); exit(0); break; case 's': camera.swapcolors = 1; break; case 'a': camera.autobright = 1; break; case 'v' : sprintf(camera.devname, "%s", optarg ); break;

17 Embedded System Lab. 17 cam_test.c (7) case 's': camera.swapcolors = 1; break; case 'a': camera.autobright = 1; break; case 'v' : sprintf(camera.devname, "%s", optarg ); break; case 'd' : camera.dump = 1; if( strcmp( optarg, "-" ) != 0 ) /* leave alone if stdout */ filename = optarg; break; case 't' : if(!strcmp(optarg, "PPM")) camera.savetype = PPM; else if(!strcmp(optarg, "PNG")) camera.savetype = PNG;

18 Embedded System Lab. 18 cam_test.c (8) else if(!strcmp(optarg, "JPEG")) camera.savetype = JPEG; break; case 'b' : brightness = atoi( optarg ); break; case 'w' : whiteness = atoi( optarg ); break; case 'c' : contrast = atoi( optarg ); break; case 'm' : if( atoi(optarg) > 0 ) /* Avoid weird values */ camera.timeout = 1000/atoi(optarg); break; case 'F' : camera.speed_fastest = 1; camera.timeout = 0;

19 Embedded System Lab. 19 cam_test.c (9) break; case EOF : done = 1; break; default : print_usage(); exit(1); }; } camera.fps_avg = 0; camera.fps_current = 0; if( camera.dump ){ exit( dump_pict( &camera, filename, brightness, contrast, whiteness ) ); } sem_init( &s_draw, 0, 0 );// 세마포어 초기화 sem_init( &s_grab1, 0, 1 );

20 Embedded System Lab. 20 cam_test.c (10) sem_init( &s_grab2, 0, 1 ); open_cam(&camera);//CAM open get_cam_info(&camera); camera.vid_pic.brightness = brightness*256; camera.vid_pic.contrast = contrast*256; camera.vid_pic.whiteness = whiteness*256; set_cam_info(&camera); if ((fb_dev_fd = open(fb_dev_name, O_RDWR)) == -1) { printf( "Can't open %s\n", fb_dev_name); exit(0); } #if !CAMERA_RECONFIG if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) { printf("Can't get VSCREENINFO\n"); exit(0); }

21 Embedded System Lab. 21 cam_test.c (11) printf("fb_vinfo.xres = %d ",fb_vinfo.xres); printf("fb_vinfo.yres = %d ",fb_vinfo.yres); printf("fb_vinfo.xres_virtual = %d ",fb_vinfo.xres_virtual); printf("fb_vinfo.yres_virtual = %d ",fb_vinfo.yres_virtual); printf("fb_vinfo.xoffset = %d ",fb_vinfo.xoffset); printf("fb_vinfo.yoffset = %d ",fb_vinfo.yoffset); printf("fb_vinfo.bits_per_pixel = %d ",fb_vinfo.bits_per_pixel); printf("fb_vinfo.grayscale = %d ",fb_vinfo.grayscale); printf("fb_vinfo.activate = %d ",fb_vinfo.activate); printf("fb_vinfo.nonstd = %d ",fb_vinfo.nonstd); printf("fb_vinfo.height = %d ",fb_vinfo.height); printf("fb_vinfo.width = %d ",fb_vinfo.width); printf("fb_vinfo.accel_flags = %d ",fb_vinfo.accel_flags); printf("fb_vinfo.pixclock = %d ",fb_vinfo.pixclock); printf("fb_vinfo.left_margin = %d ",fb_vinfo.left_margin); printf("fb_vinfo.right_margin = %d ",fb_vinfo.right_margin); printf("fb_vinfo.upper_margin = %d ",fb_vinfo.upper_margin); printf("fb_vinfo.lower_margin = %d ",fb_vinfo.lower_margin); printf("fb_vinfo.hsync_len = %d ",fb_vinfo.hsync_len);

22 Embedded System Lab. 22 cam_test.c (12) printf("fb_vinfo.vsync_len = %d ",fb_vinfo.vsync_len); printf("fb_vinfo.sync = %d ",fb_vinfo.sync); printf("fb_vinfo.vmode = %d ",fb_vinfo.vmode); if ((fb_tty_fd = open("/dev/tty", O_RDWR)) < 0) { printf("notice: Can't open /dev/tty:\n");exit(0); } if (fb_tty_fd >= 0 && ioctl(fb_tty_fd, KDSETMODE, KD_GRAPHICS) < 0) { printf("Can't set graphics mode: %s\n"); close(fb_tty_fd); fb_tty_fd = -1; } if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_vinfo)) { printf("Can't put VSCREENINFO\n"); exit(0); } #endif fb_size = 640*480*2;

23 Embedded System Lab. 23 cam_test.c (13) if ((frame_buffer = mmap(0, fb_size, PROT_READ | PROT_WRITE, MAP_SHARED, fb_dev_fd, 0)) == -1) { printf("Can't mmap %s \n", fb_dev_name); exit(0); } pthread_create(&grab_thread, NULL, (void *)&grab_image, (void*)&camera);// 이미지 수집 쓰레드 생성 pthread_create(&draw_thread, NULL, (void *)&display, (void*)&camera);// 이미지 출력 쓰레 드 생성 pause(); plsquit = 1; // ask our threads to quit // update semaphores and mutexes so threads can run and finish pthread_mutex_unlock( &camera.freeze_mutex ); sem_post( &s_draw );//semaphore 의 값을 늘린다 sem_post( &s_grab1 ); sem_post( &s_grab2 ); // join the threads cleanly pthread_join( grab_thread, NULL ); pthread_join( draw_thread, NULL );

24 Embedded System Lab. 24 cam_test.c (14) pthread_mutex_unlock( &camera.freeze_mutex ); close_cam(&camera, 1); exit(0); } void init_cam(struct Camera *camera) { camera->greyscale = 0; camera->pic = NULL; camera->picbuff = NULL; camera->draw = 0; camera->frozen = 0; camera->update_camera = 0; camera->saving = 0; camera->savetype = PNG; camera->capture = 1; camera->dev = 0; strcpy(camera->devname, "/dev/video0"); camera->docked = 1; camera->dump=0;

25 Embedded System Lab. 25 cam_test.c (15) camera->speed_fastest = 0; camera->timeout = 100; camera->on_timer = 0; camera->swapcolors = 0; pthread_mutex_init( &camera->pref_mutex, NULL ); //to modify pref/setting pthread_mutex_init( &camera->freeze_mutex, NULL ); //to freeze display pthread_mutex_init( &camera->iscam_mutex, NULL ); //is there an open cam? } void print_usage() { fprintf(stderr, "gqcam - GTK QuickCam Control\n"); fprintf(stderr, "Copyright (C) 1999 Cory Lueninghoener \n"); fprintf(stderr, "This software comes with ABSOLUTELY NO WARRANTY\n"); fprintf(stderr, "This software is free software, and you are welcome to redistribute it\n");

26 Embedded System Lab. 26 cam_test.c (16) fprintf(stderr, "under certain conditions\n"); fprintf(stderr, "See the README file for a more complete notice.\n"); fprintf( stderr, "usage: gqcam [-hVFs] [-d file] [-c contrast] [-w whiteness] [-b brightness] [-m maxfps] [-d filename] [-t type]\n" ); fprintf(stderr, "\t-h --help\t\tdisplay this help screen\n"); fprintf(stderr, "\t-V --version\t\tdisplay version and exit\n"); fprintf(stderr, "\t-s --swap\t\tswap RGB into BGR (WARNING: this option will disappear in the future, turning into a filter instead)\n"); fprintf(stderr, "\t-a --autobright\tperform autobrightness\n"); fprintf(stderr, "\t-v --video \tgrab frames from \n"); fprintf(stderr, "\t-d --dump \tdump image to \n\t\t\t\t(or stdout if filename is \"-\")\n"); fprintf(stderr, "\t-t --type \ttype of image to dump(default:PNG)\n\t\t\t\t(valid types: PPM PNG JPEG)\n"); fprintf(stderr, "\t-b --brightness \tset brightness to \n"); fprintf(stderr, "\t-w --whiteness \tset white balance to \n"); fprintf(stderr, "\t-c --contrast \tset contrast to \n"); fprintf(stderr, "\t-m --maxfps \tset the maximum frames per second(default:%d)\n", 10 ); fprintf(stderr, "\t-F --fullspeed\t\tdisplay as many frames per second as you can\n" ); }

27 Embedded System Lab. 27 cam_test.c (17) int dump_pict( struct Camera *camera, char *filename, int brightness, int contrast, int whiteness ) { FILE *outf = NULL; if( filename != NULL ){ strcpy(camera->savefile, filename); strcpy(camera->savefileclean, filename); } fprintf( stderr, "Dumping...\n" ); open_cam(camera); get_cam_info(camera); camera->vid_pic.brightness = brightness*256; camera->vid_pic.contrast = contrast*256; camera->vid_pic.whiteness = whiteness*256; set_cam_info(camera); sem_post( &s_grab1 ); sem_post( &s_grab2 ); grab_image(camera);

28 Embedded System Lab. 28 cam_test.c (18) camera->pic = camera->picbuff; close_cam(camera, 1); camera->save_struct.smoothness = 0; camera->save_struct.quality = 75; camera->save_struct.optimize = 0; jpeg_save(camera); return 0; } void open_cam(struct Camera *camera) { if((camera->dev<=0)){ camera->dev = open(camera->devname, O_RDWR); if (camera->dev < 0) { perror("/dev/video"); exit(1);} } pthread_mutex_unlock( &camera->iscam_mutex ); }

29 Embedded System Lab. 29 cam_test.c (19) void get_cam_info(struct Camera *camera) { int i; struct video_clip vid_clips[32]; ioctl(camera->dev, VIDIOCGCAP, &camera->vid_caps); ioctl(camera->dev, VIDIOCGWIN, &camera->vid_win); ioctl(camera->dev, VIDIOCGPICT, &camera->vid_pic); #if CAMERA_RECONFIG camera->vid_win.x = 0; camera->vid_win.y = 0; camera->vid_win.width = 320; camera->vid_win.height = 240; #else for (i = 0; i < 32; i++) { vid_clips[i].x = 0; vid_clips[i].y = 0; vid_clips[i].width = 0; }

30 Embedded System Lab. 30 cam_test.c (20) camera->vid_win.clips = vid_clips; camera->vid_win.clipcount = 0; #endif #if !CAMERA_RECONFIG camera->vid_pic.palette = VIDEO_PALETTE_RGB24; #else camera->vid_pic.palette = VIDEO_PALETTE_RGB565; camera->vid_pic.depth = 16; #endif if (camera->vid_caps.type & VID_TYPE_MONOCHROME) { camera->greyscale = 1; camera->pic = realloc( camera->pic, camera->vid_caps.maxwidth*camera- >vid_caps.maxheight); camera->picbuff = realloc( camera->picbuff, camera->vid_caps.maxwidth*camera- >vid_caps.maxheight ); } else { camera->greyscale = 0;

31 Embedded System Lab. 31 cam_test.c (21) camera->pic = realloc(camera->pic, camera->vid_caps.maxwidth*camera- >vid_caps.maxheight*3); camera->picbuff = realloc(camera->pic, camera->vid_caps.maxwidth*camera- >vid_caps.maxheight*3); } void set_cam_info(struct Camera *camera) { if (ioctl (camera->dev, VIDIOCSPICT, &(camera->vid_pic)) == -1) { perror ("ioctl (VIDIOCSPICT)"); } if (ioctl (camera->dev, VIDIOCSWIN, &(camera->vid_win)) == -1) { perror ("ioctl (VIDIOCSWIN)"); } void grab_image(struct Camera *camera) { int len,i,j,k,l=0; get_cam_info(camera);

32 Embedded System Lab. 32 cam_test.c (22) while ( !plsquit ) { // order matters! the sem_waits MUST be before the mutex lock // order matters! the sem_waits MUST be before the mutex lock if( !sem_wait( &s_grab1 ) && !pthread_mutex_lock( &camera->freeze_mutex ) && !pthread_mutex_lock( &camera->iscam_mutex )){ pthread_mutex_lock( &camera->pref_mutex ); if (camera->update_camera){ set_cam_info(camera); get_cam_info(camera); camera->update_camera = 0; } pthread_mutex_unlock( &camera->pref_mutex ); if( camera->dev ) len = read (camera->dev, camera->picbuff, camera->vid_win.width * camera- >vid_win.height*2); if (len <= 0) fprintf(stderr, "Error reading image...\n"); }

33 Embedded System Lab. 33 cam_test.c (23) pthread_mutex_unlock( &camera->freeze_mutex ); pthread_mutex_unlock( &camera->iscam_mutex ); if( camera->dump ) return; sem_post( &s_draw ); } void display(struct Camera *camera) { unsigned char *fb; int i; fb = frame_buffer + 640*2* *2; while( !plsquit ) { if( !sem_wait( &s_draw ) ) { unsigned char *tmp; tmp = camera->pic;

34 Embedded System Lab. 34 cam_test.c (24) camera->pic = camera->picbuff; camera->picbuff = tmp; sem_post( &s_grab1 ); for(i = 0;i < 240;i++){ memcpy(&fb[i*1280],&camera->pic[i*640],640); } return; }

35 Embedded System Lab. 35 cam_test.c (25) void close_cam(struct Camera *camera, int quiting) { int debug = 0; pthread_mutex_lock( &camera->iscam_mutex ); if(camera->dev > 0){ close(camera->dev); camera->dev = 0; }

36 Embedded System Lab. 36 cam_test.c (26) void jpeg_save(struct Camera *camera) { FILE *outfile; int ls=0, x, y, i; int lines, pixels_per_line; unsigned char buff[3]; struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; JSAMPROW row_pointer[1]; // pointer to JSAMPLE row(s) int row_stride; // physical row width in image buffer if(!strcmp(camera->savefile, "")) outfile = stdout; else if(camera->savefile != NULL) outfile = fopen(camera->savefile, "w"); if (outfile == NULL){ printf("\n file open error!!"); return; }

37 Embedded System Lab. 37 cam_test.c (27) cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); jpeg_stdio_dest(&cinfo, outfile); cinfo.image_width = camera->vid_win.width; cinfo.image_height = camera->vid_win.height; if (camera->greyscale) { cinfo.input_components = 1; cinfo.in_color_space = JCS_GRAYSCALE; } else { cinfo.input_components = 3; cinfo.in_color_space = JCS_RGB; } cinfo.smoothing_factor = camera->save_struct.smoothness; if (camera->save_struct.smoothness) { cinfo.optimize_coding = TRUE; }

38 Embedded System Lab. 38 cam_test.c (28) jpeg_set_defaults(&cinfo); jpeg_set_quality(&cinfo, camera->save_struct.quality, TRUE); jpeg_start_compress(&cinfo, TRUE); row_stride = cinfo.input_components*camera->vid_win.width; while (cinfo.next_scanline < cinfo.image_height) { row_pointer[0] = &camera->pic[cinfo.next_scanline * row_stride]; jpeg_write_scanlines(&cinfo, row_pointer, 1); } jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); fclose(outfile); return; }

39 Embedded System Lab. 39 cam_test.c (29) void ppm_save(struct Camera *camera) { FILE *outfile; unsigned char buff[3]; int i; if(!strcmp(camera->savefile, "")) outfile = stdout; else if(camera->savefile != NULL) outfile = fopen(camera->savefile, "w"); if (outfile == NULL){ printf("Could not open file"); return; } If (camera->save_struct.format == RAW){/* Raw */ fprintf (outfile, "P6\n%d %d\n%d\n", camera->vid_win.width, camera->vid_win.height, 255); if (camera->greyscale){

40 Embedded System Lab. 40 cam_test.c (30) for (i = 0; i vid_win.width*camera->vid_win.height; i++){ buff[0] = camera->pic[i]; buff[1] = camera->pic[i]; buff[2] = camera->pic[i]; fwrite (buff, 1, 3, outfile); } else { for (i = 0; i vid_win.width * camera->vid_win.height * 3; i++) { fputc(camera->pic[i], outfile); }

41 Embedded System Lab. 41 cam_test.c (31) else if (camera->save_struct.format == ASCII){/* Ascii */ fprintf (outfile, "P3\n%d %d\n%d\n", camera->vid_win.width, camera->vid_win.height, 255); if (camera->greyscale) { for (i = 0; i vid_win.width*camera->vid_win.height; i++){ fprintf (outfile, "%03d %03d %03d\n", camera->pic[i], camera->pic[i], camera- >pic[i]); } else for (i = 0; i vid_win.width*camera->vid_win.height*3; i=i+3){ fprintf (outfile, "%03d %03d %03d\n", camera->pic[i], camera->pic[i+1], camera->pic[i+2]); } fclose(outfile); }

42 Embedded System Lab. 42 cam_test.c (32) void swap_rgb16(struct Camera *camera) { unsigned short c; char *p = camera->pic; int i = camera->vid_win.width * camera->vid_win.height; int bytes_per_rgb = 3; int index = 0; if(!camera->greyscale){ while (--i) { c = ((p[2] & 0xf8) > 3) ; (unsigned short)camera->pic[index++] = c; p += bytes_per_rgb; }

43 Embedded System Lab. 43 Makefile CC = arm-linux-gcc LD = $(CC) LDFLAGS = -L/usr/local/arm/lib -ljpeg -lpthread PROG = cam_test VERSION = 0.9 CFLAGS = -DVERSION=\"$(VERSION)\" -I/home/max233/huins_040715/linux pro3_usb20/include INCLUDES = OBJS = all: $(PROG) clean: rm -f $(PROG) *.o *.core core *.bak *~ cam_test: cam_test.o $(LD) $(LDFLAGS) cam_test.o libjpeg.a -o cam_test cam_test.o: cam_test.c cam_test.h $(CC) $(CFLAGS) -c cam_test.c

44 Embedded System Lab. 44 Web CAM 실행 앞에서 만든 드라이버 소스를 test application 은 cam_test.c, 그리고 makefile 은 Makefile 로 작성 후 저장한다 make 명령어를 이용하여 위의 file 을 컴파일한다 % make 생성된 cam_test 과 usb device driver 를 target 으로 전송한다. 전송방식은 앞에서 배웠던 minicom 또는 nfs 방식을 이용한다. 밑에서는 nfs 방식을 통 하여 파일을 전송하였다

45 Embedded System Lab. 45 Web CAM 실행 (2) 위와 같이 실행 후 WEBCAM 과 LCD 의 동작을 확인한다 WEBCAM 을 USB2.0 에 연결


Download ppt "Embedded System Lab. Web CAM 경희대학교 컴퓨터공학과 조 진 성. Embedded System Lab. 2 Web CAM application program 제작 Device driver 는 매우 고난이도의 기술을 요구 Web CAM 으로부터 읽은."

Similar presentations


Ads by Google