specify camera on command line
[challenge-bot] / bbb / opencv-hello-world / opencv-hello-world.cpp
index 02fea3ea1c374657dd72e46cc28190b009c4076e..55d58274ea17d2eea704dc4db1526202ccd2a5a8 100644 (file)
@@ -13,13 +13,15 @@ using namespace cv;
 using namespace std;
 
 int main(int argc, char** argv) {
-  VideoCapture camera;
-  camera.open(0);
-  Mat edges;
-  Mat frame;
+  if (argc < 2) {
+    cout << "supply a video device index." << endl;
+    cout << "probably 0 for beaglebone, 1 for laptop" << endl;
+    exit(0); }
+  VideoCapture camera(atoi(argv[1]));
   if(!camera.isOpened()) {
     cout << "not opened :( that's bad" << endl;
     exit(-1); }
+  Mat frame;
   camera >> frame;
   Mat grey_image;
   cvtColor(frame, grey_image, CV_BGR2GRAY);