我想同时展示两个视频。以下代码正在运行,但不知何故,视频完成后会出现错误。如果我只播放一个视频,则不会发生错误。有什么帮助吗?
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
string filename1 = "C:/test_videos/toy_plane_liftoff.avi";
string filename2 = "C:/test_videos/toy_plane_liftoff_stab.avi";
VideoCapture capture1(filename1);
VideoCapture capture2(filename2);
Mat frame1, frame2;
if (!capture1.isOpened())
throw "Error1";
if (!capture2.isOpened())
throw "Error2";
for (int i = 0; i <= min(capture1.get(CV_CAP_PROP_FRAME_COUNT), capture2.get(CV_CAP_PROP_FRAME_COUNT)); i++)
{
capture1 >> frame1;
capture2 >> frame2;
imshow("1", frame1);
imshow("2", frame2);
if (waitKey(30) >= 0)
break;
}
return 0;
}
答案 0 :(得分:1)
您可以通过以下方式摆脱错误
HttpClient httpClient = new DefaultHttpClient();
try {
HttpPost request = new HttpPost("https://invoice.zoho.com/api/v3/contacts?authtoken="ur_token"&organization_id="ur_org_id");
StringEntity params =new StringEntity("JSONString={\"contact_name\":\"company_name\",\"age\":\"20\"} ");
request.addHeader("content-type", "application/json");
request.addHeader("Accept","application/json");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
System.out.println(response);
// handle response here...
}catch (Exception ex) {
// handle exception here
} finally {
httpClient.getConnectionManager().shutdown();
}