Added DragNDrop images directly in objects or scene zones.
git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@415 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
parent
807c8b5b43
commit
a96ea6c4f5
@ -86,7 +86,9 @@ private Q_SLOTS:
|
|||||||
void loadObjects();
|
void loadObjects();
|
||||||
bool saveObjects();
|
bool saveObjects();
|
||||||
void addObjectFromScene();
|
void addObjectFromScene();
|
||||||
|
void addObjectsFromFiles(const QStringList & fileNames);
|
||||||
void addObjectsFromFiles();
|
void addObjectsFromFiles();
|
||||||
|
void loadSceneFromFile(const QStringList & fileNames);
|
||||||
void loadSceneFromFile();
|
void loadSceneFromFile();
|
||||||
void setupCameraFromVideoFile();
|
void setupCameraFromVideoFile();
|
||||||
void setupCameraFromImagesDirectory();
|
void setupCameraFromImagesDirectory();
|
||||||
|
|||||||
@ -12,6 +12,7 @@ SET(headers_ui
|
|||||||
./ParametersToolBox.h
|
./ParametersToolBox.h
|
||||||
./AboutDialog.h
|
./AboutDialog.h
|
||||||
./RectItem.h
|
./RectItem.h
|
||||||
|
./ImageDropWidget.h
|
||||||
./rtabmap/PdfPlot.h
|
./rtabmap/PdfPlot.h
|
||||||
./utilite/UPlot.h
|
./utilite/UPlot.h
|
||||||
)
|
)
|
||||||
@ -47,6 +48,7 @@ SET(SRC_FILES
|
|||||||
./ParametersToolBox.cpp
|
./ParametersToolBox.cpp
|
||||||
./Settings.cpp
|
./Settings.cpp
|
||||||
./ObjWidget.cpp
|
./ObjWidget.cpp
|
||||||
|
./ImageDropWidget.cpp
|
||||||
./FindObject.cpp
|
./FindObject.cpp
|
||||||
./AboutDialog.cpp
|
./AboutDialog.cpp
|
||||||
./TcpServer.cpp
|
./TcpServer.cpp
|
||||||
|
|||||||
65
src/ImageDropWidget.cpp
Normal file
65
src/ImageDropWidget.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* ImageDropWidget.cpp
|
||||||
|
*
|
||||||
|
* Created on: Dec 22, 2014
|
||||||
|
* Author: mathieu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ImageDropWidget.h>
|
||||||
|
#include <find_object/Settings.h>
|
||||||
|
#include <QtGui/QDragEnterEvent>
|
||||||
|
#include <QtCore/QRegExp>
|
||||||
|
#include <QtCore/QUrl>
|
||||||
|
|
||||||
|
namespace find_object {
|
||||||
|
|
||||||
|
ImageDropWidget::ImageDropWidget(QWidget *parent, Qt::WindowFlags flags) :
|
||||||
|
QWidget(parent, flags)
|
||||||
|
{
|
||||||
|
setAcceptDrops(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageDropWidget::~ImageDropWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageDropWidget::dragEnterEvent(QDragEnterEvent *event)
|
||||||
|
{
|
||||||
|
if (event->mimeData()->hasUrls())
|
||||||
|
{
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageDropWidget::dropEvent(QDropEvent *event)
|
||||||
|
{
|
||||||
|
QStringList fileNames;
|
||||||
|
|
||||||
|
QStringList extensions = Settings::getGeneral_imageFormats().split(" ");
|
||||||
|
|
||||||
|
QList<QUrl> urls = event->mimeData()->urls();
|
||||||
|
for(int i=0; i<urls.size(); ++i)
|
||||||
|
{
|
||||||
|
QString path = urls.at(i).toLocalFile();
|
||||||
|
for(int j=0; j<extensions.size(); ++j)
|
||||||
|
{
|
||||||
|
QRegExp reg(extensions[j]);
|
||||||
|
reg.setPatternSyntax(QRegExp::Wildcard);
|
||||||
|
if(reg.exactMatch(path))
|
||||||
|
{
|
||||||
|
fileNames.push_back(path);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fileNames.size())
|
||||||
|
{
|
||||||
|
Q_EMIT imagesReceived(fileNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
34
src/ImageDropWidget.h
Normal file
34
src/ImageDropWidget.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* ImageDropWidget.h
|
||||||
|
*
|
||||||
|
* Created on: Dec 22, 2014
|
||||||
|
* Author: mathieu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IMAGEDROPWIDGET_H_
|
||||||
|
#define IMAGEDROPWIDGET_H_
|
||||||
|
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
|
namespace find_object {
|
||||||
|
|
||||||
|
class ImageDropWidget : public QWidget {
|
||||||
|
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ImageDropWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||||
|
virtual ~ImageDropWidget();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void imagesReceived(const QStringList &);
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||||
|
virtual void dropEvent(QDropEvent *event);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* IMAGEDROPWIDGET_H_ */
|
||||||
@ -246,6 +246,10 @@ MainWindow::MainWindow(FindObject * findObject, Camera * camera, QWidget * paren
|
|||||||
// Set 1 msec to see state on the status bar.
|
// Set 1 msec to see state on the status bar.
|
||||||
QTimer::singleShot(1, this, SLOT(startProcessing()));
|
QTimer::singleShot(1, this, SLOT(startProcessing()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Setup drag and drop images
|
||||||
|
connect(ui_->imageDrop_objects, SIGNAL(imagesReceived(const QStringList &)), this, SLOT(addObjectsFromFiles(const QStringList &)));
|
||||||
|
connect(ui_->imageDrop_scene, SIGNAL(imagesReceived(const QStringList &)), this, SLOT(loadSceneFromFile(const QStringList &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -570,9 +574,8 @@ void MainWindow::addObjectFromScene()
|
|||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addObjectsFromFiles()
|
void MainWindow::addObjectsFromFiles(const QStringList & fileNames)
|
||||||
{
|
{
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Add objects..."), Settings::workingDirectory(), tr("Image Files (%1)").arg(Settings::getGeneral_imageFormats()));
|
|
||||||
if(fileNames.size())
|
if(fileNames.size())
|
||||||
{
|
{
|
||||||
for(int i=0; i<fileNames.size(); ++i)
|
for(int i=0; i<fileNames.size(); ++i)
|
||||||
@ -584,6 +587,11 @@ void MainWindow::addObjectsFromFiles()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::addObjectsFromFiles()
|
||||||
|
{
|
||||||
|
addObjectsFromFiles(QFileDialog::getOpenFileNames(this, tr("Add objects..."), Settings::workingDirectory(), tr("Image Files (%1)").arg(Settings::getGeneral_imageFormats())));
|
||||||
|
}
|
||||||
|
|
||||||
bool MainWindow::addObjectFromFile(const QString & filePath)
|
bool MainWindow::addObjectFromFile(const QString & filePath)
|
||||||
{
|
{
|
||||||
const ObjSignature * s = findObject_->addObject(filePath);
|
const ObjSignature * s = findObject_->addObject(filePath);
|
||||||
@ -602,6 +610,20 @@ bool MainWindow::addObjectFromFile(const QString & filePath)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::loadSceneFromFile(const QStringList & fileNames)
|
||||||
|
{
|
||||||
|
//take the first
|
||||||
|
if(fileNames.size())
|
||||||
|
{
|
||||||
|
cv::Mat img = cv::imread(fileNames.first().toStdString().c_str());
|
||||||
|
if(!img.empty())
|
||||||
|
{
|
||||||
|
this->update(img);
|
||||||
|
ui_->label_timeRefreshRate->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::loadSceneFromFile()
|
void MainWindow::loadSceneFromFile()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Load scene..."), Settings::workingDirectory(), tr("Image Files (%1)").arg(Settings::getGeneral_imageFormats()));
|
QString fileName = QFileDialog::getOpenFileName(this, tr("Load scene..."), Settings::workingDirectory(), tr("Image Files (%1)").arg(Settings::getGeneral_imageFormats()));
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>826</width>
|
<width>881</width>
|
||||||
<height>523</height>
|
<height>523</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -18,6 +18,15 @@
|
|||||||
<normaloff>:/images/resources/Find-Object.png</normaloff>:/images/resources/Find-Object.png</iconset>
|
<normaloff>:/images/resources/Find-Object.png</normaloff>:/images/resources/Find-Object.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="find_object::ImageDropWidget" name="imageDrop_scene" native="true">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0">
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@ -194,13 +203,16 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>826</width>
|
<width>881</width>
|
||||||
<height>25</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
@ -255,7 +267,7 @@
|
|||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>360</width>
|
<width>360</width>
|
||||||
<height>156</height>
|
<height>168</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="floating">
|
<property name="floating">
|
||||||
@ -285,8 +297,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>360</width>
|
<width>348</width>
|
||||||
<height>73</height>
|
<height>76</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@ -309,8 +321,8 @@
|
|||||||
<widget class="QDockWidget" name="dockWidget_objects">
|
<widget class="QDockWidget" name="dockWidget_objects">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>200</width>
|
<width>208</width>
|
||||||
<height>138</height>
|
<height>196</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -321,6 +333,12 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<widget class="QWidget" name="dockWidgetContents_2">
|
<widget class="QWidget" name="dockWidgetContents_2">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="find_object::ImageDropWidget" name="imageDrop_objects" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@ -343,8 +361,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>198</width>
|
<width>206</width>
|
||||||
<height>393</height>
|
<height>396</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_objects">
|
<layout class="QVBoxLayout" name="verticalLayout_objects">
|
||||||
@ -408,6 +426,12 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
<zorder></zorder>
|
||||||
|
<zorder>verticalSpacer</zorder>
|
||||||
|
<zorder>objects_area</zorder>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QDockWidget" name="dockWidget_plot">
|
<widget class="QDockWidget" name="dockWidget_plot">
|
||||||
@ -825,6 +849,12 @@
|
|||||||
<header>utilite/UPlot.h</header>
|
<header>utilite/UPlot.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>find_object::ImageDropWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>ImageDropWidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../resources.qrc"/>
|
<include location="../resources.qrc"/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user