/* * main.cpp * * Created on: 2014-05-05 * Author: mathieu */ #include #include #include #include #include #include "TcpResponse.h" #include "find_object/JsonWriter.h" void showUsage() { printf("\ntcpRequest [options] --scene image.png --out # --in #\n" " \"out\" is the port to which the image is sent.\n" " \"in\" is the port from which the detection is received.\n" " Options:\n" " --host #.#.#.# Set host address.\n"); if(JsonWriter::available()) { printf(" --json \"path\" Path to an output JSON file.\n"); } exit(-1); } int main(int argc, char * argv[]) { QString ipAddress; QString scenePath; QString jsonPath; quint16 portOut = 0; quint16 portIn = 0; for(int i=1; i buf; cv::imencode(".png", image, buf); QByteArray block; QDataStream out(&block, QIODevice::WriteOnly); out.setVersion(QDataStream::Qt_4_0); out << (quint64)0; out.writeRawData((char*)buf.data(), (int)buf.size()); out.device()->seek(0); out << (quint64)(block.size() - sizeof(quint64)); if(request.waitForReadyRead()) { qint64 bytes = request.write(block); printf("Image published (%d bytes), waiting for response...\n", (int)bytes); QTime time; time.start(); // wait for response app.exec(); if(response.dataReceived()) { printf("Response received! (%d ms)\n", time.elapsed()); // print detected objects if(response.info().objDetected_.size()) { QList ids = response.info().objDetected_.uniqueKeys(); for(int i=0; i