46 #include <visp3/core/vpConfig.h>
48 #if defined(VISP_HAVE_OPENCV)
57 #include <visp3/core/vpDisplay.h>
58 #include <visp3/gui/vpDisplayOpenCV.h>
59 #include <visp3/core/vpMath.h>
60 #include <visp3/core/vpImageTools.h>
61 #include <visp3/core/vpIoTools.h>
64 #include <visp3/core/vpDebug.h>
65 #include <visp3/core/vpDisplayException.h>
67 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
69 # include <opencv2/imgproc/imgproc.hpp>
70 # include <opencv2/core/core_c.h>
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;
105 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
106 m_background(NULL), col(NULL), cvcolor(), font(NULL),
108 m_background(), col(NULL), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f),
110 fontHeight(10), x_move(0), y_move(0) , move(false),
111 x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
112 x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false),
113 x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
114 x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false),
115 x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false),
116 x_rbuttonup(0), y_rbuttonup(0), rbuttonup(false)
146 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
147 m_background(NULL), col(NULL), cvcolor(), font(NULL),
149 m_background(), col(NULL), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f),
151 fontHeight(10), x_move(0), y_move(0) , move(false),
152 x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
153 x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false),
154 x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
155 x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false),
156 x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false),
157 x_rbuttonup(0), y_rbuttonup(0), rbuttonup(false)
160 init(I, x, y, title) ;
179 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
180 m_background(NULL), col(NULL), cvcolor(), font(NULL),
182 m_background(), col(NULL), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f),
184 fontHeight(10), x_move(0), y_move(0) , move(false),
185 x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
186 x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false),
187 x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
188 x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false),
189 x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false),
190 x_rbuttonup(0), y_rbuttonup(0), rbuttonup(false)
216 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
217 m_background(NULL), col(NULL), cvcolor(), font(NULL),
219 m_background(), col(NULL), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f),
221 fontHeight(10), x_move(0), y_move(0) , move(false),
222 x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
223 x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false),
224 x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
225 x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false),
226 x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false),
227 x_rbuttonup(0), 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),
263 x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
264 x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false),
265 x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
266 x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false),
267 x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false),
268 x_rbuttonup(0), y_rbuttonup(0), rbuttonup(false)
277 std::ostringstream s;
279 m_title = std::string(
"Window ") + s.str();
285 for(
size_t i = 0 ; i < m_listTitles.size() ; i++){
286 if(m_listTitles[i] ==
m_title){
287 std::ostringstream s;
289 m_title = std::string(
"Window ") + s.str();
297 m_listTitles.push_back(
m_title);
321 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
322 m_background(NULL), col(NULL), cvcolor(), font(NULL),
324 m_background(), col(NULL), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f),
326 fontHeight(10), x_move(0), y_move(0) , move(false),
327 x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
328 x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false),
329 x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
330 x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false),
331 x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false),
332 x_rbuttonup(0), y_rbuttonup(0), rbuttonup(false)
342 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
343 cvReleaseImage(&m_background);
359 const std::string &title)
364 "Image not initialized")) ;
385 const std::string &title)
390 "Image not initialized")) ;
412 const std::string &title)
423 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
424 int flags = CV_WINDOW_AUTOSIZE;
426 int flags = cv::WINDOW_AUTOSIZE;
435 std::ostringstream s;
437 m_title = std::string(
"Window ") + s.str();
443 for(
size_t i = 0 ; i < m_listTitles.size() ; i++){
444 if(m_listTitles[i] ==
m_title){
445 std::ostringstream s;
447 m_title = std::string(
"Window ") + s.str();
455 m_listTitles.push_back(
m_title);
459 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
460 if (cvNamedWindow( this->
m_title.c_str(), flags ) < 0) {
462 "OpenCV was not built with a display device")) ;
465 cv::namedWindow( this->
m_title, flags );
467 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
479 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
526 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
528 cvInitFont( font, CV_FONT_HERSHEY_PLAIN, 0.70f,0.70f);
531 cvGetTextSize(
"A", font, &fontSize, &baseline );
536 fontSize = cv::getTextSize(
"A", font, fontScale, thickness, &baseline );
539 fontHeight = fontSize.height + baseline;
596 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
597 cvMoveWindow( this->
m_title.c_str(), winx, winy );
599 cv::moveWindow( this->
m_title.c_str(), winx, winy );
605 "OpenCV not initialized")) ;
623 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
627 if (m_background != NULL){
628 if(m_background->nChannels != channels || m_background->depth != depth
629 || m_background->height != (
int) m_height || m_background->width != (
int) m_width){
630 if(m_background->nChannels != 0) cvReleaseImage(&m_background);
631 m_background = cvCreateImage( size, depth, channels );
635 m_background = cvCreateImage( size, depth, channels );
639 for (
unsigned int i=0; i<
m_height; i++) {
640 unsigned char *dst_24 = (
unsigned char* ) m_background->imageData + (
int)(i*m_background->widthStep);
641 for (
unsigned int j=0; j<
m_width; j++) {
642 unsigned char val = I[i][j];
643 * ( dst_24 ++ ) = val;
644 * ( dst_24 ++ ) = val;
645 * ( dst_24 ++ ) = val;
650 for (
unsigned int i=0; i<
m_height; i++) {
651 unsigned char *dst_24 = (
unsigned char* ) m_background->imageData + (
int)(i*m_background->widthStep);
652 for (
unsigned int j=0; j<
m_width; j++) {
654 * ( dst_24 ++ ) = val;
655 * ( dst_24 ++ ) = val;
656 * ( dst_24 ++ ) = val;
664 cv::Size size((
int)m_width, (
int)m_height);
665 if(m_background.channels() != channels || m_background.depth() != depth
666 || m_background.rows != (int) m_height || m_background.cols != (
int)
m_width){
667 m_background = cv::Mat( size, CV_MAKETYPE(depth, channels) );
671 for (
unsigned int i=0; i<
m_height; i++) {
672 unsigned char *dst_24 = (
unsigned char* ) m_background.data + (
int)(i*3*
m_width);
673 for (
unsigned int j=0; j<
m_width; j++) {
674 unsigned char val = I[i][j];
675 * ( dst_24 ++ ) = val;
676 * ( dst_24 ++ ) = val;
677 * ( dst_24 ++ ) = val;
682 for (
unsigned int i=0; i<
m_height; i++) {
683 unsigned char *dst_24 = (
unsigned char* ) m_background.data + (
int)(i*3*
m_width);
684 for (
unsigned int j=0; j<
m_width; j++) {
686 * ( dst_24 ++ ) = val;
687 * ( dst_24 ++ ) = val;
688 * ( dst_24 ++ ) = val;
698 "OpenCV not initialized")) ;
718 const unsigned int w,
const unsigned int h )
722 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
726 if (m_background != NULL){
727 if(m_background->nChannels != channels || m_background->depth != depth
728 || m_background->height != (
int) m_height || m_background->width != (
int) m_width){
729 if(m_background->nChannels != 0) cvReleaseImage(&m_background);
730 m_background = cvCreateImage( size, depth, channels );
734 m_background = cvCreateImage( size, depth, channels );
738 unsigned int i_min = (
unsigned int)iP.
get_i();
739 unsigned int j_min = (
unsigned int)iP.
get_j();
740 unsigned int i_max = std::min(i_min + h, m_height);
741 unsigned int j_max = std::min(j_min + w, m_width);
742 for (
unsigned int i=i_min; i<i_max; i++) {
743 unsigned char *dst_24 = (
unsigned char* ) m_background->imageData + (
int)(i*m_background->widthStep + j_min*3);
744 for (
unsigned int j=j_min; j<j_max; j++) {
745 unsigned char val = I[i][j];
746 * ( dst_24 ++ ) = val;
747 * ( dst_24 ++ ) = val;
748 * ( dst_24 ++ ) = val;
755 int i_max = std::min((
int)ceil((iP.
get_i() + h)/
m_scale), (int)m_height);
756 int j_max = std::min((
int)ceil((iP.
get_j() + w)/
m_scale), (int)m_width);
757 for (
int i=i_min; i<i_max; i++) {
758 unsigned char *dst_24 = (
unsigned char* ) m_background->imageData + (
int)(i*m_background->widthStep + j_min*3);
759 for (
int j=j_min; j<j_max; j++) {
761 * ( dst_24 ++ ) = val;
762 * ( dst_24 ++ ) = val;
763 * ( dst_24 ++ ) = val;
771 cv::Size size((
int)m_width, (
int)m_height);
772 if(m_background.channels() != channels || m_background.depth() != depth
773 || m_background.rows != (int) m_height || m_background.cols != (
int)
m_width){
774 m_background = cv::Mat( size, CV_MAKETYPE(depth, channels) );
778 unsigned int i_min = (
unsigned int)iP.
get_i();
779 unsigned int j_min = (
unsigned int)iP.
get_j();
780 unsigned int i_max = std::min(i_min + h, m_height);
781 unsigned int j_max = std::min(j_min + w, m_width);
782 for (
unsigned int i=i_min; i<i_max; i++) {
783 unsigned char *dst_24 = (
unsigned char* ) m_background.data + (
int)(i*3*m_width + j_min*3);
784 for (
unsigned int j=j_min; j<j_max; j++) {
785 unsigned char val = I[i][j];
786 * ( dst_24 ++ ) = val;
787 * ( dst_24 ++ ) = val;
788 * ( dst_24 ++ ) = val;
795 int i_max = std::min((
int)ceil((iP.
get_i() + h)/
m_scale), (int)m_height);
796 int j_max = std::min((
int)ceil((iP.
get_j() + w)/
m_scale), (int)m_width);
797 for (
int i=i_min; i<i_max; i++) {
798 unsigned char *dst_24 = (
unsigned char* ) m_background.data + (
int)(i*3*m_width + j_min*3);
799 for (
int j=j_min; j<j_max; j++) {
801 * ( dst_24 ++ ) = val;
802 * ( dst_24 ++ ) = val;
803 * ( dst_24 ++ ) = val;
812 "OpenCV not initialized")) ;
833 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
837 if (m_background != NULL){
838 if(m_background->nChannels != channels || m_background->depth != depth
839 || m_background->height != (
int) m_height || m_background->width != (
int) m_width){
840 if(m_background->nChannels != 0) cvReleaseImage(&m_background);
841 m_background = cvCreateImage( size, depth, channels );
845 m_background = cvCreateImage( size, depth, channels );
849 for (
unsigned int i=0; i<
m_height; i++) {
850 unsigned char *dst_24 = (
unsigned char* ) m_background->imageData + (
int)(i*m_background->widthStep);
851 for (
unsigned int j=0; j<
m_width; j++) {
853 * ( dst_24 ++ ) = val.
B;
854 * ( dst_24 ++ ) = val.
G;
855 * ( dst_24 ++ ) = val.
R;
860 for (
unsigned int i=0; i<
m_height; i++) {
861 unsigned char *dst_24 = (
unsigned char* ) m_background->imageData + (
int)(i*m_background->widthStep);
862 for (
unsigned int j=0; j<
m_width; j++) {
864 * ( dst_24 ++ ) = val.
B;
865 * ( dst_24 ++ ) = val.
G;
866 * ( dst_24 ++ ) = val.
R;
873 cv::Size size((
int)this->m_width, (
int)this->m_height);
874 if(m_background.channels() != channels || m_background.depth() != depth
875 || m_background.rows != (int) m_height || m_background.cols != (
int)
m_width){
876 m_background = cv::Mat( size, CV_MAKETYPE(depth, channels) );
880 for (
unsigned int i=0; i<
m_height; i++) {
881 unsigned char *dst_24 = (
unsigned char* ) m_background.data + (
int)(i*3*
m_width);
882 for (
unsigned int j=0; j<
m_width; j++) {
884 * ( dst_24 ++ ) = val.
B;
885 * ( dst_24 ++ ) = val.
G;
886 * ( dst_24 ++ ) = val.
R;
891 for (
unsigned int i=0; i<
m_height; i++) {
892 unsigned char *dst_24 = (
unsigned char* ) m_background.data + (
int)(i*3*
m_width);
893 for (
unsigned int j=0; j<
m_width; j++) {
895 * ( dst_24 ++ ) = val.
B;
896 * ( dst_24 ++ ) = val.
G;
897 * ( dst_24 ++ ) = val.
R;
906 "OpenCV not initialized")) ;
926 const unsigned int w,
const unsigned int h )
930 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
934 if (m_background != NULL){
935 if(m_background->nChannels != channels || m_background->depth != depth
936 || m_background->height != (
int) m_height || m_background->width != (
int) m_width){
937 if(m_background->nChannels != 0) cvReleaseImage(&m_background);
938 m_background = cvCreateImage( size, depth, channels );
942 m_background = cvCreateImage( size, depth, channels );
946 unsigned int i_min = (
unsigned int)iP.
get_i();
947 unsigned int j_min = (
unsigned int)iP.
get_j();
948 unsigned int i_max = std::min(i_min + h, m_height);
949 unsigned int j_max = std::min(j_min + w, m_width);
950 for (
unsigned int i=i_min; i<i_max; i++) {
951 unsigned char *dst_24 = (
unsigned char* ) m_background->imageData + (
int)(i*m_background->widthStep + j_min*3);
952 for (
unsigned int j=j_min; j<j_max; j++) {
954 * ( dst_24 ++ ) = val.
B;
955 * ( dst_24 ++ ) = val.
G;
956 * ( dst_24 ++ ) = val.
R;
963 int i_max = std::min((
int)ceil((iP.
get_i() + h)/
m_scale), (int)m_height);
964 int j_max = std::min((
int)ceil((iP.
get_j() + w)/
m_scale), (int)m_width);
965 for (
int i=i_min; i<i_max; i++) {
966 unsigned char *dst_24 = (
unsigned char* ) m_background->imageData + (
int)(i*m_background->widthStep + j_min*3);
967 for (
int j=j_min; j<j_max; j++) {
969 * ( dst_24 ++ ) = val.
B;
970 * ( dst_24 ++ ) = val.
G;
971 * ( dst_24 ++ ) = val.
R;
978 cv::Size size((
int)this->m_width, (
int)this->m_height);
979 if(m_background.channels() != channels || m_background.depth() != depth
980 || m_background.rows != (int) m_height || m_background.cols != (
int)
m_width){
981 m_background = cv::Mat( size, CV_MAKETYPE(depth, channels) );
985 unsigned int i_min = (
unsigned int)iP.
get_i();
986 unsigned int j_min = (
unsigned int)iP.
get_j();
987 unsigned int i_max = std::min(i_min + h, m_height);
988 unsigned int j_max = std::min(j_min + w, m_width);
989 for (
unsigned int i=i_min; i<i_max; i++) {
990 unsigned char *dst_24 = (
unsigned char* ) m_background.data + (
int)(i*3*m_width + j_min*3);
991 for (
unsigned int j=j_min; j<j_max; j++) {
993 * ( dst_24 ++ ) = val.
B;
994 * ( dst_24 ++ ) = val.
G;
995 * ( dst_24 ++ ) = val.
R;
1000 int i_min = std::max((
int)ceil(iP.
get_i()/
m_scale), 0);
1001 int j_min = std::max((
int)ceil(iP.
get_j()/
m_scale), 0);
1002 int i_max = std::min((
int)ceil((iP.
get_i() + h)/
m_scale), (int)m_height);
1003 int j_max = std::min((
int)ceil((iP.
get_j() + w)/
m_scale), (int)m_width);
1004 for (
int i=i_min; i<i_max; i++) {
1005 unsigned char *dst_24 = (
unsigned char* ) m_background.data + (
int)(i*3*m_width + j_min*3);
1006 for (
int j=j_min; j<j_max; j++) {
1008 * ( dst_24 ++ ) = val.
B;
1009 * ( dst_24 ++ ) = val.
G;
1010 * ( dst_24 ++ ) = val.
R;
1019 "OpenCV not initialized")) ;
1030 vpTRACE(
" not implemented ") ;
1044 delete [] col ; col = NULL ;
1046 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
1054 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
1055 cvDestroyWindow( this->
m_title.c_str() );
1057 cv::destroyWindow( this->
m_title );
1060 for(
size_t i = 0 ; i < m_listTitles.size() ; i++){
1061 if(
m_title == m_listTitles[i]){
1062 m_listTitles.erase(m_listTitles.begin()+(
long int)i);
1083 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
1084 cvShowImage(this->
m_title.c_str(), m_background );
1087 cv::imshow(this->
m_title, m_background );
1094 "OpenCV not initialized")) ;
1107 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
1108 cvShowImage(this->
m_title.c_str(), m_background );
1111 cv::imshow(this->
m_title.c_str(), m_background );
1118 "OpenCV not initialized")) ;
1128 static bool warn_displayed =
false;
1129 if (! warn_displayed) {
1131 warn_displayed =
true;
1145 unsigned int w,
unsigned int h,
1146 unsigned int thickness)
1155 if ((std::fabs(a) <= std::numeric_limits<double>::epsilon())
1156 &&(std::fabs(b)<= std::numeric_limits<double>::epsilon()))
1188 "OpenCV not initialized")) ;
1204 const char *text,
const vpColor &color )
1209 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1210 cvPutText( m_background, text,
1213 font, col[color.
id] );
1215 cv::putText( m_background, text,
1218 font, fontScale, col[color.
id] );
1222 cvcolor = CV_RGB(color.
R, color.
G, color.
B) ;
1223 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1224 cvPutText( m_background, text,
1229 cv::putText( m_background, text,
1232 font, fontScale, cvcolor );
1239 "OpenCV not initialized")) ;
1252 unsigned int radius,
1255 unsigned int thickness)
1259 if (fill ==
false) {
1261 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1262 cvCircle( m_background,
1265 (int)radius /
m_scale, col[color.
id], (
int)thickness);
1267 cv::circle( m_background,
1270 (int)radius /
m_scale, col[color.
id], (
int)thickness);
1274 cvcolor = CV_RGB(color.
R, color.
G, color.
B) ;
1275 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1276 cvCircle( m_background,
1279 (int)radius /
m_scale, cvcolor, (
int)thickness);
1281 cv::circle( m_background,
1284 (int)radius /
m_scale, cvcolor, (
int)thickness);
1289 #if VISP_HAVE_OPENCV_VERSION >= 0x030000
1290 int filled = cv::FILLED;
1292 int filled = CV_FILLED;
1295 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1296 cvCircle( m_background,
1299 (int)radius /
m_scale, col[color.
id], filled);
1301 cv::circle( m_background,
1304 (int)radius /
m_scale, col[color.
id], filled);
1308 cvcolor = CV_RGB(color.
R, color.
G, color.
B) ;
1309 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1310 cvCircle( m_background,
1313 (int)radius /
m_scale, cvcolor, filled);
1315 cv::circle( m_background,
1318 (int)radius /
m_scale, cvcolor, filled);
1326 "OpenCV not initialized")) ;
1341 unsigned int thickness)
1360 "OpenCV not initialized")) ;
1376 unsigned int thickness)
1382 double deltaj = size/length*(ip2.
get_j() - ip1.
get_j());
1383 double deltai = size/length*(ip2.
get_i() - ip1.
get_i());
1385 double orig = ip1.
get_i() - slope*ip1.
get_j();
1386 for(
unsigned int j=(
unsigned int)ip1.
get_j(); j< ip2.
get_j(); j+=(
unsigned int)(2*deltaj)) {
1387 double i = slope*j+orig;
1394 "OpenCV not initialized")) ;
1409 unsigned int thickness)
1414 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1415 cvLine( m_background,
1420 col[color.
id], (int) thickness);
1422 cv::line( m_background,
1427 col[color.
id], (int) thickness);
1431 cvcolor = CV_RGB(color.
R, color.
G, color.
B) ;
1432 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1433 cvLine( m_background,
1438 cvcolor, (int) thickness);
1440 cv::line( m_background,
1445 cvcolor, (int) thickness);
1452 "OpenCV not initialized")) ;
1466 for(
unsigned int i=0; i<thickness; i++) {
1468 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1469 cvLine( m_background,
1474 col[color.
id], (int) thickness);
1476 cv::line( m_background,
1481 col[color.
id], (int) thickness);
1485 cvcolor = CV_RGB(color.
R, color.
G, color.
B) ;
1486 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1487 cvLine( m_background,
1492 cvcolor, (int) thickness);
1494 cv::line( m_background,
1499 cvcolor, (int) thickness);
1507 "OpenCV not initialized")) ;
1526 unsigned int w,
unsigned int h,
1527 const vpColor &color,
bool fill,
1528 unsigned int thickness)
1532 if (fill ==
false) {
1534 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1535 cvRectangle( m_background,
1540 col[color.
id], (
int)thickness);
1542 cv::rectangle( m_background,
1547 col[color.
id], (
int)thickness);
1551 cvcolor = CV_RGB(color.
R, color.
G, color.
B) ;
1552 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1553 cvRectangle( m_background,
1558 cvcolor, (
int)thickness);
1560 cv::rectangle( m_background,
1565 cvcolor, (
int)thickness);
1570 #if VISP_HAVE_OPENCV_VERSION >= 0x030000
1571 int filled = cv::FILLED;
1573 int filled = CV_FILLED;
1576 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1577 cvRectangle( m_background,
1582 col[color.
id], filled);
1584 cv::rectangle( m_background,
1589 col[color.
id], filled);
1593 cvcolor = CV_RGB(color.
R, color.
G, color.
B) ;
1594 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1595 cvRectangle( m_background,
1602 cv::rectangle( m_background,
1615 "OpenCV not initialized")) ;
1633 const vpColor &color,
bool fill,
1634 unsigned int thickness )
1638 if (fill ==
false) {
1640 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1641 cvRectangle( m_background,
1646 col[color.
id], (int)thickness);
1648 cv::rectangle( m_background,
1653 col[color.
id], (int)thickness);
1657 cvcolor = CV_RGB(color.
R, color.
G, color.
B) ;
1658 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1659 cvRectangle( m_background,
1664 cvcolor, (int)thickness);
1666 cv::rectangle( m_background,
1671 cvcolor, (int)thickness);
1676 #if VISP_HAVE_OPENCV_VERSION >= 0x030000
1677 int filled = cv::FILLED;
1679 int filled = CV_FILLED;
1682 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1683 cvRectangle( m_background,
1688 col[color.
id], filled);
1690 cv::rectangle( m_background,
1695 col[color.
id], filled);
1699 cvcolor = CV_RGB(color.
R, color.
G, color.
B) ;
1700 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1701 cvRectangle( m_background,
1708 cv::rectangle( m_background,
1721 "OpenCV not initialized")) ;
1739 const vpColor &color,
bool fill,
1740 unsigned int thickness)
1744 if (fill ==
false) {
1746 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1747 cvRectangle( m_background,
1752 col[color.
id], (int)thickness);
1754 cv::rectangle( m_background,
1759 col[color.
id], (int)thickness);
1763 cvcolor = CV_RGB(color.
R, color.
G, color.
B) ;
1764 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1765 cvRectangle( m_background,
1770 cvcolor, (int)thickness);
1773 cv::rectangle( m_background,
1778 cvcolor, (int)thickness);
1784 #if VISP_HAVE_OPENCV_VERSION >= 0x030000
1785 int filled = cv::FILLED;
1787 int filled = CV_FILLED;
1790 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1791 cvRectangle( m_background,
1796 col[color.
id], filled);
1798 cv::rectangle( m_background,
1803 col[color.
id], filled);
1807 cvcolor = CV_RGB(color.
R, color.
G, color.
B) ;
1808 #if VISP_HAVE_OPENCV_VERSION < 0x020408
1809 cvRectangle( m_background,
1816 cv::rectangle( m_background,
1829 "OpenCV not initialized")) ;
1857 lbuttondown =
false;
1858 mbuttondown =
false;
1859 rbuttondown =
false;
1864 lbuttondown =
false;
1868 mbuttondown =
false;
1872 rbuttondown =
false;
1875 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
1880 }
while ( ret ==
false && blocking ==
true);
1884 "OpenCV not initialized")) ;
1917 lbuttondown =
false;
1918 mbuttondown =
false;
1919 rbuttondown =
false;
1924 u = (
unsigned int)x_lbuttondown *
m_scale;
1925 v = (
unsigned int)y_lbuttondown *
m_scale;
1928 lbuttondown =
false;
1932 u = (
unsigned int)x_mbuttondown *
m_scale;
1933 v = (
unsigned int)y_mbuttondown *
m_scale;
1936 mbuttondown =
false;
1940 u = (
unsigned int)x_rbuttondown *
m_scale;
1941 v = (
unsigned int)y_rbuttondown *
m_scale;
1944 rbuttondown =
false;
1947 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
1952 }
while ( ret ==
false && blocking ==
true);
1956 "OpenCV not initialized")) ;
1992 lbuttondown =
false;
1993 mbuttondown =
false;
1994 rbuttondown =
false;
1999 u = (
unsigned int)x_lbuttondown *
m_scale;
2000 v = (
unsigned int)y_lbuttondown *
m_scale;
2004 lbuttondown =
false;
2008 u = (
unsigned int)x_mbuttondown *
m_scale;
2009 v = (
unsigned int)y_mbuttondown *
m_scale;
2013 mbuttondown =
false;
2017 u = (
unsigned int)x_rbuttondown *
m_scale;
2018 v = (
unsigned int)y_rbuttondown *
m_scale;
2022 rbuttondown =
false;
2025 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
2030 }
while ( ret ==
false && blocking ==
true);
2034 "OpenCV not initialized")) ;
2079 u = (
unsigned int)x_lbuttonup *
m_scale;
2080 v = (
unsigned int)y_lbuttonup *
m_scale;
2088 u = (
unsigned int)x_mbuttonup *
m_scale;
2089 v = (
unsigned int)y_mbuttonup *
m_scale;
2097 u = (
unsigned int)x_rbuttonup *
m_scale;
2098 v = (
unsigned int)y_rbuttonup *
m_scale;
2105 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
2110 }
while ( ret ==
false && blocking ==
true);
2114 "OpenCV not initialized" ) ) ;
2134 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
2135 case CV_EVENT_MOUSEMOVE:
2137 case cv::EVENT_MOUSEMOVE:
2145 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
2146 case CV_EVENT_LBUTTONDOWN:
2148 case cv::EVENT_LBUTTONDOWN:
2151 disp->lbuttondown =
true;
2152 disp->x_lbuttondown = x;
2153 disp->y_lbuttondown = y;
2156 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
2157 case CV_EVENT_MBUTTONDOWN:
2159 case cv::EVENT_MBUTTONDOWN:
2162 disp->mbuttondown =
true;
2163 disp->x_mbuttondown = x;
2164 disp->y_mbuttondown = y;
2167 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
2168 case CV_EVENT_RBUTTONDOWN:
2170 case cv::EVENT_RBUTTONDOWN:
2173 disp->rbuttondown =
true;
2174 disp->x_rbuttondown = x;
2175 disp->y_rbuttondown = y;
2178 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
2179 case CV_EVENT_LBUTTONUP:
2181 case cv::EVENT_LBUTTONUP:
2184 disp->lbuttonup =
true;
2185 disp->x_lbuttonup = x;
2186 disp->y_lbuttonup = y;
2189 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
2190 case CV_EVENT_MBUTTONUP:
2192 case cv::EVENT_MBUTTONUP:
2195 disp->mbuttonup =
true;
2196 disp->x_mbuttonup = x;
2197 disp->y_mbuttonup = y;
2200 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
2201 case CV_EVENT_RBUTTONUP:
2203 case cv::EVENT_RBUTTONUP:
2206 disp->rbuttonup =
true;
2207 disp->x_rbuttonup = x;
2208 disp->y_rbuttonup = y;
2244 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
2245 int key_pressed = cvWaitKey(delay);
2247 int key_pressed = cv::waitKey(delay);
2250 if (key_pressed == -1)
2256 "OpenCV not initialized")) ;
2290 #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
2291 int key_pressed = cvWaitKey(delay);
2293 int key_pressed = cv::waitKey(delay);
2295 if (key_pressed == -1)
2299 std::stringstream ss;
2307 "OpenCV not initialized")) ;
2331 double u = (
unsigned int)x_move /
m_scale;
2332 double v = (
unsigned int)y_move /
m_scale;
2341 "OpenCV not initialized")) ;
2364 u = (
unsigned int)x_move /
m_scale;
2365 v = (
unsigned int)y_move /
m_scale;
2373 "OpenCV not initialized")) ;
2385 #if defined(VISP_HAVE_X11)
2388 #elif defined(VISP_HAVE_XRANDR)
2389 std::string command=
"xrandr | grep '*'";
2390 FILE *fpipe = (FILE*)popen(command.c_str(),
"r");
2392 while ( fgets( line,
sizeof(line), fpipe))
2394 std::string str(line);
2395 std::size_t found = str.find(
"Failed");
2397 if (found == std::string::npos) {
2398 std::vector<std::string> elm;
2400 for(
size_t i=0; i<elm.size(); i++) {
2401 if (! elm[i].empty()) {
2403 if (resolution.size() == 2) {
2404 std::istringstream sswidth(resolution[0]), ssheight(resolution[1]);
2414 #elif defined(_WIN32)
2415 # if !defined(WINRT)
2416 w = GetSystemMetrics(SM_CXSCREEN);
2417 h = GetSystemMetrics(SM_CYSCREEN);
2429 unsigned int width, height;
2439 unsigned int width, height;
2444 #elif !defined(VISP_BUILD_SHARED_LIBS)
2446 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)
unsigned int getWidth() const
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)
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="")
bool getPointerPosition(vpImagePoint &ip)
static const vpColor darkBlue
unsigned char G
Green component.
bool m_displayHasBeenInitialized
display has been initialized
static const vpColor green
static int round(const double x)
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)
void set_i(const double ii)
int m_windowXPosition
display position
static const vpColor cyan
static const vpColor lightGreen
void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height)
void setScale(vpScaleType scaleType, unsigned int width, unsigned int height)
void set_u(const double u)
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 set_v(const double v)
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)
void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, const unsigned int width, const unsigned int height)
bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)
static const vpColor gray
static const vpColor darkGray
void set_j(const double jj)
bool getPointerMotionEvent(vpImagePoint &ip)
Error that can be emited by the vpDisplay class and its derivates.
void getImage(vpImage< vpRGBa > &I)
get the window pixmap and put it in vpRGBa image
vpScaleType
Values that could be applied to a display to down scale the size of the display.
unsigned int getScreenWidth()
unsigned char R
Red component.
unsigned int getHeight() const
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
bool getKeyboardEvent(bool blocking=true)
static double distance(const vpImagePoint &iP1, const vpImagePoint &iP2)
void setWindowPosition(int winx, int winy)
static const vpColor blue