私は自分のlinux pcでスクリーンショットをキャプチャしようとしています。コードのコンパイルは大丈夫ですが、私はそれを実行しようとすると、それは以下のように同じエラーを投げ続けて:誰が問題であるかを把握するために私を助けることができるX11 XGetImage BadMatchエラー(無効なパラメータ属性)
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 73 (X_GetImage)
Serial number of failed request: 7
Current serial number in output stream: 7
?
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
using namespace cv;
int main()
{
Display* d = XOpenDisplay(nullptr);
auto root = DefaultRootWindow(d);
auto img = XGetImage(d, root, 0, 0, 1000, 1000, AllPlanes, ZPixmap);
auto rimg = Mat(1000, 1000, CV_8UC4, img->data);
imshow("test image", rimg);
waitKey(0);
return 0;
}
を呼び出す前に
を使用してDISPLAY環境変数設定されていますか?そうであれば、nullptrの代わりにNULLを使用してみてください。 – cup
私は他のことに触れませんでした。そして、NULLは機能しません。 –
XOpenDisplayのパラメータがNULLまたはnullptrの場合、DISPLAY環境変数の値が使用されます。 DISPLAY環境変数が設定されていないと、エラーが発生します。 – cup