specify camera on command line
authordaniel watson <ozzloy@gmail.com>
Sun, 6 Mar 2016 22:58:19 +0000 (14:58 -0800)
committerdaniel watson <ozzloy@gmail.com>
Sun, 6 Mar 2016 23:11:10 +0000 (15:11 -0800)
bbb/opencv-hello-world/makefile
bbb/opencv-hello-world/opencv-hello-world.cpp

index 91052dd96def24dafc9cf1aff9aa44b2bb28a559..88d4fa6a27c40507bc65c30fd1285b847629c691 100644 (file)
@@ -10,7 +10,17 @@ LIBS = `pkg-config --libs opencv`
        g++ $(CFLAGS) $(LIBS) -o $@ $<
 
 all: opencv-hello-world
-       ./opencv-hello-world
+
+1: all
+       ./opencv-hello-world 1
+       eog .
+
+0: all
+       ./opencv-hello-world 0
+       eog .
+
+clean:
+       rm image.png image-grey.png
 
 # This file is part of challenge-bot.
 
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);