Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. cv::Mat IMGCONVERT(string imgpath)
  2. {
  3. //This grabs the image at "imgpath", measures it, creates center measures, and copies a white border around it using those measures.
  4. // Then it returns the new image as a new Mat
  5. cout << "IMGCONVERT() called! n";
  6. Mat originalimage;
  7. Mat Finalimage;
  8. string imgtoloadpath = filepath + imgpath;
  9. originalimage = imread(imgtoloadpath.c_str(), IMREAD_COLOR);
  10. int imgrows = originalimage.rows; // integer number of rows in the image
  11. int imgcol = originalimage.cols; // integer number of columns in the image
  12. int TOPBOT = (screenheight-imgrows)/2; //Spacing to center image
  13. int LEFTRIGHT = (screenwidth-imgcol)/2; //Spacing to center image
  14. 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)
  15. return Finalimage; // pass final image out of function
  16. }
  17.  
  18. namedWindow("MAIN WINDOW", CV_WINDOW_NORMAL); //Create the main window. Must set CV_WINDOW_NORMAL so it can be resized in the next step.
  19. 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