Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpDisplayOpenCV.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 *
30 * Description:
31 * Image display.
32 */
33
34#ifndef VP_DISPLAY_OPENCV_H
35#define VP_DISPLAY_OPENCV_H
36
37#include <visp3/core/vpConfig.h>
38#include <visp3/core/vpDisplay.h>
39
40#if defined(HAVE_OPENCV_HIGHGUI)
41
42#include <functional>
43
44#include <visp3/core/vpImage.h>
45#include <visp3/core/vpImageConvert.h>
46
48
53
138class VISP_EXPORT vpDisplayOpenCV : public vpDisplay
139{
140public:
142 vpDisplayOpenCV(int winx, int winy, const std::string &title = "");
144 vpDisplayOpenCV(vpImage<unsigned char> &I, int winx = -1, int winy = -1, const std::string &title = "",
147 vpDisplayOpenCV(vpImage<vpRGBa> &I, int winx = -1, int winy = -1, const std::string &title = "",
150 virtual ~vpDisplayOpenCV() VP_OVERRIDE;
152
153 void getImage(vpImage<vpRGBa> &I) VP_OVERRIDE;
154 unsigned int getScreenHeight() VP_OVERRIDE;
155 void getScreenSize(unsigned int &width, unsigned int &height) VP_OVERRIDE;
156 unsigned int getScreenWidth() VP_OVERRIDE;
157
158 void init(vpImage<unsigned char> &I, int winx = -1, int winy = -1, const std::string &title = "") VP_OVERRIDE;
159 void init(vpImage<vpRGBa> &I, int winx = -1, int winy = -1, const std::string &title = "") VP_OVERRIDE;
160 void init(unsigned int width, unsigned int height, int winx = -1, int winy = -1, const std::string &title = "") VP_OVERRIDE;
161
162protected:
163 void setFont(const std::string &font) VP_OVERRIDE;
164 void setTitle(const std::string &title) VP_OVERRIDE;
165 void setWindowPosition(int winx, int winy) VP_OVERRIDE;
166
167 void clearDisplay(const vpColor &color = vpColor::white) VP_OVERRIDE;
168
169 void closeDisplay() VP_OVERRIDE;
170
171 void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color = vpColor::white,
172 unsigned int w = 4, unsigned int h = 2, unsigned int thickness = 1) VP_OVERRIDE;
173
174 void displayCircle(const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill = false,
175 unsigned int thickness = 1) VP_OVERRIDE;
176 void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness = 1) VP_OVERRIDE;
177 void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color,
178 unsigned int thickness = 1) VP_OVERRIDE;
179
180 void displayImage(const vpImage<unsigned char> &I) VP_OVERRIDE;
181 void displayImage(const vpImage<vpRGBa> &I) VP_OVERRIDE;
182 void displayImage(const unsigned char *I);
183
184 void displayImageROI(const vpImage<unsigned char> &I, const vpImagePoint &iP, unsigned int width,
185 unsigned int height) VP_OVERRIDE;
186 void displayImageROI(const vpImage<vpRGBa> &I, const vpImagePoint &iP, unsigned int width, unsigned int height) VP_OVERRIDE;
187
188 void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness = 1) VP_OVERRIDE;
189 void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness = 1) VP_OVERRIDE;
190
191 void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color,
192 bool fill = false, unsigned int thickness = 1) VP_OVERRIDE;
193 void displayRectangle(const vpImagePoint &topLeft, const vpImagePoint &bottomRight, const vpColor &color,
194 bool fill = false, unsigned int thickness = 1) VP_OVERRIDE;
195 void displayRectangle(const vpRect &rectangle, const vpColor &color, bool fill = false, unsigned int thickness = 1) VP_OVERRIDE;
196
197 void displayText(const vpImagePoint &ip, const std::string &text, const vpColor &color = vpColor::green) VP_OVERRIDE;
198
199 void flushDisplay() VP_OVERRIDE;
200 void flushDisplayROI(const vpImagePoint &iP, unsigned int width, unsigned int height) VP_OVERRIDE;
201
202 bool getClick(bool blocking = true) VP_OVERRIDE;
203 bool getClick(vpImagePoint &ip, bool blocking = true) VP_OVERRIDE;
204 bool getClick(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking = true) VP_OVERRIDE;
205 bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking = true) VP_OVERRIDE;
206
207 bool getKeyboardEvent(bool blocking = true) VP_OVERRIDE;
208 bool getKeyboardEvent(std::string &key, bool blocking = true) VP_OVERRIDE;
209 bool getPointerMotionEvent(vpImagePoint &ip) VP_OVERRIDE;
210 bool getPointerPosition(vpImagePoint &ip) VP_OVERRIDE;
211
212private:
213 // Implementation
214 class Impl;
215 Impl *m_impl;
216};
217
218END_VISP_NAMESPACE
219#endif
220#endif
Class to define RGB colors available for display functionalities.
Definition vpColor.h:157
static const vpColor white
Definition vpColor.h:193
static const vpColor green
Definition vpColor.h:201
void flushDisplayROI(const vpImagePoint &iP, unsigned int width, unsigned int height) VP_OVERRIDE
void flushDisplay() VP_OVERRIDE
void getScreenSize(unsigned int &width, unsigned int &height) VP_OVERRIDE
void clearDisplay(const vpColor &color=vpColor::white) VP_OVERRIDE
unsigned int getScreenWidth() VP_OVERRIDE
void closeDisplay() VP_OVERRIDE
void displayImage(const vpImage< unsigned char > &I) VP_OVERRIDE
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="") VP_OVERRIDE
unsigned int getScreenHeight() VP_OVERRIDE
void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, unsigned int width, unsigned int height) VP_OVERRIDE
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void displayCircle(const vpImage< unsigned char > &I, const vpImageCircle &circle, const vpColor &color, bool fill=false, unsigned int thickness=1)
static bool getKeyboardEvent(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
static bool getClickUp(const vpImage< unsigned char > &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static void displayArrow(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
static void setFont(const vpImage< unsigned char > &I, const std::string &font)
vpDisplay & operator=(const vpDisplay &)=default
static void displayDotLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
static bool getPointerPosition(const vpImage< unsigned char > &I, vpImagePoint &ip)
static bool getPointerMotionEvent(const vpImage< unsigned char > &I, vpImagePoint &ip)
@ SCALE_DEFAULT
Definition vpDisplay.h:198
static void displayRectangle(const vpImage< unsigned char > &I, const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
static void setWindowPosition(const vpImage< unsigned char > &I, int winx, int winy)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
Definition vpImage.h:131
Defines a rectangle in the plane.
Definition vpRect.h:79