如何基于C++解決RTSP取流報(bào)錯(cuò)問(wèn)題
使用g++ opencv_demo.cpp -o test 會(huì)報(bào)以下錯(cuò)誤
這是我的代碼:
#include <string> #include <iostream> #include <time.h> #include <opencv2/highgui/highgui.hpp> #include <opencv2/opencv.hpp> #include <opencv2/core.hpp> #include <opencv2/videoio/videoio.hpp> #include <opencv2/imgproc/imgproc_c.h> //#pragma comment(lib, "") using namespace std; using namespace cv; void Video_to_Image(Mat& frame); int main() { //string filename = "Wildlife.wmv"; string filename = "rtsp://admin:abc.1234@10.12.18.131:554"; Mat frame; VideoCapture cap; cap.open(filename); if (!cap.isOpened()) { cerr << "ERROR! Unable to open camera\n"; return -1; } //--- GRAB AND WRITE LOOP cout << "Start grabbing" << endl << "Press any key to terminate" << endl; time_t start_time = time(NULL); for (;;) { // wait for a new frame from camera and store it into 'frame' cap.read(frame); // check if we succeeded if (frame.empty()) { cerr << "ERROR! blank frame grabbed\n"; break; } // show live and wait for a key with timeout long enough to show images imshow("Live", frame); // 每隔2s保存圖片 time_t end_time = time(NULL); if ((end_time - start_time) >=2) { cout << "2s capture" << endl; Video_to_Image(frame); start_time = time(NULL); } if (waitKey(5) >= 0) break; } cap.release(); return 0; } void Video_to_Image(Mat& frame) { char image_name[PATH_MAX]; sprintf(image_name, "%s%s", "test_image", ".jpg"); imwrite(image_name, frame); }
解決方案:
g++ `pkg-config opencv --cflags` opencv_demo.cpp -o test `pkg-config opencv --libs`
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 15種?C++?常見報(bào)錯(cuò)原因分析
- c++報(bào)錯(cuò)問(wèn)題解決方案lvalue required as left operand of assignment
- C++?OpenCV裁剪圖片時(shí)發(fā)生報(bào)錯(cuò)的解決方式
- 解決pip?install?dlib報(bào)錯(cuò)C++11?is?required?to?use?dlib
- Python3安裝模塊報(bào)錯(cuò)Microsoft Visual C++ 14.0 is required的解決方法
- 解決安裝mysqlclient的時(shí)候出現(xiàn)Microsoft Visual C++ 14.0 is required報(bào)錯(cuò)
- C或C++報(bào)錯(cuò):ld returned 1 exit status報(bào)錯(cuò)的原因及解決方法
相關(guān)文章
C語(yǔ)言實(shí)現(xiàn)簡(jiǎn)單的掃雷游戲
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言實(shí)現(xiàn)簡(jiǎn)單的掃雷游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-12-12Typedef在C語(yǔ)言和C++中的用法和區(qū)別
在C語(yǔ)言和C++中,typedef是一個(gè)非常常用的關(guān)鍵字,用于為數(shù)據(jù)類型定義別名,盡管它在兩種語(yǔ)言中都有相似的功能,但由于C++具有更豐富的類型系統(tǒng),因此在實(shí)際應(yīng)用中,typedef在兩者間的使用存在一些微妙的差異2024-01-01C++ 中靜態(tài)成員函數(shù)與非靜態(tài)成員函數(shù)的區(qū)別
這篇文章主要介紹了C++ 中靜態(tài)成員函數(shù)與非靜態(tài)成員函數(shù)的區(qū)別的相關(guān)資料,需要的朋友可以參考下2017-05-05淺談C++中對(duì)象的復(fù)制與對(duì)象之間的相互賦值
這篇文章主要介紹了淺談C++中對(duì)象的復(fù)制與對(duì)象之間的相互賦值,是C語(yǔ)言入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下2015-09-09C++實(shí)現(xiàn)LeetCode(768.可排序的最大塊數(shù)之二)
這篇文章主要介紹了C++實(shí)現(xiàn)LeetCode(768.可排序的最大塊數(shù)之二),本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-07-07純C語(yǔ)言實(shí)現(xiàn)火車售票系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了純C語(yǔ)言實(shí)現(xiàn)火車售票系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-12-12c++ builder TreeView控件節(jié)點(diǎn)遍歷代碼
這篇文章介紹了c++ builder TreeView控件節(jié)點(diǎn)遍歷代碼,有需要的朋友可以參考一下2013-09-09