Added TcpRequest tool (ask a running find_object to process an image and wait results over TCP)

Refactored CameraTcpClient to CameraTcpServer (to send images we connect to find_object, instead of connecting find_object to an image server), removed parameter CameraIP

git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@364 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
matlabbe
2014-08-02 06:09:27 +00:00
parent b28ca440e8
commit 167aeee4bc
18 changed files with 359 additions and 250 deletions
+1 -3
View File
@@ -12,15 +12,13 @@
#include <QtCore/QPointF>
#include <QtCore/QTime>
TcpClient::TcpClient(const QString & hostname, quint16 port, QObject *parent) :
TcpClient::TcpClient(QObject *parent) :
QTcpSocket(parent),
blockSize_(0)
{
connect(this, SIGNAL(readyRead()), this, SLOT(readReceivedData()));
connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
connect(this, SIGNAL(disconnected()), this, SLOT(connectionLost()));
this->connectToHost(hostname, port);
}
void TcpClient::readReceivedData()
+1 -1
View File
@@ -14,7 +14,7 @@ class TcpClient : public QTcpSocket
{
Q_OBJECT;
public:
TcpClient(const QString & hostname, quint16 port, QObject * parent = 0);
TcpClient(QObject * parent = 0);
private Q_SLOTS:
void readReceivedData();
+5 -19
View File
@@ -11,7 +11,7 @@
void showUsage()
{
printf("tcpClient [hostname] port\n");
printf("\ntcpObjectsClient [hostname] port\n");
exit(-1);
}
@@ -37,30 +37,16 @@ int main(int argc, char * argv[])
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();
}
ipAddress = QHostAddress(QHostAddress::LocalHost).toString();
}
QCoreApplication app(argc, argv);
printf("Connecting to \"%s:%d\"...\n", ipAddress.toStdString().c_str(), port);
TcpClient client(ipAddress, port);
TcpClient client;
client.connectToHost(ipAddress, port);
if(client.waitForConnected())
{