#include #include #include #include #include #include #include #include #include "transfer.h" #include "logging.h" #include using namespace std; using boost::asio::ip::tcp; int main() { try { boost::asio::io_context io_context; // creating socket tcp::acceptor acceptor(io_context, tcp::endpoint(tcp::v4(), 8080)); tcp::socket socket(io_context); info("Ready to accept connections."); // accepting connection request acceptor.accept(socket); info("Client connected."); // TODO: handle multiple images cv::Mat image = cv::Mat::zeros(cv::Size(640, 480), CV_8UC3); bool running = true; // TODO: make this asynchronous. probably do that in tandem with setting up networking while (running) { // receive data vector buffer; trace("Receiving image"); int latency = recvImage(socket, buffer); trace("Applying new data to image"); applyImage(image, &buffer); cv::putText(image, to_string(latency), cv::Point(0, 480), cv::FONT_HERSHEY_PLAIN, 1, cv::Scalar(255, 0, 0), 1, cv::LINE_AA); trace("Displaying image"); imshow("image", image); running = cv::waitKey(30) != 27; } } catch (std::exception& e) { error(e.what()); } return 0; }