Go to the documentation of this file.00001 #include "camera.h"
00002 #include <fstream>
00003 #include <iostream>
00004
00005 int main(int argc, char *argv[])
00006 {
00007 int w=640, h=480, n=1;
00008 for (int i=1; i<argc; i++){
00009 if (strcmp(argv[i], "-w") == 0){
00010 w = atoi(argv[++i]);
00011 }else if (strcmp(argv[i], "-h") == 0){
00012 h = atoi(argv[++i]);
00013 }else if (strcmp(argv[i], "-n") == 0){
00014 n = atoi(argv[++i]);
00015 }
00016 }
00017
00018 v4l_capture cam;
00019
00020 if (cam.init(w, h, n) != 0){
00021 std::cerr << "failed to initialize device(/dev/video" << n << ")"
00022 << std::endl;
00023 return 1;
00024 }
00025
00026 uchar *img = cam.capture();
00027
00028 std::ofstream ofs("test.ppm");
00029 ofs << "P6" << std::endl;
00030 ofs << w << " " << h << std::endl;
00031 ofs << "255" << std::endl;
00032 ofs.write((const char *)img, w*h*3);
00033
00034 return 0;
00035 }