我试图将ORB OpenCV算法运行到视频帧,我注意到CPU版本的执行速度比GPU版本快得多.这是代码:
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
#include <fstream>
#include <sstream>
#include <math.h>
#include <omp.h>
#include <algorithm>
#include <vector>
#include <string>
using namespace cv;
using namespace std;
using namespace cv::gpu;
void process_cpu(string vid, int start_frame, int end_frame)
{
VideoCapture myCapture(vid);
Mat frame, gray_frame;
ORB myOrb(400);
Mat descriptors;
vector<KeyPoint> keypoints;
myCapture.set(CV_CAP_PROP_POS_FRAMES, start_frame);
for (int i=0; i<end_frame-start_frame; i++) {
myCapture.read(frame);
cvtColor(frame, gray_frame, CV_RGB2GRAY);
myOrb(gray_frame, Mat(), keypoints, descriptors);
}
myCapture.release();
}
void process_gpu(string vid, int start_frame, int end_frame) …
Run Code Online (Sandbox Code Playgroud) 我有一个小代码,它使用Poco库向本地Web服务发送POST HTTP调用并获得响应.目前我在cout终端上打印了回复消息.
#include "Poco/Net/HTTPClientSession.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h"
#include "Poco/StreamCopier.h"
#include <iostream>
using namespace std;
using namespace Poco::Net;
using namespace Poco;
int main (int argc, char* argv[])
{
HTTPClientSession s("localhost", 8000);
HTTPRequest request(HTTPRequest::HTTP_POST, "/test");
s.sendRequest(request);
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
StreamCopier::copyStream(rs, cout);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如何将响应消息存储在char数组或字符串中而不打印或存储在文件中?