From 1cd2b11901835f1afbf10d12bb34354f88f22d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Callyhoskinson=E2=80=9D?= Date: Mon, 6 Mar 2023 00:08:03 -0600 Subject: [PATCH 1/2] Added image frame and text output functionalities --- src/main.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index b39c1db8256..6bc1dcacecc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,11 +2,17 @@ #include #include +#include +#include +#include "opencv2/highgui/highgui.hpp" + // /brlcad/build/share/db/moss.g // /brlcad/src/gtools/rgen/visualization // ../../../../../build/bin/mged ../db/moss.g tops // ../../../../../build/bin/rt ../db/moss.g all.g +using namespace cv; + int main(int argc, char **argv) { if (argc == 2) { const char* filename = argv[1]; @@ -17,6 +23,45 @@ int main(int argc, char **argv) { auto result2 = system(rtAll); std::cout << "Success\n"; } else { + // To create an image + // CV_8UC3 depicts : (3 channels,8 bit image depth) + // Height = 750 pixels, Width = 1500 pixels + // Background is set to white + Mat img(750, 1500, CV_8UC3, Scalar(255,255,255)); + + putText(img, "Report:", Point(0, 50), FONT_HERSHEY_DUPLEX, 1.0, CV_RGB(0, 0, 0), 1); + + // check whether the image is loaded or not + if (img.empty()) + { + std::cout << "\n Image not created. You" + " have done something wrong. \n"; + return -1; // Unsuccessful. + } + + // first argument: name of the window + // second argument: flag- types: + // WINDOW_NORMAL If this is set, the user can + // resize the window. + // WINDOW_AUTOSIZE If this is set, the window size + // is automatically adjusted to fit + // the displayed image, and you cannot + // change the window size manually. + // WINDOW_OPENGL If this is set, the window will be + // created with OpenGL support. + namedWindow("Report", WINDOW_AUTOSIZE); + + //Saves to png + imwrite("report.png", img); + + // first argument: name of the window + // second argument: image to be shown(Mat object) + imshow("Report", img); + + waitKey(0); //wait infinite time for a keypress + + // destroy the window with the name, "MyWindow" + destroyWindow("Report"); return 1; } } From 4166a485bd4fab61065832ce04a25ea6ca2a4f07 Mon Sep 17 00:00:00 2001 From: Michael Tao Date: Mon, 6 Mar 2023 14:11:38 -0600 Subject: [PATCH 2/2] trying out shapes --- src/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 6bc1dcacecc..84d3c80d212 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,6 +58,15 @@ int main(int argc, char **argv) { // second argument: image to be shown(Mat object) imshow("Report", img); + /* Mat whiteMatrix(200, 200, CV_8UC3, Scalar(255, 255, 255));//Declaring a white matrix + Point center(100, 100);//Declaring the center point + int radius = 50; //Declaring the radius + Scalar line_Color(0, 0, 0);//Color of the circle + int thickness = 2;//thickens of the line + namedWindow("whiteMatrix");//Declaring a window to show the circle + circle(whiteMatrix, center,radius, line_Color, thickness);//Using circle()function to draw the line// + imshow("WhiteMatrix", whiteMatrix);//Showing the circle//*/ + waitKey(0); //wait infinite time for a keypress // destroy the window with the name, "MyWindow"