-
Notifications
You must be signed in to change notification settings - Fork 71
Description
int main() {
// 加载图像
// std::string video_path = "/data/ai_monitor/simulate/video/channels/1";
std::string video_path = "rtsp://admin:antong%40%21%40%23%24@192.168.1.88:554/h264/ch0/main/av_stream";
std::shared_ptrcv::Mat mat_;
std::shared_ptrcv::VideoCapture cap = nullptr;
cap = std::make_sharedcv::VideoCapture(video_path, cv::CAP_ANY);
// VideoCapture cap(video_path,CAP_ANY);
if (!cap->isOpened() || cap == nullptr)
{
std::cout <<"open faild !" << std::endl;
return -1;
}
int frame_cout = 0;
mat_ = std::make_sharedcv::Mat();
while (true)
{
if (!cap->read(*mat_))
{
break;
}
auto now = std::chrono::system_clock::now();
auto time_point = std::chrono::system_clock::to_time_t(now);
std::stringstream ss;
ss << std::put_time(std::localtime(&time_point), "%H:%M:%S");
std::string formatted_time = ss.str();
std::cout << formatted_time << std::endl;
std::string filename = "./image/" + formatted_time + "" + std::to_string(frame_cout) + ".jpg";
std::string filename = "./image/" + std::to_string(frame_cout) + ".jpg";
imwrite(filename,*mat);
frame_cout++;
}
cap->release();
return 0;
}
这样读取实时视频咋存在延迟呢,直接用VLC拉流是正常的