From d3b4165227672786b91d4850eb198b3524d7f49f Mon Sep 17 00:00:00 2001 From: daniel watson Date: Sun, 6 Mar 2016 14:58:19 -0800 Subject: [PATCH] specify camera on command line --- bbb/opencv-hello-world/makefile | 12 +++++++++++- bbb/opencv-hello-world/opencv-hello-world.cpp | 10 ++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bbb/opencv-hello-world/makefile b/bbb/opencv-hello-world/makefile index 91052dd..88d4fa6 100644 --- a/bbb/opencv-hello-world/makefile +++ b/bbb/opencv-hello-world/makefile @@ -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. diff --git a/bbb/opencv-hello-world/opencv-hello-world.cpp b/bbb/opencv-hello-world/opencv-hello-world.cpp index 02fea3e..55d5827 100644 --- a/bbb/opencv-hello-world/opencv-hello-world.cpp +++ b/bbb/opencv-hello-world/opencv-hello-world.cpp @@ -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); -- 2.30.2