cv :: Rect



Cv Rect



cv::Rect_クラステンプレートリファレンス
2D長方形のテンプレートクラス。

1. cv::Rect -オープン宣言

あなたの便宜のために、Rect_エイリアスが利用可能です:cv::Rect



template class Rect_ { public: typedef _Tp value_type //! default constructor Rect_() Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height) Rect_(const Rect_& r) Rect_(Rect_&& r) CV_NOEXCEPT Rect_(const Point_& org, const Size_& sz) Rect_(const Point_& pt1, const Point_& pt2) Rect_& operator = ( const Rect_& r ) Rect_& operator = ( Rect_&& r ) CV_NOEXCEPT //! the top-left corner Point_ tl() const //! the bottom-right corner Point_ br() const //! size (width, height) of the rectangle Size_ size() const //! area (width*height) of the rectangle _Tp area() const //! true if empty bool empty() const //! conversion to another data type template operator Rect_() const //! checks whether the rectangle contains the point bool contains(const Point_& pt) const _Tp x //!

2.例

//============================================================================ // Name : X11/Xlib.h // Author : Yongqiang Cheng // Version : Feb 22, 2020 // Copyright : Copyright (c) 2019 Yongqiang Cheng // Description : Hello World in C++, Ansi-style //============================================================================ #include #include #include using namespace std using namespace cv int main(int argc, char** argv) { int screen_num(0) int width(0) int height(0) unsigned long background(0) unsigned long border(0) Display *x11_info Screen *screen_info /* First connect to the display server. */ x11_info = XOpenDisplay(NULL) if (!x11_info) { cerr << 'Unable to connect to display' width Rect screen_rect(0, 0, screen_info->width, screen_info->height) /* These are macros that pull useful data out of the display object. */ /* We use these bits of info enough to want them in their own variables. */ screen_num = DefaultScreen(x11_info) background = BlackPixel(x11_info, screen_num) border = WhitePixel(x11_info, screen_num) cout << 'the height of the screen in pixels: ' << height << endl cout << 'the width of the screen in pixels: ' << width << endl cout << 'the black pixel value for the specified screen: ' << background << endl cout << 'the white pixel value for the specified screen: ' << border << endl cout << 'the default screen number referenced by the XOpenDisplay() function: ' << screen_num << endl cout << ' x coordinate of the top-left corner: ' << screen_rect.x << endl cout << 'y coordinate of the top-left corner: ' << screen_rect.y << endl cout << 'width of the rectangle: ' << screen_rect.width << endl cout << 'height of the rectangle: ' << screen_rect.height << endl return 0 } 15:36:43 **** Build of configuration Debug for project DisplayImage **** make all Building file: ../src/DisplayImage.cpp Invoking: GCC C++ Compiler g++ -std=c++0x -I/usr/local/include -I/usr/local/include/opencv4 -I/usr/local/include/opencv4/opencv2 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF'src/DisplayImage.d' -MT'src/DisplayImage.o' -o 'src/DisplayImage.o' '../src/DisplayImage.cpp' Finished building: ../src/DisplayImage.cpp Building target: DisplayImage Invoking: GCC C++ Linker g++ -L/usr/local/lib -o 'DisplayImage' ./src/DisplayImage.o -lopencv_core -lX11 -lopencv_video -lopencv_ml -lopencv_imgproc -lopencv_img_hash -lopencv_flann -lopencv_features2d -lopencv_calib3d -lopencv_dnn -lopencv_dnn_objdetect -lopencv_cvv -lopencv_text -lopencv_datasets -lopencv_aruco -lopencv_bgsegm -lopencv_shape -lopencv_imgcodecs -lopencv_videoio -lopencv_highgui -lopencv_bioinspired Finished building target: DisplayImage 15:36:46 Build Finished (took 2s.733ms) the height of the screen in pixels: 1080 the width of the screen in pixels: 1920 the black pixel value for the specified screen: 0 the white pixel value for the specified screen: 16777215 the default screen number referenced by the XOpenDisplay() function: 0 x coordinate of the top-left corner: 0 y coordinate of the top-left corner: 0 width of the rectangle: 1920 height of the rectangle: 1080