영상 캡쳐 소스 질문이요~
제가 직접 작성한 소스는 아니구요--
처음 하는 거라, 구해서 나름대로 분석해 보았는데, 잘 이해가 안되는 부분이 있어서요
캡쳐하는 것 까진 알겠는데 그 다음, ppm파일로 저장을 시키는 것 같은데 ppm파일은 어디에 저장이 되는 건가요??;;;;
실행시키면 일정 숫자만 한 일분동안 쫙~ 나오다 끝나는데...
설마 이렇게 데이터 출력하고 끝나는 건가요? 저장 하는 부분이 어딘지 잘 모르긴 하겠지만;;;;
컴파일시킬때 pnmtojpeg -quality=100 img0.ppm>img0.jpg
요런 부분이 있는데 그러면 img0.jpg는 있어야 하는게 아닌가요?
도와주세요ㅠㅠ
관련 부분 소스 올립니다----
/* Map the address space for device to the address space for this process */
map = (char *)mmap(0, m_buf.size, PROT_READ, MAP_SHARED, fd, 0);
if(map == MAP_FAILED)
perror("mmap");
/* Set image parameters for mapped memory area */
v_map.frame = 0;
v_map.height = img_h;
v_map.width = img_w;
// v_map.format = VIDEO_PALETTE_RGB24;
pic.palette = VIDEO_PALETTE_YUV420P;
/* Capture a frame. The data will be present in the mapped user space */
if( (ret = ioctl(fd, VIDIOCMCAPTURE, &v_map)) < 0 ) {
fprintf(stderr,"ioctl on VIDIOCMCAPTURE failed\n");
exit(1);
}
/* Wait for end of frame */
if( (ret = ioctl(fd, VIDIOCSYNC, &v_map)) < 0 ) {
fprintf(stderr,"ioctl on VIDIOCSYNC failed\n");
exit(1);
}
map1=(char *)malloc(img_w*img_h*(img_d/8));
yuv2rgb_init();
yuv2rgb(map1,map,img_w*3,img_w,img_h);
/* print out RGB values for pixels of the frame to the standard output */
/* values are initially stored in memory in the BGR format */
// p = map;
p = map1;
printf("P3\n%d %d\n255", img_w, img_h);
for(i = 0; i < img_h; i++) {
for(j = 0; j < img_w; j++) {
if( (3*j%15) == 0 )
printf("\n");
printf("%d %d %d ", *(p+2), *(p+1), *p);
p = p + 3;
}
printf("\n");
}
댓글 달기