From 3746c48451b890bc67d0c8bd047b308d28b6277e Mon Sep 17 00:00:00 2001 From: Yannick Verdie Date: Wed, 18 Aug 2010 15:35:56 +0000 Subject: [PATCH] Bug in calibration.cpp sample This was crashing my code: for( size_t i = 1; i < imagePoints.size(); i++ ) objectPoints.push_back(objectPoints[0]); Changed by: objectPoints.resize(imagePoints.size(),objectPoints[0]); Plus clean up on Qt code --- modules/highgui/src/window_QT.cpp | 124 +++++++++----------------------------- samples/cpp/calibration.cpp | 4 +- 2 files changed, 32 insertions(+), 96 deletions(-) diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index 3229c79..0bf9e80 100755 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -1583,148 +1583,84 @@ void CvWindow::displayPropertiesWin() global_control_panel->hide(); } -/* -void CvWindow::createActionsandShortcuts() +void CvWindow::createActions() { vect_QActions.resize(10); //if the shortcuts are changed in window_QT.h, we need to update the tooltip manually vect_QActions[0] = new QAction(QIcon(":/left-icon"),"Panning left (CTRL+arrowLEFT)",this); vect_QActions[0]->setIconVisibleInMenu(true); - vect_QActions[0]->setShortcut(shortcut_panning_left); QObject::connect( vect_QActions[0],SIGNAL(triggered()),myview, SLOT( siftWindowOnLeft() )); vect_QActions[1] = new QAction(QIcon(":/right-icon"),"Panning right (CTRL+arrowRIGHT)",this); vect_QActions[1]->setIconVisibleInMenu(true); - vect_QActions[1]->setShortcut(shortcut_panning_right); QObject::connect( vect_QActions[1],SIGNAL(triggered()),myview, SLOT( siftWindowOnRight() )); vect_QActions[2] = new QAction(QIcon(":/up-icon"),"Panning up (CTRL+arrowUP)",this); vect_QActions[2]->setIconVisibleInMenu(true); - vect_QActions[2]->setShortcut(shortcut_panning_up); QObject::connect( vect_QActions[2],SIGNAL(triggered()),myview, SLOT( siftWindowOnUp() )); vect_QActions[3] = new QAction(QIcon(":/down-icon"),"Panning down (CTRL+arrowDOWN)",this); vect_QActions[3]->setIconVisibleInMenu(true); - vect_QActions[3]->setShortcut(shortcut_panning_down); QObject::connect( vect_QActions[3],SIGNAL(triggered()),myview, SLOT( siftWindowOnDown() )); - vect_QActions[4] = new QAction(QIcon(":/zoom_x1-icon"),"Zoom x1 (CTRL+Z)",this); + vect_QActions[4] = new QAction(QIcon(":/zoom_x1-icon"),"Zoom x1 (CTRL+P)",this); vect_QActions[4]->setIconVisibleInMenu(true); - vect_QActions[4]->setShortcut(shortcut_zoom_normal); QObject::connect( vect_QActions[4],SIGNAL(triggered()),myview, SLOT( resetZoom() )); vect_QActions[5] = new QAction(QIcon(":/imgRegion-icon"),tr("Zoom x%1 (see label) (CTRL+X)") .arg(threshold_zoom_img_region) ,this); vect_QActions[5]->setIconVisibleInMenu(true); - vect_QActions[5]->setShortcut(shortcut_zoom_imgRegion); QObject::connect( vect_QActions[5],SIGNAL(triggered()),myview, SLOT( imgRegion() )); vect_QActions[6] = new QAction(QIcon(":/zoom_in-icon"),tr("Zoom in (CTRL++)"),this); vect_QActions[6]->setIconVisibleInMenu(true); - vect_QActions[6]->setShortcut(shortcut_zoom_in); QObject::connect( vect_QActions[6],SIGNAL(triggered()),myview, SLOT( ZoomIn() )); vect_QActions[7] = new QAction(QIcon(":/zoom_out-icon"),tr("Zoom out (CTRL+-)"),this); vect_QActions[7]->setIconVisibleInMenu(true); - vect_QActions[7]->setShortcut(shortcut_zoom_out); QObject::connect( vect_QActions[7],SIGNAL(triggered()),myview, SLOT( ZoomOut() )); vect_QActions[8] = new QAction(QIcon(":/save-icon"),tr("Save current image (CTRL+S)"),this); vect_QActions[8]->setIconVisibleInMenu(true); - vect_QActions[8]->setShortcut(shortcut_save_img); QObject::connect( vect_QActions[8],SIGNAL(triggered()),myview, SLOT( saveView() )); vect_QActions[9] = new QAction(QIcon(":/properties-icon"),tr("Display properties window (CTRL+P)"),this); vect_QActions[9]->setIconVisibleInMenu(true); - vect_QActions[9]->setShortcut(shortcut_properties_win); + QObject::connect( vect_QActions[9],SIGNAL(triggered()),this, SLOT( displayPropertiesWin() )); if (global_control_panel->myLayout->count() == 0) vect_QActions[9]->setDisabled(true); - QObject::connect( vect_QActions[9],SIGNAL(triggered()),this, SLOT( displayPropertiesWin() )); +} -}*/ - -void CvWindow::createActions() -{ - vect_QActions.resize(10); - - //if the shortcuts are changed in window_QT.h, we need to update the tooltip manually - vect_QActions[0] = new QAction(QIcon(":/left-icon"),"Panning left (CTRL+arrowLEFT)",this); - vect_QActions[0]->setIconVisibleInMenu(true); - QObject::connect( vect_QActions[0],SIGNAL(triggered()),myview, SLOT( siftWindowOnLeft() )); - - vect_QActions[1] = new QAction(QIcon(":/right-icon"),"Panning right (CTRL+arrowRIGHT)",this); - vect_QActions[1]->setIconVisibleInMenu(true); - QObject::connect( vect_QActions[1],SIGNAL(triggered()),myview, SLOT( siftWindowOnRight() )); - - vect_QActions[2] = new QAction(QIcon(":/up-icon"),"Panning up (CTRL+arrowUP)",this); - vect_QActions[2]->setIconVisibleInMenu(true); - QObject::connect( vect_QActions[2],SIGNAL(triggered()),myview, SLOT( siftWindowOnUp() )); - - vect_QActions[3] = new QAction(QIcon(":/down-icon"),"Panning down (CTRL+arrowDOWN)",this); - vect_QActions[3]->setIconVisibleInMenu(true); - QObject::connect( vect_QActions[3],SIGNAL(triggered()),myview, SLOT( siftWindowOnDown() )); - - vect_QActions[4] = new QAction(QIcon(":/zoom_x1-icon"),"Zoom x1 (CTRL+P)",this); - vect_QActions[4]->setIconVisibleInMenu(true); - QObject::connect( vect_QActions[4],SIGNAL(triggered()),myview, SLOT( resetZoom() )); - - vect_QActions[5] = new QAction(QIcon(":/imgRegion-icon"),tr("Zoom x%1 (see label) (CTRL+X)") - .arg(threshold_zoom_img_region) - ,this); - vect_QActions[5]->setIconVisibleInMenu(true); - QObject::connect( vect_QActions[5],SIGNAL(triggered()),myview, SLOT( imgRegion() )); - - vect_QActions[6] = new QAction(QIcon(":/zoom_in-icon"),tr("Zoom in (CTRL++)"),this); - vect_QActions[6]->setIconVisibleInMenu(true); - QObject::connect( vect_QActions[6],SIGNAL(triggered()),myview, SLOT( ZoomIn() )); - - vect_QActions[7] = new QAction(QIcon(":/zoom_out-icon"),tr("Zoom out (CTRL+-)"),this); - vect_QActions[7]->setIconVisibleInMenu(true); - QObject::connect( vect_QActions[7],SIGNAL(triggered()),myview, SLOT( ZoomOut() )); - - vect_QActions[8] = new QAction(QIcon(":/save-icon"),tr("Save current image (CTRL+S)"),this); - vect_QActions[8]->setIconVisibleInMenu(true); - QObject::connect( vect_QActions[8],SIGNAL(triggered()),myview, SLOT( saveView() )); - - vect_QActions[9] = new QAction(QIcon(":/properties-icon"),tr("Display properties window (CTRL+P)"),this); - vect_QActions[9]->setIconVisibleInMenu(true); - QObject::connect( vect_QActions[9],SIGNAL(triggered()),this, SLOT( displayPropertiesWin() )); - - if (global_control_panel->myLayout->count() == 0) - vect_QActions[9]->setDisabled(true); - -} - - -void CvWindow::createShortcuts() -{ - vect_QShortcuts.resize(10); - - vect_QShortcuts[0] = new QShortcut(shortcut_panning_left, this); - QObject::connect( vect_QShortcuts[0], SIGNAL( activated ()),myview, SLOT( siftWindowOnLeft() )); - vect_QShortcuts[1] = new QShortcut(shortcut_panning_right, this); - QObject::connect( vect_QShortcuts[1], SIGNAL( activated ()),myview, SLOT( siftWindowOnRight() )); - vect_QShortcuts[2] = new QShortcut(shortcut_panning_up, this); - QObject::connect(vect_QShortcuts[2], SIGNAL( activated ()),myview, SLOT( siftWindowOnUp() )); - vect_QShortcuts[3] = new QShortcut(shortcut_panning_down, this); - QObject::connect(vect_QShortcuts[3], SIGNAL( activated ()),myview, SLOT( siftWindowOnDown() )); - - vect_QShortcuts[4] = new QShortcut(shortcut_zoom_normal, this); - QObject::connect( vect_QShortcuts[4], SIGNAL( activated ()),myview, SLOT( resetZoom( ) )); - vect_QShortcuts[5] = new QShortcut(shortcut_zoom_imgRegion, this); - QObject::connect( vect_QShortcuts[5], SIGNAL( activated ()),myview, SLOT( imgRegion( ) )); - vect_QShortcuts[6] = new QShortcut(shortcut_zoom_in, this); - QObject::connect( vect_QShortcuts[6], SIGNAL( activated ()),myview, SLOT( ZoomIn() )); - vect_QShortcuts[7] = new QShortcut(shortcut_zoom_out, this); - QObject::connect(vect_QShortcuts[7], SIGNAL( activated ()),myview, SLOT( ZoomOut() )); - vect_QShortcuts[8] = new QShortcut(shortcut_save_img, this); - QObject::connect( vect_QShortcuts[8], SIGNAL( activated ()),myview, SLOT( saveView( ) )); - vect_QShortcuts[9] = new QShortcut(shortcut_properties_win, this); - QObject::connect( vect_QShortcuts[9], SIGNAL( activated ()),this, SLOT( displayPropertiesWin() )); + +void CvWindow::createShortcuts() +{ + vect_QShortcuts.resize(10); + + vect_QShortcuts[0] = new QShortcut(shortcut_panning_left, this); + QObject::connect( vect_QShortcuts[0], SIGNAL( activated ()),myview, SLOT( siftWindowOnLeft() )); + vect_QShortcuts[1] = new QShortcut(shortcut_panning_right, this); + QObject::connect( vect_QShortcuts[1], SIGNAL( activated ()),myview, SLOT( siftWindowOnRight() )); + vect_QShortcuts[2] = new QShortcut(shortcut_panning_up, this); + QObject::connect(vect_QShortcuts[2], SIGNAL( activated ()),myview, SLOT( siftWindowOnUp() )); + vect_QShortcuts[3] = new QShortcut(shortcut_panning_down, this); + QObject::connect(vect_QShortcuts[3], SIGNAL( activated ()),myview, SLOT( siftWindowOnDown() )); + + vect_QShortcuts[4] = new QShortcut(shortcut_zoom_normal, this); + QObject::connect( vect_QShortcuts[4], SIGNAL( activated ()),myview, SLOT( resetZoom( ) )); + vect_QShortcuts[5] = new QShortcut(shortcut_zoom_imgRegion, this); + QObject::connect( vect_QShortcuts[5], SIGNAL( activated ()),myview, SLOT( imgRegion( ) )); + vect_QShortcuts[6] = new QShortcut(shortcut_zoom_in, this); + QObject::connect( vect_QShortcuts[6], SIGNAL( activated ()),myview, SLOT( ZoomIn() )); + vect_QShortcuts[7] = new QShortcut(shortcut_zoom_out, this); + QObject::connect(vect_QShortcuts[7], SIGNAL( activated ()),myview, SLOT( ZoomOut() )); + vect_QShortcuts[8] = new QShortcut(shortcut_save_img, this); + QObject::connect( vect_QShortcuts[8], SIGNAL( activated ()),myview, SLOT( saveView( ) )); + vect_QShortcuts[9] = new QShortcut(shortcut_properties_win, this); + QObject::connect( vect_QShortcuts[9], SIGNAL( activated ()),this, SLOT( displayPropertiesWin() )); } void CvWindow::createToolBar() diff --git a/samples/cpp/calibration.cpp b/samples/cpp/calibration.cpp index cff22d9..f69273d 100644 --- a/samples/cpp/calibration.cpp +++ b/samples/cpp/calibration.cpp @@ -86,8 +86,8 @@ static bool runCalibration( vector > imagePoints, vector > objectPoints(1); calcChessboardCorners(boardSize, squareSize, objectPoints[0]); - for( size_t i = 1; i < imagePoints.size(); i++ ) - objectPoints.push_back(objectPoints[0]); + + objectPoints.resize(imagePoints.size(),objectPoints[0]); calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs, flags); -- 2.7.4