diff --git a/tools/tcpClient/CMakeLists.txt b/tools/tcpClient/CMakeLists.txt index ddb2e2d7..f9363d3f 100644 --- a/tools/tcpClient/CMakeLists.txt +++ b/tools/tcpClient/CMakeLists.txt @@ -13,6 +13,7 @@ SET(SRC_FILES ) SET(INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/../../include ${CMAKE_CURRENT_SOURCE_DIR} ${OpenCV_INCLUDE_DIRS} ) @@ -29,12 +30,12 @@ INCLUDE_DIRECTORIES(${INCLUDE_DIRS}) # Add binary called "example" that is built from the source file "main.cpp". # The extension is automatically found. -ADD_EXECUTABLE(tcpObjectsClient ${SRC_FILES}) -TARGET_LINK_LIBRARIES(tcpObjectsClient ${LIBRARIES}) +ADD_EXECUTABLE(tcpClient ${SRC_FILES}) +TARGET_LINK_LIBRARIES(tcpClient ${LIBRARIES}) -SET_TARGET_PROPERTIES( tcpObjectsClient - PROPERTIES OUTPUT_NAME ${PROJECT_PREFIX}-tcpObjectsClient) +SET_TARGET_PROPERTIES( tcpClient + PROPERTIES OUTPUT_NAME ${PROJECT_PREFIX}-tcpClient) -INSTALL(TARGETS tcpObjectsClient +INSTALL(TARGETS tcpClient RUNTIME DESTINATION bin COMPONENT runtime BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}" COMPONENT runtime) \ No newline at end of file diff --git a/tools/tcpClient/TcpClient.cpp b/tools/tcpClient/TcpClient.cpp index 58a92922..7054636c 100644 --- a/tools/tcpClient/TcpClient.cpp +++ b/tools/tcpClient/TcpClient.cpp @@ -6,7 +6,7 @@ */ #include "TcpClient.h" - +#include "find_object/DetectionInfo.h" #include #include #include @@ -43,28 +43,29 @@ void TcpClient::readReceivedData() blockSize_ = 0; - QVector data; - in >> data; + DetectionInfo info; + in >> info; printf("---\n"); - if(data.size() == 0) + if(info.objDetected_.size() == 0) { printf("(%s) No objects detected.\n", QTime::currentTime().toString("HH:mm:ss.zzz").toStdString().c_str()); } else { - for(int i=0; i::const_iterator iterSizes = info.objDetectedSizes_.constBegin(); + for(QMultiMap::const_iterator iter=info.objDetected_.constBegin(); + iter!=info.objDetected_.constEnd(); + ++iter) { // get data - int id = (int)data[i]; - float objectWidth = data[i+1]; - float objectHeight = data[i+2]; + int id = (int)iter.key(); + float objectWidth = iterSizes.value().width(); + float objectHeight = iterSizes.value().height(); // 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]); + QTransform qtHomography = iter.value(); QPointF qtTopLeft = qtHomography.map(QPointF(0,0)); QPointF qtTopRight = qtHomography.map(QPointF(objectWidth,0)); @@ -84,15 +85,15 @@ void TcpClient::readReceivedData() { // Find corners OpenCV cv::Mat cvHomography(3, 3, CV_32F); - cvHomography.at(0,0) = data[i+3]; - cvHomography.at(1,0) = data[i+4]; - cvHomography.at(2,0) = data[i+5]; - cvHomography.at(0,1) = data[i+6]; - cvHomography.at(1,1) = data[i+7]; - cvHomography.at(2,1) = data[i+8]; - cvHomography.at(0,2) = data[i+9]; - cvHomography.at(1,2) = data[i+10]; - cvHomography.at(2,2) = data[i+11]; + cvHomography.at(0,0) = qtHomography.m11(); + cvHomography.at(1,0) = qtHomography.m12(); + cvHomography.at(2,0) = qtHomography.m13(); + cvHomography.at(0,1) = qtHomography.m21(); + cvHomography.at(1,1) = qtHomography.m22(); + cvHomography.at(2,1) = qtHomography.m23(); + cvHomography.at(0,2) = qtHomography.m31(); + cvHomography.at(1,2) = qtHomography.m32(); + cvHomography.at(2,2) = qtHomography.m33(); std::vector inPts, outPts; inPts.push_back(cv::Point2f(0,0)); inPts.push_back(cv::Point2f(objectWidth,0)); @@ -108,6 +109,8 @@ void TcpClient::readReceivedData() outPts.at(2).x, outPts.at(2).y, outPts.at(3).x, outPts.at(3).y); } + + ++iterSizes; } } }