Fixed issue 19: Publish detected objects and position on TCP
git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@243 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
parent
6082ab4b63
commit
fa07e735a6
30
.cproject
30
.cproject
@ -1,16 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
<?fileVersion 4.0.0?>
|
||||||
|
|
||||||
|
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||||
<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1122816744">
|
<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1122816744">
|
||||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1122816744" moduleId="org.eclipse.cdt.core.settings" name="Unix">
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1122816744" moduleId="org.eclipse.cdt.core.settings" name="Unix">
|
||||||
<externalSettings/>
|
<externalSettings/>
|
||||||
<extensions>
|
<extensions>
|
||||||
|
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
|
||||||
</extensions>
|
</extensions>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
@ -83,12 +85,12 @@
|
|||||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1122816744.759219509" moduleId="org.eclipse.cdt.core.settings" name="Windows">
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1122816744.759219509" moduleId="org.eclipse.cdt.core.settings" name="Windows">
|
||||||
<externalSettings/>
|
<externalSettings/>
|
||||||
<extensions>
|
<extensions>
|
||||||
|
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
|
||||||
</extensions>
|
</extensions>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
@ -161,9 +163,6 @@
|
|||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
<project id="find_object.null.1999159200" name="find_object"/>
|
<project id="find_object.null.1999159200" name="find_object"/>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="scannerConfiguration">
|
|
||||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
||||||
<buildTargets>
|
<buildTargets>
|
||||||
<target name="CMake-MinGW-Debug" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="CMake-MinGW-Debug" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
@ -200,16 +199,17 @@
|
|||||||
</target>
|
</target>
|
||||||
</buildTargets>
|
</buildTargets>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
<storageModule moduleId="refreshScope" versionNumber="1">
|
||||||
<configuration configurationName="Windows">
|
|
||||||
<resource resourceType="PROJECT" workspacePath="/find-object"/>
|
|
||||||
</configuration>
|
|
||||||
<configuration configurationName="Default">
|
|
||||||
<resource resourceType="PROJECT" workspacePath="/find_object"/>
|
<resource resourceType="PROJECT" workspacePath="/find_object"/>
|
||||||
</configuration>
|
|
||||||
<configuration configurationName="Unix">
|
|
||||||
<resource resourceType="PROJECT" workspacePath="/find-object"/>
|
|
||||||
</configuration>
|
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||||
|
<storageModule moduleId="scannerConfiguration">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||||
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1122816744;cdt.managedbuild.toolchain.gnu.base.1122816744.306079558;cdt.managedbuild.tool.gnu.cpp.compiler.base.2094327183;cdt.managedbuild.tool.gnu.cpp.compiler.input.424205109">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1122816744;cdt.managedbuild.toolchain.gnu.base.1122816744.306079558;cdt.managedbuild.tool.gnu.c.compiler.base.86959710;cdt.managedbuild.tool.gnu.c.compiler.input.1730465962">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
</storageModule>
|
||||||
</cproject>
|
</cproject>
|
||||||
|
|||||||
@ -41,7 +41,7 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
|
|||||||
|
|
||||||
####### DEPENDENCIES #######
|
####### DEPENDENCIES #######
|
||||||
FIND_PACKAGE(OpenCV REQUIRED) # tested on 2.3.1
|
FIND_PACKAGE(OpenCV REQUIRED) # tested on 2.3.1
|
||||||
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui) # tested on Qt4.7
|
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtNetwork) # tested on Qt4.7
|
||||||
|
|
||||||
####### OSX BUNDLE CMAKE_INSTALL_PREFIX #######
|
####### OSX BUNDLE CMAKE_INSTALL_PREFIX #######
|
||||||
OPTION(BUILD_AS_BUNDLE "Set to ON to build as bundle (DragNDrop)" OFF)
|
OPTION(BUILD_AS_BUNDLE "Set to ON to build as bundle (DragNDrop)" OFF)
|
||||||
@ -64,6 +64,7 @@ ENDIF(APPLE AND BUILD_AS_BUNDLE)
|
|||||||
####### SOURCES (Projects) #######
|
####### SOURCES (Projects) #######
|
||||||
ADD_SUBDIRECTORY( app )
|
ADD_SUBDIRECTORY( app )
|
||||||
ADD_SUBDIRECTORY( example )
|
ADD_SUBDIRECTORY( example )
|
||||||
|
ADD_SUBDIRECTORY( tcpClient )
|
||||||
ADD_SUBDIRECTORY( console_app )
|
ADD_SUBDIRECTORY( console_app )
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ SET(headers_ui
|
|||||||
../src/Camera.h
|
../src/Camera.h
|
||||||
../src/ParametersToolBox.h
|
../src/ParametersToolBox.h
|
||||||
../src/AboutDialog.h
|
../src/AboutDialog.h
|
||||||
|
../src/TcpServer.h
|
||||||
../src/utilite/UPlot.h
|
../src/utilite/UPlot.h
|
||||||
../src/rtabmap/PdfPlot.h
|
../src/rtabmap/PdfPlot.h
|
||||||
)
|
)
|
||||||
@ -44,6 +45,7 @@ SET(SRC_FILES
|
|||||||
../src/Settings.cpp
|
../src/Settings.cpp
|
||||||
../src/ObjWidget.cpp
|
../src/ObjWidget.cpp
|
||||||
../src/AboutDialog.cpp
|
../src/AboutDialog.cpp
|
||||||
|
../src/TcpServer.cpp
|
||||||
../src/utilite/UPlot.cpp
|
../src/utilite/UPlot.cpp
|
||||||
../src/utilite/UDirectory.cpp
|
../src/utilite/UDirectory.cpp
|
||||||
../src/utilite/UFile.cpp
|
../src/utilite/UFile.cpp
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "ParametersToolBox.h"
|
#include "ParametersToolBox.h"
|
||||||
#include "AboutDialog.h"
|
#include "AboutDialog.h"
|
||||||
|
#include "TcpServer.h"
|
||||||
#include "rtabmap/PdfPlot.h"
|
#include "rtabmap/PdfPlot.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -45,7 +46,8 @@ MainWindow::MainWindow(Camera * camera, const QString & settings, QWidget * pare
|
|||||||
settings_(settings),
|
settings_(settings),
|
||||||
likelihoodCurve_(0),
|
likelihoodCurve_(0),
|
||||||
lowestRefreshRate_(99),
|
lowestRefreshRate_(99),
|
||||||
objectsModified_(false)
|
objectsModified_(false),
|
||||||
|
tcpServer_(0)
|
||||||
{
|
{
|
||||||
ui_ = new Ui_mainWindow();
|
ui_ = new Ui_mainWindow();
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
@ -152,6 +154,10 @@ connect(ui_->toolBox, SIGNAL(parametersChanged(const QStringList &)), this, SLOT
|
|||||||
ui_->actionCamera_from_video_file->setChecked(!Settings::getCamera_5mediaPath().isEmpty() && !UDirectory::exists(Settings::getCamera_5mediaPath().toStdString()));
|
ui_->actionCamera_from_video_file->setChecked(!Settings::getCamera_5mediaPath().isEmpty() && !UDirectory::exists(Settings::getCamera_5mediaPath().toStdString()));
|
||||||
ui_->actionCamera_from_directory_of_images->setChecked(!Settings::getCamera_5mediaPath().isEmpty() && UDirectory::exists(Settings::getCamera_5mediaPath().toStdString()));
|
ui_->actionCamera_from_directory_of_images->setChecked(!Settings::getCamera_5mediaPath().isEmpty() && UDirectory::exists(Settings::getCamera_5mediaPath().toStdString()));
|
||||||
|
|
||||||
|
ui_->label_ipAddress->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
|
ui_->label_port->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
|
setupTCPServer();
|
||||||
|
|
||||||
if(Settings::getGeneral_autoStartCamera())
|
if(Settings::getGeneral_autoStartCamera())
|
||||||
{
|
{
|
||||||
// Set 1 msec to see state on the status bar.
|
// Set 1 msec to see state on the status bar.
|
||||||
@ -200,6 +206,21 @@ void MainWindow::closeEvent(QCloseEvent * event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::setupTCPServer()
|
||||||
|
{
|
||||||
|
if(tcpServer_)
|
||||||
|
{
|
||||||
|
tcpServer_->close();
|
||||||
|
delete tcpServer_;
|
||||||
|
}
|
||||||
|
tcpServer_ = new TcpServer(Settings::getGeneral_port(), this);
|
||||||
|
connect(this, SIGNAL(objectsFound(QMultiMap<int,QPair<QRect,QTransform> >)), tcpServer_, SLOT(publishObjects(QMultiMap<int,QPair<QRect,QTransform> >)));
|
||||||
|
ui_->label_ipAddress->setText(tcpServer_->getHostAddress().toString());
|
||||||
|
ui_->label_port->setNum(tcpServer_->getPort());
|
||||||
|
printf("IP: %s\nport: %d\n",
|
||||||
|
tcpServer_->getHostAddress().toString().toStdString().c_str(), tcpServer_->getPort());
|
||||||
|
}
|
||||||
|
|
||||||
ParametersToolBox * MainWindow::parametersToolBox() const
|
ParametersToolBox * MainWindow::parametersToolBox() const
|
||||||
{
|
{
|
||||||
return ui_->toolBox;
|
return ui_->toolBox;
|
||||||
@ -1007,10 +1028,11 @@ protected:
|
|||||||
++outliers_;
|
++outliers_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(Settings::getHomography_ignoreWhenAllInliers())
|
|
||||||
{
|
|
||||||
// ignore homography when all features are inliers
|
// ignore homography when all features are inliers
|
||||||
if(inliers_ == (int)outlierMask_.size())
|
if(inliers_ == (int)outlierMask_.size() && !h_.empty())
|
||||||
|
{
|
||||||
|
if(Settings::getHomography_ignoreWhenAllInliers() || cv::countNonZero(h_) < 1)
|
||||||
{
|
{
|
||||||
h_ = cv::Mat();
|
h_ = cv::Mat();
|
||||||
}
|
}
|
||||||
@ -1506,6 +1528,13 @@ void MainWindow::notifyParametersChanged(const QStringList & paramChanged)
|
|||||||
{
|
{
|
||||||
nearestNeighborParamsChanged = true;
|
nearestNeighborParamsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(iter->compare(Settings::kGeneral_port()) == 0 &&
|
||||||
|
Settings::getGeneral_port() != ui_->label_port->text().toInt() &&
|
||||||
|
Settings::getGeneral_port() != 0)
|
||||||
|
{
|
||||||
|
setupTCPServer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Settings::getGeneral_autoUpdateObjects())
|
if(Settings::getGeneral_autoUpdateObjects())
|
||||||
|
|||||||
@ -22,6 +22,7 @@ class Camera;
|
|||||||
class ParametersToolBox;
|
class ParametersToolBox;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class AboutDialog;
|
class AboutDialog;
|
||||||
|
class TcpServer;
|
||||||
|
|
||||||
namespace rtabmap
|
namespace rtabmap
|
||||||
{
|
{
|
||||||
@ -77,6 +78,7 @@ signals:
|
|||||||
void objectsFound(const QMultiMap<int, QPair<QRect, QTransform> > &);
|
void objectsFound(const QMultiMap<int, QPair<QRect, QTransform> > &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setupTCPServer();
|
||||||
void addObjectFromFile(const QString & filePath);
|
void addObjectFromFile(const QString & filePath);
|
||||||
void showObject(ObjWidget * obj);
|
void showObject(ObjWidget * obj);
|
||||||
void updateData();
|
void updateData();
|
||||||
@ -97,6 +99,7 @@ private:
|
|||||||
int lowestRefreshRate_;
|
int lowestRefreshRate_;
|
||||||
bool objectsModified_;
|
bool objectsModified_;
|
||||||
QMap<int, QByteArray> imagesMap_;
|
QMap<int, QByteArray> imagesMap_;
|
||||||
|
TcpServer * tcpServer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MainWindow_H_ */
|
#endif /* MainWindow_H_ */
|
||||||
|
|||||||
@ -422,9 +422,20 @@ void ParametersToolBox::changeParameter()
|
|||||||
Settings::setParameter(sender()->objectName(), doubleSpinBox->value());
|
Settings::setParameter(sender()->objectName(), doubleSpinBox->value());
|
||||||
}
|
}
|
||||||
else if(spinBox)
|
else if(spinBox)
|
||||||
|
{
|
||||||
|
if(spinBox->objectName().compare(Settings::kHomography_minimumInliers()) == 0 &&
|
||||||
|
spinBox->value() < 4)
|
||||||
|
{
|
||||||
|
Settings::setHomography_minimumInliers(4);
|
||||||
|
spinBox->blockSignals(true);
|
||||||
|
this->updateParameter(Settings::kHomography_minimumInliers());
|
||||||
|
spinBox->blockSignals(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Settings::setParameter(sender()->objectName(), spinBox->value());
|
Settings::setParameter(sender()->objectName(), spinBox->value());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(lineEdit)
|
else if(lineEdit)
|
||||||
{
|
{
|
||||||
Settings::setParameter(sender()->objectName(), lineEdit->text());
|
Settings::setParameter(sender()->objectName(), lineEdit->text());
|
||||||
@ -545,6 +556,7 @@ void ParametersToolBox::changeParameter(const int & value)
|
|||||||
{
|
{
|
||||||
Settings::setParameter(sender()->objectName(), value==Qt::Checked?true:false);
|
Settings::setParameter(sender()->objectName(), value==Qt::Checked?true:false);
|
||||||
}
|
}
|
||||||
|
|
||||||
paramChanged.append(sender()->objectName());
|
paramChanged.append(sender()->objectName());
|
||||||
emit parametersChanged(paramChanged);
|
emit parametersChanged(paramChanged);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -175,11 +175,12 @@ class Settings
|
|||||||
PARAMETER(General, threads, int, 1, "Number of threads used for objects matching and homography computation. 0 means as many threads as objects. On InvertedSearch mode, multi-threading has only effect on homography computation.");
|
PARAMETER(General, threads, int, 1, "Number of threads used for objects matching and homography computation. 0 means as many threads as objects. On InvertedSearch mode, multi-threading has only effect on homography computation.");
|
||||||
PARAMETER(General, multiDetection, bool, false, "Multiple detection of the same object.");
|
PARAMETER(General, multiDetection, bool, false, "Multiple detection of the same object.");
|
||||||
PARAMETER(General, multiDetectionRadius, int, 30, "Ignore detection of the same object in X pixels radius of the previous detections.");
|
PARAMETER(General, multiDetectionRadius, int, 30, "Ignore detection of the same object in X pixels radius of the previous detections.");
|
||||||
|
PARAMETER(General, port, int, 0, "Port on objects detected are published. If port=0, a port is chosen automatically.")
|
||||||
|
|
||||||
PARAMETER(Homography, homographyComputed, bool, true, "Compute homography? On ROS, this is required to publish objects detected.");
|
PARAMETER(Homography, homographyComputed, bool, true, "Compute homography? On ROS, this is required to publish objects detected.");
|
||||||
PARAMETER(Homography, method, QString, "1:LMEDS;RANSAC", "Type of the robust estimation algorithm: least-median algorithm or RANSAC algorithm.");
|
PARAMETER(Homography, method, QString, "1:LMEDS;RANSAC", "Type of the robust estimation algorithm: least-median algorithm or RANSAC algorithm.");
|
||||||
PARAMETER(Homography, ransacReprojThr, double, 1.0, "Maximum allowed reprojection error to treat a point pair as an inlier (used in the RANSAC method only). It usually makes sense to set this parameter somewhere in the range of 1 to 10.");
|
PARAMETER(Homography, ransacReprojThr, double, 1.0, "Maximum allowed reprojection error to treat a point pair as an inlier (used in the RANSAC method only). It usually makes sense to set this parameter somewhere in the range of 1 to 10.");
|
||||||
PARAMETER(Homography, minimumInliers, int, 10, "Minimum inliers to accept the homography.");
|
PARAMETER(Homography, minimumInliers, int, 10, "Minimum inliers to accept the homography. Value must be >= 4.");
|
||||||
PARAMETER(Homography, ignoreWhenAllInliers, bool, false, "Ignore homography when all features are inliers (sometimes when the homography doesn't converge, it returns the best homography with all features as inliers).");
|
PARAMETER(Homography, ignoreWhenAllInliers, bool, false, "Ignore homography when all features are inliers (sometimes when the homography doesn't converge, it returns the best homography with all features as inliers).");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
99
src/TcpServer.cpp
Normal file
99
src/TcpServer.cpp
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* TCPServer.cpp
|
||||||
|
*
|
||||||
|
* Created on: 2014-05-05
|
||||||
|
* Author: mathieu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "TcpServer.h"
|
||||||
|
|
||||||
|
#include <QtNetwork/QNetworkInterface>
|
||||||
|
#include <QtNetwork/QTcpSocket>
|
||||||
|
#include <QtGui/QTransform>
|
||||||
|
|
||||||
|
TcpServer::TcpServer(quint16 port, QObject * parent) :
|
||||||
|
QTcpServer(parent)
|
||||||
|
{
|
||||||
|
if (!this->listen(QHostAddress::Any, port))
|
||||||
|
{
|
||||||
|
printf("ERROR: Unable to start the TCP server: %s\n", this->errorString().toStdString().c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(this, SIGNAL(newConnection()), this, SLOT(addClient()));
|
||||||
|
}
|
||||||
|
|
||||||
|
QHostAddress TcpServer::getHostAddress() const
|
||||||
|
{
|
||||||
|
QHostAddress hostAddress;
|
||||||
|
|
||||||
|
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
|
||||||
|
// use the first non-localhost IPv4 address
|
||||||
|
for (int i = 0; i < ipAddressesList.size(); ++i)
|
||||||
|
{
|
||||||
|
if (ipAddressesList.at(i) != QHostAddress::LocalHost && ipAddressesList.at(i).toIPv4Address())
|
||||||
|
{
|
||||||
|
hostAddress = ipAddressesList.at(i).toString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we did not find one, use IPv4 localhost
|
||||||
|
if (hostAddress.isNull())
|
||||||
|
{
|
||||||
|
hostAddress = QHostAddress(QHostAddress::LocalHost);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hostAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint16 TcpServer::getPort() const
|
||||||
|
{
|
||||||
|
return this->serverPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcpServer::publishObjects(const QMultiMap<int, QPair<QRect, QTransform> > & objects)
|
||||||
|
{
|
||||||
|
if(objects.size())
|
||||||
|
{
|
||||||
|
QList<QTcpSocket*> clients = this->findChildren<QTcpSocket*>();
|
||||||
|
if(clients.size())
|
||||||
|
{
|
||||||
|
QVector<float> data(objects.size()*12);
|
||||||
|
int i=0;
|
||||||
|
for(QMultiMap<int, QPair<QRect, QTransform> >::const_iterator iter=objects.constBegin(); iter!=objects.constEnd(); ++iter)
|
||||||
|
{
|
||||||
|
data[i++] = iter.key();
|
||||||
|
data[i++] = iter.value().first.width();
|
||||||
|
data[i++] = iter.value().first.height();
|
||||||
|
data[i++] = iter.value().second.m11();
|
||||||
|
data[i++] = iter.value().second.m12();
|
||||||
|
data[i++] = iter.value().second.m13();
|
||||||
|
data[i++] = iter.value().second.m21();
|
||||||
|
data[i++] = iter.value().second.m22();
|
||||||
|
data[i++] = iter.value().second.m23();
|
||||||
|
data[i++] = iter.value().second.m31(); // dx
|
||||||
|
data[i++] = iter.value().second.m32(); // dy
|
||||||
|
data[i++] = iter.value().second.m33();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(QList<QTcpSocket*>::iterator iter = clients.begin(); iter!=clients.end(); ++iter)
|
||||||
|
{
|
||||||
|
QByteArray block;
|
||||||
|
QDataStream out(&block, QIODevice::WriteOnly);
|
||||||
|
out.setVersion(QDataStream::Qt_4_0);
|
||||||
|
out << (quint16)0;
|
||||||
|
out << data;
|
||||||
|
out.device()->seek(0);
|
||||||
|
out << (quint16)(block.size() - sizeof(quint16));
|
||||||
|
(*iter)->write(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcpServer::addClient()
|
||||||
|
{
|
||||||
|
QTcpSocket * client = this->nextPendingConnection();
|
||||||
|
connect(client, SIGNAL(disconnected()), client, SLOT(deleteLater()));
|
||||||
|
}
|
||||||
31
src/TcpServer.h
Normal file
31
src/TcpServer.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* TCPServer.h
|
||||||
|
*
|
||||||
|
* Created on: 2014-05-05
|
||||||
|
* Author: mathieu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TCPSERVER_H_
|
||||||
|
#define TCPSERVER_H_
|
||||||
|
|
||||||
|
#include <QtNetwork/QTcpServer>
|
||||||
|
|
||||||
|
class QNetworkSession;
|
||||||
|
|
||||||
|
class TcpServer : public QTcpServer
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TcpServer(quint16 port = 0, QObject * parent = 0);
|
||||||
|
|
||||||
|
QHostAddress getHostAddress() const;
|
||||||
|
quint16 getPort() const;
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void addClient();
|
||||||
|
void publishObjects(const QMultiMap<int, QPair<QRect, QTransform> > & objects);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* TCPSERVER_H_ */
|
||||||
@ -287,13 +287,20 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0">
|
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0">
|
||||||
<property name="horizontalSpacing">
|
<property name="horizontalSpacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="verticalSpacing">
|
<property name="verticalSpacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="label_timeIndexing">
|
||||||
|
<property name="text">
|
||||||
|
<string>000</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QLabel" name="label_timeMatching">
|
<widget class="QLabel" name="label_timeMatching">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -420,13 +427,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QLabel" name="label_timeIndexing">
|
|
||||||
<property name="text">
|
|
||||||
<string>000</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -462,6 +462,34 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
|
<widget class="QLabel" name="label_18">
|
||||||
|
<property name="text">
|
||||||
|
<string>IP address</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="0">
|
||||||
|
<widget class="QLabel" name="label_19">
|
||||||
|
<property name="text">
|
||||||
|
<string>Port</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="1">
|
||||||
|
<widget class="QLabel" name="label_ipAddress">
|
||||||
|
<property name="text">
|
||||||
|
<string>0.0.0.0</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="1">
|
||||||
|
<widget class="QLabel" name="label_port">
|
||||||
|
<property name="text">
|
||||||
|
<string>0</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -478,7 +506,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>360</width>
|
<width>360</width>
|
||||||
<height>120</height>
|
<height>86</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
|
|||||||
37
tcpClient/CMakeLists.txt
Normal file
37
tcpClient/CMakeLists.txt
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
### Qt Gui stuff ###
|
||||||
|
SET(headers_ui
|
||||||
|
TcpClient.h
|
||||||
|
)
|
||||||
|
#This will generate moc_* for Qt
|
||||||
|
QT4_WRAP_CPP(moc_srcs ${headers_ui})
|
||||||
|
### Qt Gui stuff end###
|
||||||
|
|
||||||
|
SET(SRC_FILES
|
||||||
|
TcpClient.cpp
|
||||||
|
main.cpp
|
||||||
|
${moc_srcs}
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(INCLUDE_DIRS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${OpenCV_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
INCLUDE(${QT_USE_FILE})
|
||||||
|
|
||||||
|
SET(LIBRARIES
|
||||||
|
${OpenCV_LIBS}
|
||||||
|
${QT_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Make sure the compiler can find include files from our library.
|
||||||
|
INCLUDE_DIRECTORIES(${INCLUDE_DIRS})
|
||||||
|
|
||||||
|
# Add binary called "example" that is built from the source file "main.cpp".
|
||||||
|
# The extension is automatically found.
|
||||||
|
ADD_EXECUTABLE(tcpClient ${SRC_FILES})
|
||||||
|
TARGET_LINK_LIBRARIES(tcpClient ${LIBRARIES})
|
||||||
|
|
||||||
|
SET_TARGET_PROPERTIES( tcpClient
|
||||||
|
PROPERTIES OUTPUT_NAME ${PROJECT_PREFIX}-tcpClient)
|
||||||
|
|
||||||
132
tcpClient/TcpClient.cpp
Normal file
132
tcpClient/TcpClient.cpp
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* TCPClient.cpp
|
||||||
|
*
|
||||||
|
* Created on: 2014-05-05
|
||||||
|
* Author: mathieu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "TcpClient.h"
|
||||||
|
|
||||||
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include <QtGui/QTransform>
|
||||||
|
#include <QtCore/QPointF>
|
||||||
|
|
||||||
|
TcpClient::TcpClient(const QString & hostname, quint16 port, QObject *parent) :
|
||||||
|
QTcpSocket(parent),
|
||||||
|
blockSize_(0)
|
||||||
|
{
|
||||||
|
connect(this, SIGNAL(readyRead()), this, SLOT(readData()));
|
||||||
|
connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
|
||||||
|
connect(this, SIGNAL(disconnected()), this, SLOT(connectionLost()));
|
||||||
|
|
||||||
|
this->connectToHost(hostname, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcpClient::readData()
|
||||||
|
{
|
||||||
|
QDataStream in(this);
|
||||||
|
in.setVersion(QDataStream::Qt_4_0);
|
||||||
|
|
||||||
|
if (blockSize_ == 0)
|
||||||
|
{
|
||||||
|
if (this->bytesAvailable() < (int)sizeof(quint16))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
in >> blockSize_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->bytesAvailable() < blockSize_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockSize_ = 0;
|
||||||
|
|
||||||
|
QVector<float> data;
|
||||||
|
in >> data;
|
||||||
|
|
||||||
|
printf("---\n");
|
||||||
|
for(int i=0; i<data.size(); i+=12)
|
||||||
|
{
|
||||||
|
// get data
|
||||||
|
int id = (int)data[i];
|
||||||
|
float objectWidth = data[i+1];
|
||||||
|
float objectHeight = data[i+2];
|
||||||
|
|
||||||
|
// Find corners Qt
|
||||||
|
QTransform qtHomography(data[i+3], data[i+4], data[i+5],
|
||||||
|
data[i+6], data[i+7], data[i+8],
|
||||||
|
data[i+9], data[i+10], data[i+11]);
|
||||||
|
|
||||||
|
QPointF qtTopLeft = qtHomography.map(QPointF(0,0));
|
||||||
|
QPointF qtTopRight = qtHomography.map(QPointF(objectWidth,0));
|
||||||
|
QPointF qtBottomLeft = qtHomography.map(QPointF(0,objectHeight));
|
||||||
|
QPointF qtBottomRight = qtHomography.map(QPointF(objectWidth,objectHeight));
|
||||||
|
|
||||||
|
printf("Object %d detected, Qt corners at (%f,%f) (%f,%f) (%f,%f) (%f,%f)\n",
|
||||||
|
id,
|
||||||
|
qtTopLeft.x(), qtTopLeft.y(),
|
||||||
|
qtTopRight.x(), qtTopRight.y(),
|
||||||
|
qtBottomLeft.x(), qtBottomLeft.y(),
|
||||||
|
qtBottomRight.x(), qtBottomRight.y());
|
||||||
|
|
||||||
|
// Example with OpenCV
|
||||||
|
if(0)
|
||||||
|
{
|
||||||
|
// Find corners OpenCV
|
||||||
|
cv::Mat cvHomography(3, 3, CV_32F);
|
||||||
|
cvHomography.at<float>(0,0) = data[i+3];
|
||||||
|
cvHomography.at<float>(1,0) = data[i+4];
|
||||||
|
cvHomography.at<float>(2,0) = data[i+5];
|
||||||
|
cvHomography.at<float>(0,1) = data[i+6];
|
||||||
|
cvHomography.at<float>(1,1) = data[i+7];
|
||||||
|
cvHomography.at<float>(2,1) = data[i+8];
|
||||||
|
cvHomography.at<float>(0,2) = data[i+9];
|
||||||
|
cvHomography.at<float>(1,2) = data[i+10];
|
||||||
|
cvHomography.at<float>(2,2) = data[i+11];
|
||||||
|
std::vector<cv::Point2f> inPts, outPts;
|
||||||
|
inPts.push_back(cv::Point2f(0,0));
|
||||||
|
inPts.push_back(cv::Point2f(objectWidth,0));
|
||||||
|
inPts.push_back(cv::Point2f(0,objectHeight));
|
||||||
|
inPts.push_back(cv::Point2f(objectWidth,objectHeight));
|
||||||
|
cv::perspectiveTransform(inPts, outPts, cvHomography);
|
||||||
|
|
||||||
|
printf("Object %d detected, CV corners at (%f,%f) (%f,%f) (%f,%f) (%f,%f)\n",
|
||||||
|
id,
|
||||||
|
outPts.at(0).x, outPts.at(0).y,
|
||||||
|
outPts.at(1).x, outPts.at(1).y,
|
||||||
|
outPts.at(2).x, outPts.at(2).y,
|
||||||
|
outPts.at(3).x, outPts.at(3).y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcpClient::displayError(QAbstractSocket::SocketError socketError)
|
||||||
|
{
|
||||||
|
switch (socketError)
|
||||||
|
{
|
||||||
|
case QAbstractSocket::RemoteHostClosedError:
|
||||||
|
break;
|
||||||
|
case QAbstractSocket::HostNotFoundError:
|
||||||
|
printf("Tcp error: The host was not found. Please "
|
||||||
|
"check the host name and port settings.\n");
|
||||||
|
break;
|
||||||
|
case QAbstractSocket::ConnectionRefusedError:
|
||||||
|
printf("The connection was refused by the peer. "
|
||||||
|
"Make sure Find-Object is running, "
|
||||||
|
"and check that the host name and port "
|
||||||
|
"settings are correct.\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("The following error occurred: %s.\n", this->errorString().toStdString().c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TcpClient::connectionLost()
|
||||||
|
{
|
||||||
|
printf("Connection lost!\n");
|
||||||
|
}
|
||||||
|
|
||||||
28
tcpClient/TcpClient.h
Normal file
28
tcpClient/TcpClient.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* TCPClient.h
|
||||||
|
*
|
||||||
|
* Created on: 2014-05-05
|
||||||
|
* Author: mathieu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TCPCLIENT_H_
|
||||||
|
#define TCPCLIENT_H_
|
||||||
|
|
||||||
|
#include <QtNetwork/QTcpSocket>
|
||||||
|
|
||||||
|
class TcpClient : public QTcpSocket
|
||||||
|
{
|
||||||
|
Q_OBJECT;
|
||||||
|
public:
|
||||||
|
TcpClient(const QString & hostname, quint16 port, QObject * parent = 0);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void readData();
|
||||||
|
void displayError(QAbstractSocket::SocketError socketError);
|
||||||
|
void connectionLost();
|
||||||
|
|
||||||
|
private:
|
||||||
|
quint16 blockSize_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* TCPCLIENT_H_ */
|
||||||
77
tcpClient/main.cpp
Normal file
77
tcpClient/main.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* main.cpp
|
||||||
|
*
|
||||||
|
* Created on: 2014-05-05
|
||||||
|
* Author: mathieu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QtNetwork/QNetworkInterface>
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
|
#include "TcpClient.h"
|
||||||
|
|
||||||
|
void showUsage()
|
||||||
|
{
|
||||||
|
printf("exampleTcpClient [hostname] port\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char * argv[])
|
||||||
|
{
|
||||||
|
if(argc < 2 || argc > 3)
|
||||||
|
{
|
||||||
|
showUsage();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ipAddress;
|
||||||
|
quint16 port = 0;
|
||||||
|
|
||||||
|
if(argc == 2)
|
||||||
|
{
|
||||||
|
port = std::atoi(argv[1]);
|
||||||
|
}
|
||||||
|
else if(argc == 3)
|
||||||
|
{
|
||||||
|
ipAddress = argv[1];
|
||||||
|
port = std::atoi(argv[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ipAddress.isEmpty())
|
||||||
|
{
|
||||||
|
// find out which IP to connect to
|
||||||
|
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
|
||||||
|
// use the first non-localhost IPv4 address
|
||||||
|
for (int i = 0; i < ipAddressesList.size(); ++i)
|
||||||
|
{
|
||||||
|
if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
|
||||||
|
ipAddressesList.at(i).toIPv4Address())
|
||||||
|
{
|
||||||
|
ipAddress = ipAddressesList.at(i).toString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if we did not find one, use IPv4 localhost
|
||||||
|
if (ipAddress.isEmpty())
|
||||||
|
{
|
||||||
|
ipAddress = QHostAddress(QHostAddress::LocalHost).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
|
printf("Connecting to \"%s:%d\"...\n", ipAddress.toStdString().c_str(), port);
|
||||||
|
|
||||||
|
TcpClient client(ipAddress, port);
|
||||||
|
|
||||||
|
if(client.waitForConnected())
|
||||||
|
{
|
||||||
|
printf("Connecting to \"%s:%d\"... connected!\n", ipAddress.toStdString().c_str(), port);
|
||||||
|
app.exec();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Connecting to \"%s:%d\"... connection failed!\n", ipAddress.toStdString().c_str(), port);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user