Skip to content
Snippets Groups Projects
Commit 2423dfff authored by Noah Eigenfeld's avatar Noah Eigenfeld
Browse files

Added overlay with control options

parent 3906ed43
No related branches found
No related tags found
1 merge request!3Added overlay with control options
...@@ -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