32 #include <QtNetwork/QNetworkInterface> 33 #include <QtNetwork/QTcpSocket> 34 #include <QtGui/QTransform> 40 find_object::Settings::setCamera_4imageRate(hz);
41 find_object::Settings::setCamera_5mediaPath(path);
43 connect(&
camera_, SIGNAL(imageReceived(
const cv::Mat &)),
this, SLOT(
publishImage(
const cv::Mat &)));
44 connect(
this, SIGNAL(connected()),
this, SLOT(
startCamera()));
49 QHostAddress hostAddress;
51 QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
53 for (
int i = 0; i < ipAddressesList.size(); ++i)
55 if (ipAddressesList.at(i) != QHostAddress::LocalHost && ipAddressesList.at(i).toIPv4Address())
57 hostAddress = ipAddressesList.at(i).toString();
63 if (hostAddress.isNull())
65 hostAddress = QHostAddress(QHostAddress::LocalHost);
75 printf(
"No more images...\n");
81 if(this->waitForConnected())
83 std::vector<unsigned char> buf;
84 cv::imencode(
".png", image, buf);
87 QDataStream out(&block, QIODevice::WriteOnly);
88 out.setVersion(QDataStream::Qt_4_0);
90 out.writeRawData((
char*)buf.data(), (int)buf.size());
91 out.device()->seek(0);
92 out << (quint64)(block.size() -
sizeof(quint64));
98 printf(
"Lost connection...\n");
109 printf(
"Start...\n");
static QHostAddress getHostAddress()
ImagesTcpServer(float hz=10.0f, const QString &path="", QObject *parent=0)
void publishImage(const cv::Mat &image)
find_object::Camera camera_