90 lines
1.7 KiB
C++
90 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
|
|
#include <X11/Xlib.h>
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/extensions/XShm.h>
|
|
#include <sys/ipc.h>
|
|
#include <sys/shm.h>
|
|
|
|
#undef Bool
|
|
#undef CursorShape
|
|
#undef None
|
|
#undef KeyPress
|
|
#undef KeyRelease
|
|
#undef ButtonPress
|
|
#undef ButtonRelease
|
|
#undef MotionNotify
|
|
#undef EnterNotify
|
|
#undef LeaveNotify
|
|
#undef FocusIn
|
|
#undef FocusOut
|
|
#undef KeymapNotify
|
|
#undef Expose
|
|
#undef GraphicsExpose
|
|
#undef NoExpose
|
|
#undef VisibilityNotify
|
|
#undef CreateNotify
|
|
#undef DestroyNotify
|
|
#undef UnmapNotify
|
|
#undef MapNotify
|
|
#undef MapRequest
|
|
#undef ReparentNotify
|
|
#undef ConfigureNotify
|
|
#undef ConfigureRequest
|
|
#undef GravityNotify
|
|
#undef ResizeRequest
|
|
#undef CirculateNotify
|
|
#undef CirculateRequest
|
|
#undef PropertyNotify
|
|
#undef SelectionClear
|
|
#undef SelectionRequest
|
|
#undef SelectionNotify
|
|
#undef ColormapNotify
|
|
#undef ClientMessage
|
|
#undef MappingNotify
|
|
#undef GenericEvent
|
|
#undef LASTEvent
|
|
#undef FontChange
|
|
|
|
class ScreenShot {
|
|
private:
|
|
Display* display = nullptr;
|
|
Window window;
|
|
XWindowAttributes wattrib;
|
|
XImage* ximg = nullptr;
|
|
XShmSegmentInfo shminfo;
|
|
|
|
bool init;
|
|
bool closeDisp = true;
|
|
bool valid = false;
|
|
std::string windowname;
|
|
|
|
bool updateAttrib();
|
|
bool initImg();
|
|
public:
|
|
|
|
static std::vector<ScreenShot*> getWindows(const std::string& name);
|
|
|
|
static const uint32_t DEFAULTWIDTH;
|
|
static const uint32_t DEFAULTHEIGHT;
|
|
|
|
ScreenShot();
|
|
ScreenShot(Display* d, Window w);
|
|
virtual ~ScreenShot();
|
|
|
|
virtual void take(cv::Mat& cvimg);
|
|
virtual void operator() (cv::Mat& cvimg);
|
|
|
|
constexpr operator bool () const {
|
|
return valid;
|
|
}
|
|
|
|
virtual int getXOffset() const;
|
|
virtual int getYOffset() const;
|
|
virtual double getXScale() const;
|
|
virtual double getYScale() const;
|
|
};
|