微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么OpenCV会为此代码发出“未知功能中的错误标志”?

如何解决为什么OpenCV会为此代码发出“未知功能中的错误标志”?

| 我一直在尝试使用Open CV API使真正的基本视频播放器正常工作。一切似乎都能顺利进行,直到视频剪辑结束,然后出现此错误: OpenCV错误:未知函数文件........ \\ ocv \\ opencv \\ modules \\ core \\ src \\ array.cpp中的错误标志 这在imshow(\“ video \”,frame)的代码中产生了一个中断,我发现这很奇怪,因为这是有效播放视频的部分,所以为什么它只在剪辑的结尾大惊小怪?我发现似乎在我播放的每个视频的最后90%中都给了我这个错误,所以目前我通过告诉它一旦播放了90%的剪辑就停止了它,从而解决了这个问题,但这不是很好的编程方式,所以任何人都可以发送一些建议/帮助? 我看过有关此事的其他人的帖子,到目前为止,所建议的解决方案还没有对我有用。 这是我的代码...它只是一个实验性的部分,如果有点杂乱,对不起: 感谢您的任何帮助
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <direct.h>
#include <iostream>

using namespace cv;

void onTrackBarSlide(int);

double the_next_play_frame;

VideoCapture video(\"test.MOV\"); // open the video file

int main(int,char**)
{

if(!video.isOpened())  // check if we succeeded
{
    return -1;
}

int no_of_frames =  video.get(CV_CAP_PROP_FRAME_COUNT); //total number of frames in       video

std::cout << no_of_frames << std::endl;

std::cout << video.get(CV_CAP_PROP_FPS) << std::endl;

namedWindow(\"Video\",1);
cvCreateTrackbar(\"trackbar\",\"Video\",40,onTrackBarSlide);

double stop_at = no_of_frames * 0.999;
    for(;;){



    if(the_next_play_frame >= double(stop_at))
    {
        break;
    }

     Mat frame;
    video >> frame; // get a new frame from camera  

    imshow(\"Video\",frame); // <---------- place where break/error occurs   

    if(waitKey(30) >= 0) 
    {
        break;
    }


}

return 0;
}

void onTrackBarSlide(int pos)
{
std::cout << getTrackbarPos(\"trackbar\",\"Video\") << std::endl;

double frameratio = video.get(CV_CAP_PROP_FRAME_COUNT)/40; //10005 is the maximum   value the slider can actual hold

double next_play_frame = frameratio * getTrackbarPos(\"trackbar\",\"Video\");
video.set(CV_CAP_PROP_POS_FRAMES,next_play_frame);

the_next_play_frame = next_play_frame;

}
    

解决方法

        
VideoCapture video(\"test.MOV\"); // open the video file

int main(int,char**)
{

if(!video.isOpened())  // check if we succeeded
{
    return -1;
}
}
尝试将VideoCapture实例化放入main中。
int main(){
 VideoCapture video(\"test.MOV\"); // open the video file

...
}
    

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。