我想讀取視頻文件,但它的拋出錯誤。 的代碼是:無法讀取視頻在opencv
#include <iostream>
#include <opencv/highgui.h>
#include <opencv/cv.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char* argv[])
{
Mat inputVideo;
Mat frame;
Mat HSV;
Mat tracking;
char checkKey;
VideoCapture capture;
capture.open("video/input.mp4");
capture.set(CV_CAP_PROP_FRAME_WIDTH, 640);
capture.set(CV_CAP_PROP_FRAME_HEIGHT,480);
namedWindow("Original Video", WINDOW_AUTOSIZE);
while(1){
capture.read(inputVideo);
if (!inputVideo.empty())
{
imshow("Original Video",inputVideo);
}
waitKey(20);
}
return 0;
}
在運行這段代碼,我得到的錯誤是:
無法停止流:用於設備不適當的ioctl
(video_reading:3459): GLib-GObject-CRITICAL **:g_object_set: 斷言'G_IS_OBJECT(object)'失敗
我試過尋找解決方案,但我沒有得到它。有人能幫我解決這個錯誤嗎?
可能是ffmpeg錯誤。嘗試使用cmake再次構建 – Anirudh
@Ran是否使用Gstreamer構建'opencv'? –
我不知道什麼是gstreamer。我不得不使用建立的OpenCV以下命令的cmake -D CMAKE_BUILD_TYPE = RELEASE -D CMAKE_INSTALL_PREFIX =的/ usr /本地-D WITH_TBB = ON -D BUILD_NEW_PYTHON_SUPPORT = ON -D WITH_V4L = ON -D INSTALL_C_EXAMPLES = ON -D INSTALL_PYTHON_EXAMPLES = ON -D BUILD_EXAMPLES = ON -D WITH_QT = ON -D WITH_OPENGL = ON -D OPENCV_EXTRA_MODULES_PATH = ../../opencv_contrib /模塊-D PYTHON_EXECUTABLE =的/ usr /斌/ python3 -D WITH_CUDA = ON -D WITH_FFMPEG = ON -D ENABLE_FAST_MATH = 1 - d CUDA_FAST_MATH = 1 -D WITH_CUBLAS = 1 .. – Ran