testCamera.cpp
Go to the documentation of this file.
1 #include "camera.h"
2 #include <fstream>
3 #include <iostream>
4 
5 int main(int argc, char *argv[])
6 {
7  int w=640, h=480, n=1;
8  for (int i=1; i<argc; i++){
9  if (strcmp(argv[i], "-w") == 0){
10  w = atoi(argv[++i]);
11  }else if (strcmp(argv[i], "-h") == 0){
12  h = atoi(argv[++i]);
13  }else if (strcmp(argv[i], "-n") == 0){
14  n = atoi(argv[++i]);
15  }
16  }
17 
18  v4l_capture cam;
19 
20  if (cam.init(w, h, n) != 0){
21  std::cerr << "failed to initialize device(/dev/video" << n << ")"
22  << std::endl;
23  return 1;
24  }
25 
26  uchar *img = cam.capture();
27 
28  std::ofstream ofs("test.ppm");
29  ofs << "P6" << std::endl;
30  ofs << w << " " << h << std::endl;
31  ofs << "255" << std::endl;
32  ofs.write((const char *)img, w*h*3);
33 
34  return 0;
35 }
w
png_uint_32 i
int init(size_t _width, size_t _height, unsigned int devId)
Definition: camera.cpp:23
n
int main(int argc, char *argv[])
Definition: testCamera.cpp:5
uchar * capture()
Definition: camera.cpp:33


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:51