我正在尝试通过发布请求发送opencv Mat。 首先,我将数据编码为base64,如下所示:
void SendMatFrame::encode(cv::Mat img)
{
std::vector<uchar> buf;
cv::imencode(".jpg", img, buf);
auto *enc_msg = reinterpret_cast<unsigned char*>(buf.data());
m_encoded = boost::beast::detail::base64_encode(enc_msg, buf.size());
}
然后创建我的帖子请求:
void SendMatFrame::send()
{
boost::asio::connect(m_socket, m_endpointIter);
boost::asio::streambuf request;
std::ostream request_stream(&request);
request_stream << "POST /calibration_result HTTP/1.1 \r\n";
request_stream << "Host:" << m_address << ":" << m_port << "\r\n";
request_stream << "User-Agent: C/1.0";
request_stream << "Content-Type: multipart/form-data; charset=utf-8 \r\n";
request_stream << "Content-Transfer-Encoding: base64\r\n";
request_stream << m_encoded << "\r\n";
request_stream << "Accept: */*\r\n";
request_stream << "Connection: close\r\n\r\n";
boost::asio::write(m_socket, request);
}
由于某种原因,我没有在服务器端收到请求。我的发帖请求出了点问题? 谢谢