Skip to content

Instantly share code, notes, and snippets.

@boustrophedon
Last active September 15, 2015 20:10
Show Gist options
  • Save boustrophedon/db80461a5b7a3faee564 to your computer and use it in GitHub Desktop.
Save boustrophedon/db80461a5b7a3faee564 to your computer and use it in GitHub Desktop.
#include <iostream> // for standard I/O
#include <string> // for strings
#include <opencv2/core/core.hpp> // Basic OpenCV structures (cv::Mat)
#include <opencv2/highgui/highgui.hpp> // Video write
using namespace std;
using namespace cv;
int main() {
VideoCapture cap(0);
double w = cap.get(CV_CAP_PROP_FRAME_WIDTH);
double h = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
cout << "frame size" << w << " " << h << endl;
namedWindow("Video", CV_WINDOW_AUTOSIZE);
while (1) {
Mat frame;
bool success = cap.read(frame);
if (!success) {
cout << "couldn't read video" << endl;
}
imshow("Video", frame);
if (waitKey(30) == 27) {
cout << "exit" << endl;
break;
}
}
}
CC=g++
CFLAGS=-Wall -Werror
LDFLAGS=-lopencv_core -lopencv_highgui
all: main
OBJS = main.o
main: $(OBJS)
$(CC) -o $@ $(OBJS) $(LDFLAGS)
main.o: main.cpp
$(CC) -o $@ $(CFLAGS) -c $<
clean:
rm main $(OBJS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment