2011-12-02 18:34:08 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2011, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
|
|
|
|
|
*/
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
#include "AddObjectDialog.h"
|
|
|
|
|
#include "ui_addObjectDialog.h"
|
2011-11-15 16:37:40 +00:00
|
|
|
#include "ObjWidget.h"
|
2011-10-25 15:48:19 +00:00
|
|
|
#include "KeypointItem.h"
|
|
|
|
|
#include "Camera.h"
|
2012-05-07 22:36:59 +00:00
|
|
|
#include "QtOpenCV.h"
|
2011-11-23 16:44:14 +00:00
|
|
|
#include "Settings.h"
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
#include <QtGui/QGraphicsScene>
|
|
|
|
|
#include <QtGui/QGraphicsPixmapItem>
|
|
|
|
|
#include <QtGui/QMessageBox>
|
|
|
|
|
|
2012-05-07 22:36:59 +00:00
|
|
|
#include <opencv2/imgproc/imgproc.hpp>
|
|
|
|
|
#include <opencv2/highgui/highgui.hpp>
|
2011-10-25 15:48:19 +00:00
|
|
|
|
2012-05-07 22:36:59 +00:00
|
|
|
AddObjectDialog::AddObjectDialog(Camera * camera, const cv::Mat & image, bool mirrorView, QWidget * parent, Qt::WindowFlags f) :
|
2011-10-25 15:48:19 +00:00
|
|
|
QDialog(parent, f),
|
2011-11-23 16:44:14 +00:00
|
|
|
camera_(camera),
|
2012-05-07 22:36:59 +00:00
|
|
|
object_(0)
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
|
|
|
|
ui_ = new Ui_addObjectDialog();
|
|
|
|
|
ui_->setupUi(this);
|
|
|
|
|
|
2014-06-19 21:52:04 +00:00
|
|
|
detector_ = Settings::createKeypointDetector();
|
|
|
|
|
extractor_ = Settings::createDescriptorExtractor();
|
2014-06-19 17:43:34 +00:00
|
|
|
Q_ASSERT(detector_ != 0 && extractor_ != 0);
|
|
|
|
|
|
2011-10-25 15:48:19 +00:00
|
|
|
connect(ui_->pushButton_cancel, SIGNAL(clicked()), this, SLOT(cancel()));
|
|
|
|
|
connect(ui_->pushButton_back, SIGNAL(clicked()), this, SLOT(back()));
|
|
|
|
|
connect(ui_->pushButton_next, SIGNAL(clicked()), this, SLOT(next()));
|
|
|
|
|
connect(ui_->pushButton_takePicture, SIGNAL(clicked()), this, SLOT(takePicture()));
|
2012-01-28 01:00:23 +00:00
|
|
|
connect(ui_->comboBox_selection, SIGNAL(currentIndexChanged(int)), this, SLOT(changeSelectionMode()));
|
2011-10-25 15:48:19 +00:00
|
|
|
|
2011-11-09 15:07:19 +00:00
|
|
|
connect(ui_->cameraView, SIGNAL(selectionChanged()), this, SLOT(updateNextButton()));
|
2012-01-28 01:00:23 +00:00
|
|
|
connect(ui_->cameraView, SIGNAL(roiChanged(const QRect &)), this, SLOT(updateNextButton(const QRect &)));
|
|
|
|
|
ui_->cameraView->setMirrorView(mirrorView);
|
2011-10-25 15:48:19 +00:00
|
|
|
|
2012-05-07 22:36:59 +00:00
|
|
|
if((camera_ && camera_->isRunning()) || image.empty())
|
2012-02-04 22:15:32 +00:00
|
|
|
{
|
|
|
|
|
this->setState(kTakePicture);
|
|
|
|
|
}
|
2012-05-07 22:36:59 +00:00
|
|
|
else if(!image.empty())
|
2012-02-04 22:15:32 +00:00
|
|
|
{
|
2012-05-07 22:36:59 +00:00
|
|
|
update(image);
|
2012-02-04 22:15:32 +00:00
|
|
|
this->setState(kSelectFeatures);
|
|
|
|
|
}
|
2011-10-25 15:48:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AddObjectDialog::~AddObjectDialog()
|
|
|
|
|
{
|
2014-06-19 17:43:34 +00:00
|
|
|
delete detector_;
|
|
|
|
|
delete extractor_;
|
2012-02-04 22:15:32 +00:00
|
|
|
if(object_)
|
|
|
|
|
{
|
|
|
|
|
delete object_;
|
|
|
|
|
}
|
2011-10-25 15:48:19 +00:00
|
|
|
delete ui_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AddObjectDialog::closeEvent(QCloseEvent* event)
|
|
|
|
|
{
|
2012-02-04 22:15:32 +00:00
|
|
|
if(camera_)
|
|
|
|
|
{
|
|
|
|
|
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
|
|
|
|
}
|
2011-10-25 15:48:19 +00:00
|
|
|
QDialog::closeEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AddObjectDialog::next()
|
|
|
|
|
{
|
|
|
|
|
setState(state_+1);
|
|
|
|
|
}
|
|
|
|
|
void AddObjectDialog::back()
|
|
|
|
|
{
|
|
|
|
|
setState(state_-1);
|
|
|
|
|
}
|
|
|
|
|
void AddObjectDialog::cancel()
|
|
|
|
|
{
|
|
|
|
|
this->reject();
|
|
|
|
|
}
|
|
|
|
|
void AddObjectDialog::takePicture()
|
|
|
|
|
{
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AddObjectDialog::updateNextButton()
|
|
|
|
|
{
|
2012-01-28 01:00:23 +00:00
|
|
|
updateNextButton(QRect());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AddObjectDialog::updateNextButton(const QRect & rect)
|
|
|
|
|
{
|
|
|
|
|
roi_ = rect;
|
2012-08-28 13:44:57 +00:00
|
|
|
if(roi_.isValid() && ui_->cameraView->cvImage().cols)
|
|
|
|
|
{
|
|
|
|
|
//clip roi
|
|
|
|
|
if( roi_.x() >= ui_->cameraView->cvImage().cols ||
|
|
|
|
|
roi_.x()+roi_.width() <= 0 ||
|
|
|
|
|
roi_.y() >= ui_->cameraView->cvImage().rows ||
|
|
|
|
|
roi_.y()+roi_.height() <= 0)
|
|
|
|
|
{
|
|
|
|
|
//Not valid...
|
|
|
|
|
roi_ = QRect();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(roi_.x() < 0)
|
|
|
|
|
{
|
|
|
|
|
roi_.setX(0);
|
|
|
|
|
}
|
|
|
|
|
if(roi_.x() + roi_.width() > ui_->cameraView->cvImage().cols)
|
|
|
|
|
{
|
|
|
|
|
roi_.setWidth(ui_->cameraView->cvImage().cols - roi_.x());
|
|
|
|
|
}
|
|
|
|
|
if(roi_.y() < 0)
|
|
|
|
|
{
|
|
|
|
|
roi_.setY(0);
|
|
|
|
|
}
|
|
|
|
|
if(roi_.y() + roi_.height() > ui_->cameraView->cvImage().rows)
|
|
|
|
|
{
|
|
|
|
|
roi_.setHeight(ui_->cameraView->cvImage().rows - roi_.y());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-10-25 15:48:19 +00:00
|
|
|
if(state_ == kSelectFeatures)
|
|
|
|
|
{
|
2012-01-28 01:00:23 +00:00
|
|
|
if(ui_->comboBox_selection->currentIndex() == 1)
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
2012-01-28 01:00:23 +00:00
|
|
|
if(ui_->cameraView->selectedItems().size() > 0)
|
|
|
|
|
{
|
|
|
|
|
ui_->pushButton_next->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui_->pushButton_next->setEnabled(false);
|
|
|
|
|
}
|
2011-10-25 15:48:19 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-01-28 01:00:23 +00:00
|
|
|
if(roi_.isNull())
|
|
|
|
|
{
|
|
|
|
|
ui_->pushButton_next->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui_->pushButton_next->setEnabled(true);
|
|
|
|
|
}
|
2011-10-25 15:48:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-28 01:00:23 +00:00
|
|
|
void AddObjectDialog::changeSelectionMode()
|
|
|
|
|
{
|
|
|
|
|
this->setState(kSelectFeatures);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-25 15:48:19 +00:00
|
|
|
void AddObjectDialog::setState(int state)
|
|
|
|
|
{
|
|
|
|
|
state_ = state;
|
|
|
|
|
if(state == kTakePicture)
|
|
|
|
|
{
|
|
|
|
|
ui_->pushButton_cancel->setEnabled(true);
|
|
|
|
|
ui_->pushButton_back->setEnabled(false);
|
|
|
|
|
ui_->pushButton_next->setEnabled(false);
|
|
|
|
|
ui_->pushButton_takePicture->setEnabled(true);
|
|
|
|
|
ui_->label_instruction->setText(tr("Place the object in front of the camera and click \"Take picture\"."));
|
|
|
|
|
ui_->pushButton_next->setText(tr("Next"));
|
|
|
|
|
ui_->cameraView->setVisible(true);
|
2012-01-28 01:00:23 +00:00
|
|
|
ui_->cameraView->clearRoiSelection();
|
2011-10-25 15:48:19 +00:00
|
|
|
ui_->objectView->setVisible(false);
|
|
|
|
|
ui_->cameraView->setGraphicsViewMode(false);
|
2012-01-28 01:00:23 +00:00
|
|
|
ui_->comboBox_selection->setVisible(false);
|
2011-11-23 16:44:14 +00:00
|
|
|
if(!camera_ || !camera_->start())
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
2011-11-23 16:44:14 +00:00
|
|
|
QMessageBox::critical(this, tr("Camera error"), tr("Camera is not started!"));
|
2011-10-25 15:48:19 +00:00
|
|
|
ui_->pushButton_takePicture->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-11-23 16:44:14 +00:00
|
|
|
connect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
2011-10-25 15:48:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(state == kSelectFeatures)
|
|
|
|
|
{
|
2012-02-04 22:15:32 +00:00
|
|
|
if(camera_)
|
|
|
|
|
{
|
|
|
|
|
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
|
|
|
|
camera_->pause();
|
|
|
|
|
}
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
ui_->pushButton_cancel->setEnabled(true);
|
2012-02-04 22:15:32 +00:00
|
|
|
ui_->pushButton_back->setEnabled(camera_);
|
2011-10-25 15:48:19 +00:00
|
|
|
ui_->pushButton_next->setEnabled(false);
|
|
|
|
|
ui_->pushButton_takePicture->setEnabled(false);
|
|
|
|
|
ui_->pushButton_next->setText(tr("Next"));
|
|
|
|
|
ui_->cameraView->setVisible(true);
|
2012-01-28 01:00:23 +00:00
|
|
|
ui_->cameraView->clearRoiSelection();
|
2011-10-25 15:48:19 +00:00
|
|
|
ui_->objectView->setVisible(false);
|
2012-01-28 01:00:23 +00:00
|
|
|
ui_->comboBox_selection->setVisible(true);
|
|
|
|
|
|
|
|
|
|
if(ui_->comboBox_selection->currentIndex() == 1)
|
|
|
|
|
{
|
|
|
|
|
ui_->label_instruction->setText(tr("Select features representing the object."));
|
|
|
|
|
ui_->cameraView->setGraphicsViewMode(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui_->label_instruction->setText(tr("Select region representing the object."));
|
|
|
|
|
ui_->cameraView->setGraphicsViewMode(false);
|
|
|
|
|
}
|
|
|
|
|
updateNextButton(QRect());
|
2011-10-25 15:48:19 +00:00
|
|
|
}
|
|
|
|
|
else if(state == kVerifySelection)
|
|
|
|
|
{
|
2012-02-04 22:15:32 +00:00
|
|
|
if(camera_)
|
|
|
|
|
{
|
|
|
|
|
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
|
|
|
|
camera_->pause();
|
|
|
|
|
}
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
ui_->pushButton_cancel->setEnabled(true);
|
|
|
|
|
ui_->pushButton_back->setEnabled(true);
|
|
|
|
|
ui_->pushButton_takePicture->setEnabled(false);
|
|
|
|
|
ui_->pushButton_next->setText(tr("End"));
|
|
|
|
|
ui_->cameraView->setVisible(true);
|
|
|
|
|
ui_->objectView->setVisible(true);
|
2012-01-28 01:00:23 +00:00
|
|
|
ui_->objectView->setMirrorView(ui_->cameraView->isMirrorView());
|
|
|
|
|
ui_->objectView->setSizedFeatures(ui_->cameraView->isSizedFeatures());
|
|
|
|
|
ui_->comboBox_selection->setVisible(false);
|
|
|
|
|
if(ui_->comboBox_selection->currentIndex() == 1)
|
|
|
|
|
{
|
|
|
|
|
ui_->cameraView->setGraphicsViewMode(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui_->cameraView->setGraphicsViewMode(false);
|
|
|
|
|
}
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
std::vector<cv::KeyPoint> selectedKeypoints = ui_->cameraView->selectedKeypoints();
|
|
|
|
|
|
|
|
|
|
// Select keypoints
|
2012-05-07 22:36:59 +00:00
|
|
|
if(!cvImage_.empty() &&
|
2012-01-28 01:00:23 +00:00
|
|
|
((ui_->comboBox_selection->currentIndex() == 1 && selectedKeypoints.size()) ||
|
|
|
|
|
(ui_->comboBox_selection->currentIndex() == 0 && !roi_.isNull())))
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
2012-05-07 22:36:59 +00:00
|
|
|
cv::Rect roi;
|
2012-01-28 01:00:23 +00:00
|
|
|
if(ui_->comboBox_selection->currentIndex() == 1)
|
|
|
|
|
{
|
|
|
|
|
roi = computeROI(selectedKeypoints);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
roi.x = roi_.x();
|
|
|
|
|
roi.y = roi_.y();
|
|
|
|
|
roi.width = roi_.width();
|
|
|
|
|
roi.height = roi_.height();
|
|
|
|
|
}
|
2012-05-07 22:36:59 +00:00
|
|
|
cv::Mat imgRoi(cvImage_, roi);
|
2012-01-28 01:00:23 +00:00
|
|
|
|
|
|
|
|
if(ui_->comboBox_selection->currentIndex() == 1)
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
2012-01-28 01:00:23 +00:00
|
|
|
if(roi.x != 0 || roi.y != 0)
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
2012-01-28 01:00:23 +00:00
|
|
|
for(unsigned int i=0; i<selectedKeypoints.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
selectedKeypoints.at(i).pt.x -= roi.x;
|
|
|
|
|
selectedKeypoints.at(i).pt.y -= roi.y;
|
|
|
|
|
}
|
2011-10-25 15:48:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-01-28 01:00:23 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Extract keypoints
|
|
|
|
|
selectedKeypoints.clear();
|
2014-06-19 17:43:34 +00:00
|
|
|
detector_->detect(imgRoi, selectedKeypoints);
|
2012-01-28 01:00:23 +00:00
|
|
|
}
|
2012-05-07 22:36:59 +00:00
|
|
|
ui_->objectView->setData(selectedKeypoints, cv::Mat(), imgRoi, Settings::currentDetectorType(), "");
|
2011-11-17 20:31:08 +00:00
|
|
|
ui_->objectView->setMinimumSize(roi.width, roi.height);
|
|
|
|
|
ui_->objectView->update();
|
2011-10-25 15:48:19 +00:00
|
|
|
ui_->pushButton_next->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("Please select items\n");
|
|
|
|
|
ui_->pushButton_next->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
ui_->label_instruction->setText(tr("Selection : %1 features").arg(selectedKeypoints.size()));
|
|
|
|
|
}
|
|
|
|
|
else if(state == kClosing)
|
|
|
|
|
{
|
2012-01-28 01:00:23 +00:00
|
|
|
std::vector<cv::KeyPoint> keypoints = ui_->objectView->keypoints();
|
|
|
|
|
if((ui_->comboBox_selection->currentIndex() == 1 && keypoints.size()) ||
|
|
|
|
|
(ui_->comboBox_selection->currentIndex() == 0 && !roi_.isNull()))
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
|
|
|
|
cv::Mat descriptors;
|
2012-01-28 01:00:23 +00:00
|
|
|
if(keypoints.size())
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
2012-01-28 01:00:23 +00:00
|
|
|
// Extract descriptors
|
2014-06-19 17:43:34 +00:00
|
|
|
extractor_->compute(ui_->objectView->cvImage(), keypoints, descriptors);
|
2011-10-25 15:48:19 +00:00
|
|
|
|
2012-01-28 01:00:23 +00:00
|
|
|
if(keypoints.size() != (unsigned int)descriptors.rows)
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
2012-01-28 01:00:23 +00:00
|
|
|
printf("ERROR : keypoints=%d != descriptors=%d\n", (int)keypoints.size(), descriptors.rows);
|
2011-10-25 15:48:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-04 22:15:32 +00:00
|
|
|
if(object_)
|
|
|
|
|
{
|
|
|
|
|
delete object_;
|
|
|
|
|
object_ = 0;
|
|
|
|
|
}
|
2012-05-07 22:36:59 +00:00
|
|
|
object_ = new ObjWidget(0, keypoints, descriptors, ui_->objectView->cvImage(), Settings::currentDetectorType(), Settings::currentDescriptorType());
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
this->accept();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-23 16:44:14 +00:00
|
|
|
void AddObjectDialog::update(const cv::Mat & image)
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
2012-05-07 22:36:59 +00:00
|
|
|
cvImage_ = cv::Mat();
|
|
|
|
|
if(!image.empty())
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
|
|
|
|
// convert to grayscale
|
2012-05-07 22:36:59 +00:00
|
|
|
if(image.channels() != 1 || image.depth() != CV_8U)
|
|
|
|
|
{
|
|
|
|
|
cv::cvtColor(image, cvImage_, CV_BGR2GRAY);
|
|
|
|
|
}
|
|
|
|
|
else
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
2012-05-07 22:36:59 +00:00
|
|
|
cvImage_ = image;
|
2011-10-25 15:48:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Extract keypoints
|
|
|
|
|
cv::vector<cv::KeyPoint> keypoints;
|
2014-06-19 17:43:34 +00:00
|
|
|
detector_->detect(cvImage_, keypoints);
|
2011-10-25 15:48:19 +00:00
|
|
|
|
2012-01-28 01:00:23 +00:00
|
|
|
ui_->cameraView->setData(keypoints, cv::Mat(), cvImage_, Settings::currentDetectorType(), "");
|
2011-10-25 15:48:19 +00:00
|
|
|
ui_->cameraView->update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-07 22:36:59 +00:00
|
|
|
cv::Rect AddObjectDialog::computeROI(const std::vector<cv::KeyPoint> & kpts)
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
2012-05-07 22:36:59 +00:00
|
|
|
cv::Rect roi(0,0,0,0);
|
2011-11-23 18:08:33 +00:00
|
|
|
int x1=0,x2=0,h1=0,h2=0;
|
2011-10-25 15:48:19 +00:00
|
|
|
for(unsigned int i=0; i<kpts.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
float radius = kpts.at(i).size / 2;
|
|
|
|
|
if(i==0)
|
|
|
|
|
{
|
|
|
|
|
x1 = int(kpts.at(i).pt.x - radius);
|
|
|
|
|
x2 = int(kpts.at(i).pt.x + radius);
|
|
|
|
|
h1 = int(kpts.at(i).pt.y - radius);
|
|
|
|
|
h2 = int(kpts.at(i).pt.y + radius);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(x1 > int(kpts.at(i).pt.x - radius))
|
|
|
|
|
{
|
|
|
|
|
x1 = int(kpts.at(i).pt.x - radius);
|
|
|
|
|
}
|
|
|
|
|
else if(x2 < int(kpts.at(i).pt.x + radius))
|
|
|
|
|
{
|
|
|
|
|
x2 = int(kpts.at(i).pt.x + radius);
|
|
|
|
|
}
|
|
|
|
|
if(h1 > int(kpts.at(i).pt.y - radius))
|
|
|
|
|
{
|
|
|
|
|
h1 = int(kpts.at(i).pt.y - radius);
|
|
|
|
|
}
|
|
|
|
|
else if(h2 < int(kpts.at(i).pt.y + radius))
|
|
|
|
|
{
|
|
|
|
|
h2 = int(kpts.at(i).pt.y + radius);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
roi.x = x1;
|
|
|
|
|
roi.y = h1;
|
|
|
|
|
roi.width = x2-x1;
|
|
|
|
|
roi.height = h2-h1;
|
2011-11-17 20:31:08 +00:00
|
|
|
//printf("ptx=%d, pty=%d\n", (int)kpts.at(i).pt.x, (int)kpts.at(i).pt.y);
|
|
|
|
|
//printf("x=%d, y=%d, w=%d, h=%d\n", roi.x, roi.y, roi.width, roi.height);
|
2011-10-25 15:48:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return roi;
|
|
|
|
|
}
|