Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cv::Mat IMGCONVERT(string imgpath)
- {
- //This grabs the image at "imgpath", measures it, creates center measures, and copies a white border around it using those measures.
- // Then it returns the new image as a new Mat
- cout << "IMGCONVERT() called! n";
- Mat originalimage;
- Mat Finalimage;
- string imgtoloadpath = filepath + imgpath;
- originalimage = imread(imgtoloadpath.c_str(), IMREAD_COLOR);
- int imgrows = originalimage.rows; // integer number of rows in the image
- int imgcol = originalimage.cols; // integer number of columns in the image
- int TOPBOT = (screenheight-imgrows)/2; //Spacing to center image
- int LEFTRIGHT = (screenwidth-imgcol)/2; //Spacing to center image
- copyMakeBorder(originalimage, Finalimage, TOPBOT, TOPBOT, LEFTRIGHT, LEFTRIGHT, BORDER_CONSTANT, whitecolor); // (Source, destination, border, border, border, border, type (constant or from edge), color (if BORDER_CONSTANT)
- return Finalimage; // pass final image out of function
- }
- namedWindow("MAIN WINDOW", CV_WINDOW_NORMAL); //Create the main window. Must set CV_WINDOW_NORMAL so it can be resized in the next step.
- cvSetWindowProperty("MAIN WINDOW", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN); //Force the window to be fullscreen borderless.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement