Skip to content
Snippets Groups Projects
Commit 60272eda authored by johni's avatar johni
Browse files

Merge branch 'add-countdown-before-picture-taken' into 'master'

Added overlay with control options

We decided not to use a countdown before the picture is taken, as this seems like more of an annoyance than a feature.

See merge request !3
parents 3906ed43 2423dfff
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,13 @@ int main() { ...@@ -36,7 +36,13 @@ int main() {
return 1; return 1;
} }
imshow("Webcam", frame); //show some test text
Mat frame_with_text = frame.clone();
putText(frame_with_text, "Press Spacebar to take a picture", Point2f(110,100), FONT_HERSHEY_SIMPLEX, 2.0, Scalar(255,0,0,0), 3);
putText(frame_with_text, "Press ESC to close the application", Point2f(90,600), FONT_HERSHEY_SIMPLEX, 2.0, Scalar(0,0,255,255), 3);
imshow("Webcam", frame_with_text);
key = waitKey(30); key = waitKey(30);
if (key == 27) { //escape key pressed: stop program if (key == 27) { //escape key pressed: stop program
...@@ -44,18 +50,23 @@ int main() { ...@@ -44,18 +50,23 @@ int main() {
break; break;
} }
else if (key == ' ') { //spacebar pressed: take a picture else if (key == ' ') { //spacebar pressed: take a picture
picture = frame; picture = frame;
key = -1; key = -1;
while (true) { while (true) {
imshow("Webcam", picture); Mat picture_with_text = picture.clone();
putText(picture_with_text, "Press 's' to save", Point2f(375,100), FONT_HERSHEY_SIMPLEX, 2.0, Scalar(255,0,0,0), 3);
putText(picture_with_text, "Press ESC/Spacebar to return", Point2f(160,600), FONT_HERSHEY_SIMPLEX, 2.0, Scalar(0,0,255,255), 3);
imshow("Webcam", picture_with_text);
key = waitKey(30); key = waitKey(30);
if (key == 27 || key == 32) { if (key == 27 || key == 32) { //spacebar or ESC pressed
cout << "ESC or SPACE pressed. Returning to video..." << endl; cout << "ESC or SPACE pressed. Returning to video..." << endl;
break; break;
} else if (key == 115) { } else if (key == 115) { //s pressed
bool maybe = imwrite("./testimage.jpg", picture); bool maybe = imwrite("./testimage.jpg", picture);
cout << "s was pressed. saving image " << maybe << endl; cout << "s was pressed. saving image " << maybe << endl;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment