-1

i'm just starting to learn to use openCV and windows.h in c++ and i wanted to learn to play with images. I found online

HWND hwndDesktop = GetDesktopWindow();
Mat src = hwnd2mat(hwndDesktop);
imshow("output", src);
waitKey(0);

this bit of code to get a screenshot, but when i tried it, it said that identifier "hwnd2mat" is undefined and i found nothing online. Is it because i didn't install opencv correctly? this is my try

#include <iostream>
#include <opencv2/opencv.hpp>
#include <Windows.h>

using namespace std;
using namespace cv;

int main()
{
    HWND num = GetDesktopWindow();
    Mat src = hwnd2mat(num);

    return 0;
}
king
  • 1
  • 3
  • It's probably the code in this post https://stackoverflow.com/questions/51451213/opencv-c-hwnd2matscreenshot-blobfromimage-error - does not mean it works Answer claims to have working code. – Richard Critten Jun 04 '22 at 14:51
  • hwnd2mat is a function, you need the actual code (sure you can find it here somewhere) – berak Jun 04 '22 at 14:52
  • `hwnd2mat` is not a function in opencv. It's an external utility using opencv's `cv::Mat` to hold the captured image. You need the source code (or library with header) for this utility. – wohlstad Jun 04 '22 at 14:55
  • take the [tour], review [ask]. this site has rules. – Christoph Rackwitz Jun 04 '22 at 16:49
  • @ChristophRackwitz besides the order(that i said the problem at the end of the text) i don't really see how i didn't respect the rest – king Jun 05 '22 at 05:30
  • @RichardCritten it's the code in this post https://stackoverflow.com/questions/34466993/opencv-desktop-capture – king Jun 05 '22 at 05:30

0 Answers0