46 #include <visp3/core/vpConfig.h> 48 #if defined(VISP_HAVE_OPENCV) 57 #include <visp3/core/vpDisplay.h> 58 #include <visp3/core/vpImageTools.h> 59 #include <visp3/core/vpIoTools.h> 60 #include <visp3/core/vpMath.h> 61 #include <visp3/gui/vpDisplayOpenCV.h> 64 #include <visp3/core/vpDebug.h> 65 #include <visp3/core/vpDisplayException.h> 67 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408) 69 #include <opencv2/core/core_c.h> 70 #include <opencv2/imgproc/imgproc.hpp> 73 #define CV_RGB(r, g, b) cv::Scalar((b), (g), (r), 0) 78 #include <visp3/gui/vpDisplayX.h> 83 std::vector<std::string> vpDisplayOpenCV::m_listTitles = std::vector<std::string>();
84 unsigned int vpDisplayOpenCV::m_nbWindows = 0;
109 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
110 m_background(NULL), col(NULL), cvcolor(), font(NULL),
112 m_background(), col(NULL), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f),
114 fontHeight(10), x_move(0), y_move(0), move(false), x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
115 x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
116 x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false), x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false), x_rbuttonup(0),
117 y_rbuttonup(0), rbuttonup(false)
149 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
150 m_background(NULL), col(NULL), cvcolor(), font(NULL),
152 m_background(), col(NULL), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f),
154 fontHeight(10), x_move(0), y_move(0), move(false), x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
155 x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
156 x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false), x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false), x_rbuttonup(0),
157 y_rbuttonup(0), rbuttonup(false)
160 init(I, x, y, title);
183 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
184 m_background(NULL), col(NULL), cvcolor(), font(NULL),
186 m_background(), col(NULL), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f),
188 fontHeight(10), x_move(0), y_move(0), move(false), x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
189 x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
190 x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false), x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false), x_rbuttonup(0),
191 y_rbuttonup(0), rbuttonup(false)
219 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
220 m_background(NULL), col(NULL), cvcolor(), font(NULL),
222 m_background(), col(NULL), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f),
224 fontHeight(10), x_move(0), y_move(0), move(false), x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
225 x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
226 x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false), x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false), x_rbuttonup(0),
227 y_rbuttonup(0), rbuttonup(false)
230 init(I, x, y, title);
257 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
258 m_background(NULL), col(NULL), cvcolor(), font(NULL),
260 m_background(), col(NULL), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f),
262 fontHeight(10), x_move(0), y_move(0), move(false), x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
263 x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
264 x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false), x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false), x_rbuttonup(0),
265 y_rbuttonup(0), rbuttonup(false)
270 if (!title.empty()) {
273 std::ostringstream s;
275 m_title = std::string(
"Window ") + s.str();
281 for (
size_t i = 0; i < m_listTitles.size(); i++) {
282 if (m_listTitles[i] ==
m_title) {
283 std::ostringstream s;
285 m_title = std::string(
"Window ") + s.str();
292 m_listTitles.push_back(
m_title);
316 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
317 m_background(NULL), col(NULL), cvcolor(), font(NULL),
319 m_background(), col(NULL), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f),
321 fontHeight(10), x_move(0), y_move(0), move(false), x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
322 x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
323 x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false), x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false), x_rbuttonup(0),
324 y_rbuttonup(0), rbuttonup(false)
334 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 335 cvReleaseImage(&m_background);
400 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 401 int flags = CV_WINDOW_AUTOSIZE;
403 int flags = cv::WINDOW_AUTOSIZE;
407 if (!title.empty()) {
411 std::ostringstream s;
413 m_title = std::string(
"Window ") + s.str();
419 for (
size_t i = 0; i < m_listTitles.size(); i++) {
420 if (m_listTitles[i] ==
m_title) {
421 std::ostringstream s;
423 m_title = std::string(
"Window ") + s.str();
430 m_listTitles.push_back(
m_title);
434 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 435 if (cvNamedWindow(this->
m_title.c_str(), flags) < 0) {
439 cv::namedWindow(this->
m_title, flags);
441 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 453 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 500 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 502 cvInitFont(font, CV_FONT_HERSHEY_PLAIN, 0.70f, 0.70f);
505 cvGetTextSize(
"A", font, &fontSize, &baseline);
510 fontSize = cv::getTextSize(
"A", font, fontScale, thickness, &baseline);
513 fontHeight = fontSize.height + baseline;
564 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 565 cvMoveWindow(this->
m_title.c_str(), winx, winy);
567 cv::moveWindow(this->
m_title.c_str(), winx, winy);
587 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 591 if (m_background != NULL) {
592 if (m_background->nChannels != channels || m_background->depth != depth ||
593 m_background->height != (
int)m_height || m_background->width != (
int)m_width) {
594 if (m_background->nChannels != 0)
595 cvReleaseImage(&m_background);
596 m_background = cvCreateImage(size, depth, channels);
599 m_background = cvCreateImage(size, depth, channels);
603 for (
unsigned int i = 0; i <
m_height; i++) {
604 unsigned char *dst_24 = (
unsigned char *)m_background->imageData + (
int)(i * m_background->widthStep);
605 for (
unsigned int j = 0; j <
m_width; j++) {
606 unsigned char val = I[i][j];
613 for (
unsigned int i = 0; i <
m_height; i++) {
614 unsigned char *dst_24 = (
unsigned char *)m_background->imageData + (
int)(i * m_background->widthStep);
615 for (
unsigned int j = 0; j <
m_width; j++) {
627 cv::Size size((
int)m_width, (
int)m_height);
628 if (m_background.channels() != channels || m_background.depth() != depth || m_background.rows != (int)m_height ||
629 m_background.cols != (
int)
m_width) {
630 m_background = cv::Mat(size, CV_MAKETYPE(depth, channels));
634 for (
unsigned int i = 0; i <
m_height; i++) {
635 unsigned char *dst_24 = (
unsigned char *)m_background.data + (
int)(i * 3 *
m_width);
636 for (
unsigned int j = 0; j <
m_width; j++) {
637 unsigned char val = I[i][j];
644 for (
unsigned int i = 0; i <
m_height; i++) {
645 unsigned char *dst_24 = (
unsigned char *)m_background.data + (
int)(i * 3 *
m_width);
646 for (
unsigned int j = 0; j <
m_width; j++) {
680 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 684 if (m_background != NULL) {
685 if (m_background->nChannels != channels || m_background->depth != depth ||
686 m_background->height != (
int)m_height || m_background->width != (
int)m_width) {
687 if (m_background->nChannels != 0)
688 cvReleaseImage(&m_background);
689 m_background = cvCreateImage(size, depth, channels);
692 m_background = cvCreateImage(size, depth, channels);
696 unsigned int i_min = (
unsigned int)iP.
get_i();
697 unsigned int j_min = (
unsigned int)iP.
get_j();
698 unsigned int i_max = (std::min)(i_min + h, m_height);
699 unsigned int j_max = (std::min)(j_min + w, m_width);
700 for (
unsigned int i = i_min; i < i_max; i++) {
701 unsigned char *dst_24 =
702 (
unsigned char *)m_background->imageData + (
int)(i * m_background->widthStep + j_min * 3);
703 for (
unsigned int j = j_min; j < j_max; j++) {
704 unsigned char val = I[i][j];
711 int i_min = (std::max)((
int)ceil(iP.
get_i() /
m_scale), 0);
712 int j_min = (std::max)((
int)ceil(iP.
get_j() /
m_scale), 0);
713 int i_max = (std::min)((
int)ceil((iP.
get_i() + h) /
m_scale), (int)m_height);
714 int j_max = (std::min)((
int)ceil((iP.
get_j() + w) /
m_scale), (int)m_width);
715 for (
int i = i_min; i < i_max; i++) {
716 unsigned char *dst_24 =
717 (
unsigned char *)m_background->imageData + (
int)(i * m_background->widthStep + j_min * 3);
718 for (
int j = j_min; j < j_max; j++) {
730 cv::Size size((
int)m_width, (
int)m_height);
731 if (m_background.channels() != channels || m_background.depth() != depth || m_background.rows != (int)m_height ||
732 m_background.cols != (
int)
m_width) {
733 m_background = cv::Mat(size, CV_MAKETYPE(depth, channels));
737 unsigned int i_min = (
unsigned int)iP.
get_i();
738 unsigned int j_min = (
unsigned int)iP.
get_j();
739 unsigned int i_max = (std::min)(i_min + h, m_height);
740 unsigned int j_max = (std::min)(j_min + w, m_width);
741 for (
unsigned int i = i_min; i < i_max; i++) {
742 unsigned char *dst_24 = (
unsigned char *)m_background.data + (
int)(i * 3 * m_width + j_min * 3);
743 for (
unsigned int j = j_min; j < j_max; j++) {
744 unsigned char val = I[i][j];
751 int i_min = (std::max)((
int)ceil(iP.
get_i() /
m_scale), 0);
752 int j_min = (std::max)((
int)ceil(iP.
get_j() /
m_scale), 0);
753 int i_max = (std::min)((
int)ceil((iP.
get_i() + h) /
m_scale), (int)m_height);
754 int j_max = (std::min)((
int)ceil((iP.
get_j() + w) /
m_scale), (int)m_width);
755 for (
int i = i_min; i < i_max; i++) {
756 unsigned char *dst_24 = (
unsigned char *)m_background.data + (
int)(i * 3 * m_width + j_min * 3);
757 for (
int j = j_min; j < j_max; j++) {
786 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 790 if (m_background != NULL) {
791 if (m_background->nChannels != channels || m_background->depth != depth ||
792 m_background->height != (
int)m_height || m_background->width != (
int)m_width) {
793 if (m_background->nChannels != 0)
794 cvReleaseImage(&m_background);
795 m_background = cvCreateImage(size, depth, channels);
798 m_background = cvCreateImage(size, depth, channels);
802 for (
unsigned int i = 0; i <
m_height; i++) {
803 unsigned char *dst_24 = (
unsigned char *)m_background->imageData + (
int)(i * m_background->widthStep);
804 for (
unsigned int j = 0; j <
m_width; j++) {
812 for (
unsigned int i = 0; i <
m_height; i++) {
813 unsigned char *dst_24 = (
unsigned char *)m_background->imageData + (
int)(i * m_background->widthStep);
814 for (
unsigned int j = 0; j <
m_width; j++) {
825 cv::Size size((
int)this->m_width, (
int)this->m_height);
826 if (m_background.channels() != channels || m_background.depth() != depth || m_background.rows != (int)m_height ||
827 m_background.cols != (
int)
m_width) {
828 m_background = cv::Mat(size, CV_MAKETYPE(depth, channels));
832 for (
unsigned int i = 0; i <
m_height; i++) {
833 unsigned char *dst_24 = (
unsigned char *)m_background.data + (
int)(i * 3 *
m_width);
834 for (
unsigned int j = 0; j <
m_width; j++) {
842 for (
unsigned int i = 0; i <
m_height; i++) {
843 unsigned char *dst_24 = (
unsigned char *)m_background.data + (
int)(i * 3 *
m_width);
844 for (
unsigned int j = 0; j <
m_width; j++) {
877 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 881 if (m_background != NULL) {
882 if (m_background->nChannels != channels || m_background->depth != depth ||
883 m_background->height != (
int)m_height || m_background->width != (
int)m_width) {
884 if (m_background->nChannels != 0)
885 cvReleaseImage(&m_background);
886 m_background = cvCreateImage(size, depth, channels);
889 m_background = cvCreateImage(size, depth, channels);
893 unsigned int i_min = (
unsigned int)iP.
get_i();
894 unsigned int j_min = (
unsigned int)iP.
get_j();
895 unsigned int i_max = (std::min)(i_min + h, m_height);
896 unsigned int j_max = (std::min)(j_min + w, m_width);
897 for (
unsigned int i = i_min; i < i_max; i++) {
898 unsigned char *dst_24 =
899 (
unsigned char *)m_background->imageData + (
int)(i * m_background->widthStep + j_min * 3);
900 for (
unsigned int j = j_min; j < j_max; j++) {
908 int i_min = (std::max)((
int)ceil(iP.
get_i() /
m_scale), 0);
909 int j_min = (std::max)((
int)ceil(iP.
get_j() /
m_scale), 0);
910 int i_max = (std::min)((
int)ceil((iP.
get_i() + h) /
m_scale), (int)m_height);
911 int j_max = (std::min)((
int)ceil((iP.
get_j() + w) /
m_scale), (int)m_width);
912 for (
int i = i_min; i < i_max; i++) {
913 unsigned char *dst_24 =
914 (
unsigned char *)m_background->imageData + (
int)(i * m_background->widthStep + j_min * 3);
915 for (
int j = j_min; j < j_max; j++) {
926 cv::Size size((
int)this->m_width, (
int)this->m_height);
927 if (m_background.channels() != channels || m_background.depth() != depth || m_background.rows != (int)m_height ||
928 m_background.cols != (
int)
m_width) {
929 m_background = cv::Mat(size, CV_MAKETYPE(depth, channels));
933 unsigned int i_min = (
unsigned int)iP.
get_i();
934 unsigned int j_min = (
unsigned int)iP.
get_j();
935 unsigned int i_max = (std::min)(i_min + h, m_height);
936 unsigned int j_max = (std::min)(j_min + w, m_width);
937 for (
unsigned int i = i_min; i < i_max; i++) {
938 unsigned char *dst_24 = (
unsigned char *)m_background.data + (
int)(i * 3 * m_width + j_min * 3);
939 for (
unsigned int j = j_min; j < j_max; j++) {
947 int i_min = (std::max)((
int)ceil(iP.
get_i() /
m_scale), 0);
948 int j_min = (std::max)((
int)ceil(iP.
get_j() /
m_scale), 0);
949 int i_max = (std::min)((
int)ceil((iP.
get_i() + h) /
m_scale), (int)m_height);
950 int j_max = (std::min)((
int)ceil((iP.
get_j() + w) /
m_scale), (int)m_width);
951 for (
int i = i_min; i < i_max; i++) {
952 unsigned char *dst_24 = (
unsigned char *)m_background.data + (
int)(i * 3 * m_width + j_min * 3);
953 for (
int j = j_min; j < j_max; j++) {
987 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 994 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 995 cvDestroyWindow(this->
m_title.c_str());
997 cv::destroyWindow(this->
m_title);
1000 for (
size_t i = 0; i < m_listTitles.size(); i++) {
1001 if (
m_title == m_listTitles[i]) {
1002 m_listTitles.erase(m_listTitles.begin() + (
long int)i);
1021 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1022 cvShowImage(this->
m_title.c_str(), m_background);
1025 cv::imshow(this->
m_title, m_background);
1039 const unsigned int )
1042 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1043 cvShowImage(this->
m_title.c_str(), m_background);
1046 cv::imshow(this->
m_title.c_str(), m_background);
1059 static bool warn_displayed =
false;
1060 if (!warn_displayed) {
1062 warn_displayed =
true;
1074 unsigned int w,
unsigned int h,
unsigned int thickness)
1082 if ((std::fabs(a) <= std::numeric_limits<double>::epsilon()) &&
1083 (std::fabs(b) <= std::numeric_limits<double>::epsilon())) {
1128 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1129 cvPutText(m_background, text,
1133 cv::putText(m_background, text,
1135 font, fontScale, col[color.
id]);
1138 cvcolor = CV_RGB(color.
R, color.
G, color.
B);
1139 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1140 cvPutText(m_background, text,
1144 cv::putText(m_background, text,
1146 font, fontScale, cvcolor);
1163 unsigned int thickness)
1166 if (fill ==
false) {
1168 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1169 cvCircle(m_background,
1171 (int)radius /
m_scale, col[color.
id], (
int)thickness);
1173 cv::circle(m_background,
1175 (int)radius /
m_scale, col[color.
id], (
int)thickness);
1178 cvcolor = CV_RGB(color.
R, color.
G, color.
B);
1179 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1180 cvCircle(m_background,
1182 (int)radius /
m_scale, cvcolor, (
int)thickness);
1184 cv::circle(m_background,
1186 (int)radius /
m_scale, cvcolor, (
int)thickness);
1190 #if VISP_HAVE_OPENCV_VERSION >= 0x030000 1191 int filled = cv::FILLED;
1193 int filled = CV_FILLED;
1196 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1197 cvCircle(m_background,
1199 (int)radius /
m_scale, col[color.
id], filled);
1201 cv::circle(m_background,
1203 (int)radius /
m_scale, col[color.
id], filled);
1206 cvcolor = CV_RGB(color.
R, color.
G, color.
B);
1207 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1208 cvCircle(m_background,
1210 (int)radius /
m_scale, cvcolor, filled);
1212 cv::circle(m_background,
1214 (int)radius /
m_scale, cvcolor, filled);
1231 unsigned int thickness)
1258 unsigned int thickness)
1266 bool vertical_line = (int)ip2_.
get_j() == (int)ip1_.
get_j();
1267 if (vertical_line) {
1269 std::swap(ip1_, ip2_);
1272 std::swap(ip1_, ip2_);
1275 double diff_j = vertical_line ? 1 : ip2_.
get_j() - ip1_.
get_j();
1276 double deltaj = size / length * diff_j;
1277 double deltai = size / length * (ip2_.
get_i() - ip1_.
get_i());
1278 double slope = (ip2_.
get_i() - ip1_.
get_i()) / diff_j;
1279 double orig = ip1_.
get_i() - slope * ip1_.
get_j();
1281 if (vertical_line) {
1282 for (
unsigned int i = (
unsigned int)ip1_.
get_i(); i < ip2_.
get_i(); i += (
unsigned int)(2 * deltai)) {
1283 double j = ip1_.
get_j();
1287 for (
unsigned int j = (
unsigned int)ip1_.
get_j(); j < ip2_.
get_j(); j += (
unsigned int)(2 * deltaj)) {
1288 double i = slope * j + orig;
1304 unsigned int thickness)
1308 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1318 cvcolor = CV_RGB(color.
R, color.
G, color.
B);
1319 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1343 for (
unsigned int i = 0; i < thickness; i++) {
1345 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1348 col[color.
id], (int)thickness);
1352 col[color.
id], (int)thickness);
1355 cvcolor = CV_RGB(color.
R, color.
G, color.
B);
1356 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1359 cvcolor, (int)thickness);
1363 cvcolor, (int)thickness);
1386 const vpColor &color,
bool fill,
unsigned int thickness)
1389 if (fill ==
false) {
1391 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1395 col[color.
id], (
int)thickness);
1400 col[color.
id], (
int)thickness);
1403 cvcolor = CV_RGB(color.
R, color.
G, color.
B);
1404 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1408 cvcolor, (
int)thickness);
1413 cvcolor, (
int)thickness);
1417 #if VISP_HAVE_OPENCV_VERSION >= 0x030000 1418 int filled = cv::FILLED;
1420 int filled = CV_FILLED;
1423 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1427 col[color.
id], filled);
1432 col[color.
id], filled);
1435 cvcolor = CV_RGB(color.
R, color.
G, color.
B);
1436 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1466 const vpColor &color,
bool fill,
unsigned int thickness)
1469 if (fill ==
false) {
1471 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1472 cvRectangle(m_background,
1475 col[color.
id], (int)thickness);
1480 col[color.
id], (int)thickness);
1483 cvcolor = CV_RGB(color.
R, color.
G, color.
B);
1484 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1485 cvRectangle(m_background,
1488 cvcolor, (int)thickness);
1493 cvcolor, (int)thickness);
1497 #if VISP_HAVE_OPENCV_VERSION >= 0x030000 1498 int filled = cv::FILLED;
1500 int filled = CV_FILLED;
1503 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1504 cvRectangle(m_background,
1507 col[color.
id], filled);
1512 col[color.
id], filled);
1515 cvcolor = CV_RGB(color.
R, color.
G, color.
B);
1516 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1517 cvRectangle(m_background,
1548 if (fill ==
false) {
1550 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1555 col[color.
id], (int)thickness);
1561 col[color.
id], (int)thickness);
1564 cvcolor = CV_RGB(color.
R, color.
G, color.
B);
1565 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1570 cvcolor, (int)thickness);
1577 cvcolor, (int)thickness);
1582 #if VISP_HAVE_OPENCV_VERSION >= 0x030000 1583 int filled = cv::FILLED;
1585 int filled = CV_FILLED;
1588 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1593 col[color.
id], filled);
1599 col[color.
id], filled);
1602 cvcolor = CV_RGB(color.
R, color.
G, color.
B);
1603 #if VISP_HAVE_OPENCV_VERSION < 0x020408 1644 lbuttondown =
false;
1645 mbuttondown =
false;
1646 rbuttondown =
false;
1651 lbuttondown =
false;
1655 mbuttondown =
false;
1659 rbuttondown =
false;
1662 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1667 }
while (ret ==
false && blocking ==
true);
1699 lbuttondown =
false;
1700 mbuttondown =
false;
1701 rbuttondown =
false;
1706 u = (
unsigned int)x_lbuttondown *
m_scale;
1707 v = (
unsigned int)y_lbuttondown *
m_scale;
1710 lbuttondown =
false;
1714 u = (
unsigned int)x_mbuttondown *
m_scale;
1715 v = (
unsigned int)y_mbuttondown *
m_scale;
1718 mbuttondown =
false;
1722 u = (
unsigned int)x_rbuttondown *
m_scale;
1723 v = (
unsigned int)y_rbuttondown *
m_scale;
1726 rbuttondown =
false;
1729 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1734 }
while (ret ==
false && blocking ==
true);
1767 lbuttondown =
false;
1768 mbuttondown =
false;
1769 rbuttondown =
false;
1774 u = (
unsigned int)x_lbuttondown *
m_scale;
1775 v = (
unsigned int)y_lbuttondown *
m_scale;
1779 lbuttondown =
false;
1783 u = (
unsigned int)x_mbuttondown *
m_scale;
1784 v = (
unsigned int)y_mbuttondown *
m_scale;
1788 mbuttondown =
false;
1792 u = (
unsigned int)x_rbuttondown *
m_scale;
1793 v = (
unsigned int)y_rbuttondown *
m_scale;
1797 rbuttondown =
false;
1800 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1805 }
while (ret ==
false && blocking ==
true);
1847 u = (
unsigned int)x_lbuttonup *
m_scale;
1848 v = (
unsigned int)y_lbuttonup *
m_scale;
1856 u = (
unsigned int)x_mbuttonup *
m_scale;
1857 v = (
unsigned int)y_mbuttonup *
m_scale;
1865 u = (
unsigned int)x_rbuttonup *
m_scale;
1866 v = (
unsigned int)y_rbuttonup *
m_scale;
1873 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1878 }
while (ret ==
false && blocking ==
true);
1899 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1900 case CV_EVENT_MOUSEMOVE:
1902 case cv::EVENT_MOUSEMOVE:
1910 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1911 case CV_EVENT_LBUTTONDOWN:
1913 case cv::EVENT_LBUTTONDOWN:
1916 disp->lbuttondown =
true;
1917 disp->x_lbuttondown = x;
1918 disp->y_lbuttondown = y;
1921 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1922 case CV_EVENT_MBUTTONDOWN:
1924 case cv::EVENT_MBUTTONDOWN:
1927 disp->mbuttondown =
true;
1928 disp->x_mbuttondown = x;
1929 disp->y_mbuttondown = y;
1932 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1933 case CV_EVENT_RBUTTONDOWN:
1935 case cv::EVENT_RBUTTONDOWN:
1938 disp->rbuttondown =
true;
1939 disp->x_rbuttondown = x;
1940 disp->y_rbuttondown = y;
1943 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1944 case CV_EVENT_LBUTTONUP:
1946 case cv::EVENT_LBUTTONUP:
1949 disp->lbuttonup =
true;
1950 disp->x_lbuttonup = x;
1951 disp->y_lbuttonup = y;
1954 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1955 case CV_EVENT_MBUTTONUP:
1957 case cv::EVENT_MBUTTONUP:
1960 disp->mbuttonup =
true;
1961 disp->x_mbuttonup = x;
1962 disp->y_mbuttonup = y;
1965 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 1966 case CV_EVENT_RBUTTONUP:
1968 case cv::EVENT_RBUTTONUP:
1971 disp->rbuttonup =
true;
1972 disp->x_rbuttonup = x;
1973 disp->y_rbuttonup = y;
2007 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 2008 int key_pressed = cvWaitKey(delay);
2010 int key_pressed = cv::waitKey(delay);
2013 if (key_pressed == -1)
2049 #if (VISP_HAVE_OPENCV_VERSION < 0x020408) 2050 int key_pressed = cvWaitKey(delay);
2052 int key_pressed = cv::waitKey(delay);
2054 if (key_pressed == -1)
2058 std::stringstream ss;
2087 double u = (
unsigned int)x_move /
m_scale;
2088 double v = (
unsigned int)y_move /
m_scale;
2117 u = (
unsigned int)x_move /
m_scale;
2118 v = (
unsigned int)y_move /
m_scale;
2136 #if defined(VISP_HAVE_X11) 2139 #elif defined(VISP_HAVE_XRANDR) 2140 std::string command =
"xrandr | grep '*'";
2141 FILE *fpipe = (FILE *)popen(command.c_str(),
"r");
2143 while (fgets(line,
sizeof(line), fpipe)) {
2144 std::string str(line);
2145 std::size_t found = str.find(
"Failed");
2147 if (found == std::string::npos) {
2148 std::vector<std::string> elm;
2150 for (
size_t i = 0; i < elm.size(); i++) {
2151 if (!elm[i].empty()) {
2153 if (resolution.size() == 2) {
2154 std::istringstream sswidth(resolution[0]), ssheight(resolution[1]);
2164 #elif defined(_WIN32) 2166 w = GetSystemMetrics(SM_CXSCREEN);
2167 h = GetSystemMetrics(SM_CYSCREEN);
2170 "implemented on winrt"));
2180 unsigned int width, height;
2190 unsigned int width, height;
2195 #elif !defined(VISP_BUILD_SHARED_LIBS) 2198 void dummy_vpDisplayOpenCV(){};
void getScreenSize(unsigned int &width, unsigned int &height)
void displayCircle(const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)
void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green)
unsigned int getScreenHeight()
int m_windowYPosition
display position
Class that defines generic functionnalities for display.
void clearDisplay(const vpColor &color=vpColor::white)
void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
void flushDisplayROI(const vpImagePoint &iP, unsigned int width, unsigned int height)
unsigned char B
Blue component.
static const vpColor black
static const vpColor darkRed
bool getClick(bool blocking=true)
void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
Class to define colors available for display functionnalities.
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
error that can be emited by ViSP classes.
static const vpColor lightGray
void setFont(const std::string &font)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, unsigned int width, unsigned int height)
bool getPointerPosition(vpImagePoint &ip)
static const vpColor darkBlue
unsigned char G
Green component.
bool m_displayHasBeenInitialized
display has been initialized
static const vpColor green
void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static const vpColor lightRed
virtual ~vpDisplayOpenCV()
void displayImage(const vpImage< unsigned char > &I)
static const vpColor orange
void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
static void on_mouse(int event, int x, int y, int flags, void *param)
int m_windowXPosition
display position
static const vpColor cyan
static const vpColor lightGreen
void setScale(vpScaleType scaleType, unsigned int width, unsigned int height)
static double sqr(double x)
void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void getScreenSize(unsigned int &width, unsigned int &height)
void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)
void setTitle(const std::string &title)
bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)
static const vpColor gray
static const vpColor darkGray
static int round(double x)
bool getPointerMotionEvent(vpImagePoint &ip)
Error that can be emited by the vpDisplay class and its derivates.
unsigned int getHeight() const
void getImage(vpImage< vpRGBa > &I)
get the window pixmap and put it in vpRGBa image
unsigned int getScreenWidth()
unsigned char R
Red component.
Defines a rectangle in the plane.
static const vpColor darkGreen
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static const vpColor yellow
static const vpColor lightBlue
static const vpColor purple
static const vpColor white
unsigned int getWidth() const
Function not implemented.
bool getKeyboardEvent(bool blocking=true)
static double distance(const vpImagePoint &iP1, const vpImagePoint &iP2)
void setWindowPosition(int winx, int winy)
static const vpColor blue