截取特定区域的屏幕截图

时间:2015-01-23 22:38:29

标签: c++ opencv screenshot

寻找一种在C ++中截取屏幕上特定区域的屏幕截图的方法。 (所以不是整个屏幕)然后它应该保存为.png .jpg,然后将其与其他功能一起使用。

另外,我将以某种方式使用openCV。我想提一下,也许这是一个有用的细节。

1 个答案:

答案 0 :(得分:0)

OpenCV无法直接从您的计算机截取屏幕截图。您将需要一个不同的框架/方法来执行此操作。 @Ben是正确的,this link值得调查。

读完此图片后,您需要将其存储到cv:Mat中,以便能够对其执行OpenCV操作。

要在OpenCV中裁剪图像,以下代码段会有所帮助。

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);
相关问题