0

Looking for a way for taking a screenshot of a particular area on the screen in C++. (So not the whole screen) Then it should save it as .png .jpg whatever to use it with another function afterwards.

Also, I am going to use it, somehow, with openCV. Thought i'd mention that, maybe it's a helpful detail.

nintschger
  • 1,786
  • 5
  • 30
  • 45

1 Answers1

0

OpenCV cannot take screenshots from your computer directly. You will need a different framework/method to do this. @Ben is correct, this link would be worth investigating.

Once you have read this image in, you will need to store it into a cv:Mat so that you are able to perform OpenCV operations on it.

In order to crop an image in OpenCV the following code snippet would help.

CVMat * imagesource;

// Transform it into the C++ cv::Mat format
cv::Mat image(imagesource); 

// Setup a rectangle to define your region of interest
cv::Rect myROI(10, 10, 100, 100);

// Crop the full image to that image contained by the rectangle myROI
// Note that this doesn't copy the data
cv::Mat croppedImage = image(myROI);
GPPK
  • 6,546
  • 4
  • 32
  • 57