C++ 写视频而不是写作
我有很多视频。我想把这些视频逆时针旋转90度,然后重写它们。 我现在只想做一个视频。我将视频作为输出,但视频内容为空(0秒)。我不明白原因 这是我的密码C++ 写视频而不是写作,c++,opencv,C++,Opencv,我有很多视频。我想把这些视频逆时针旋转90度,然后重写它们。 我现在只想做一个视频。我将视频作为输出,但视频内容为空(0秒)。我不明白原因 这是我的密码 int main() { std::string videoPath = "/home/fifty/eclipse-workspace/detect/20210112_165122_B827EBB01032.avi"; cv::VideoCapture cap(videoPath); boost::filesystem
int main()
{
std::string videoPath = "/home/fifty/eclipse-workspace/detect/20210112_165122_B827EBB01032.avi";
cv::VideoCapture cap(videoPath);
boost::filesystem::path finalStorageVideoPath = "/home/fifty/eclipse-workspace/testOfflineAITracking/out.avi";
int frameWidth = cap.get(cv::CAP_PROP_FRAME_WIDTH);
int frameHeight = cap.get(cv::CAP_PROP_FRAME_HEIGHT);
cv::VideoWriter video(finalStorageVideoPath.string(),
cv::VideoWriter::fourcc('H', '2', '6', '4'), 10,
cv::Size(frameWidth, frameHeight));
cv::Mat img;
ulong FrameIndex = 0;
if (cap.open(videoPath))
{
while (cap.isOpened())
{
cout << "index : " << FrameIndex << endl;
cap >> img;
if(!img.empty())
{
transpose(img, img);
flip(img, img, 0);
cv::imshow("RotatingVideo", img);
cv::waitKey(100);
FrameIndex++;
video.write(img);
}
else
{
break;
}
}
cap.release();
video.release();
}
else
{
std::cout << "error" << std::endl;
}
std::cout << "End" << std::endl;
return 0;
}
intmain()
{
std::string videoPath=“/home/50th/eclipse workspace/detect/20210112\u 165122\u B827EBB01032.avi”;
cv::视频捕获cap(视频路径);
boost::filesystem::path finalStorageVideoPath=“/home/五十/eclipse workspace/testofflineitracking/out.avi”;
int frameWidth=cap.get(cv::cap\u PROP\u FRAME\u WIDTH);
int frameHeight=cap.get(cv::cap\u PROP\u FRAME\u HEIGHT);
cv::VideoWriter视频(finalStorageVideoPath.string(),
简历:VideoWriter:fourcc('H','2','6','4'),10,
cv::大小(帧宽、帧高);
cv::Mat img;
ulong FrameIndex=0;
如果(上限打开(视频路径))
{
while(cap.isOpened())
{
不能在写之前,试着调整你的框架大小
cv::resize(img, img, cv::Size(frameWidth, frameHeight));
video.write(img);