OPENCV C++损坏的双连锁列表

发布于 2025-02-04 15:14:40 字数 3880 浏览 2 评论 0原文

我正在尝试从多个摄像机中获取FPS。这是主要的:

int main(int argc, char* argv[])
{
    //Load all cameras IP
    map<string, string> camerasIp; //camera ID and Streaming URL
    LoadConfig(&camerasIp);

    //Get FPS of all cameras
    map<string,string>::iterator it_cam;

    while(true)
    {
        for(it_cam = camerasIp.begin(); it_cam != camerasIp.end(); ++it_cam)
        {
            GetCamFps(it_cam->second);
        }

        cout << "" << endl;
    }

    //Send FPS to server
    ...

    return 0;
}

这是getCamfps方法:

void GetCamFps(string url)
{
    cout << "VideoCapture" << endl;
    VideoCapture video(url);

    cout << "Get frames" << endl;
    double fps = video.get(CAP_PROP_FPS);
    cout <<"Frames: " << fps << endl;

    video.release();
}

这是退出:

VideoCapture
Get frames
Frames: 30
VideoCapture
corrupted double-linked list
Aborted (core dumped)

我尝试添加睡眠以在打开一个URL和另一个URL之间让一些时间,但无法正常工作。我检查了地图,这是正确的。

当我评论该方法中的两个第一个cout时,它可以正常工作,但是过了一会儿,它再次失败。

GDB带有backtrace的输出:

Thread 1 "Fps_Monitoring" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) backtrace
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff51cc801 in __GI_abort () at abort.c:79
#2  0x00007ffff5215897 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff5342b9a "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3  0x00007ffff521c90a in malloc_printerr (str=str@entry=0x7ffff5340cba "corrupted double-linked list") at malloc.c:5350
#4  0x00007ffff521cac4 in malloc_consolidate (av=av@entry=0x7ffff5577c40 <main_arena>) at malloc.c:4456
#5  0x00007ffff52207d8 in _int_malloc (av=av@entry=0x7ffff5577c40 <main_arena>, bytes=bytes@entry=1600) at malloc.c:3703
#6  0x00007ffff52214eb in _int_memalign (av=0x7ffff5577c40 <main_arena>, alignment=64, bytes=<optimized out>) at malloc.c:4694
#7  0x00007ffff5226fba in _mid_memalign (address=<optimized out>, bytes=1496, alignment=<optimized out>) at malloc.c:3314
#8  __posix_memalign (memptr=0x7fffffffdad0, alignment=<optimized out>, size=1496) at malloc.c:5369
#9  0x00007ffff028e7e3 in av_malloc () from /usr/local/lib/libavutil.so.56
#10 0x00007ffff06b253b in avformat_alloc_context () from /usr/local/lib/libavformat.so.58
#11 0x00007ffff5f8b9a3 in CvCapture_FFMPEG::open(char const*) () from /usr/local/lib/libopencv_videoio.so.4.2
#12 0x00007ffff5f8e9ff in cv::cvCreateFileCapture_FFMPEG_proxy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
   from /usr/local/lib/libopencv_videoio.so.4.2
#13 0x00007ffff5f71566 in cv::StaticBackend::createCapture(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const ()
   from /usr/local/lib/libopencv_videoio.so.4.2
#14 0x00007ffff5f4cc17 in cv::VideoCapture::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) ()
   from /usr/local/lib/libopencv_videoio.so.4.2
#15 0x00007ffff5f4f595 in cv::VideoCapture::VideoCapture(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) ()
   from /usr/local/lib/libopencv_videoio.so.4.2
#16 0x000055555555f9b3 in GetCamFps(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) ()
#17 0x000055555555d5df in main ()

任何想法,为什么第二个视频帕特尔不起作用?

谢谢。

I'm trying to get the fps from multiple cameras. This is the main:

int main(int argc, char* argv[])
{
    //Load all cameras IP
    map<string, string> camerasIp; //camera ID and Streaming URL
    LoadConfig(&camerasIp);

    //Get FPS of all cameras
    map<string,string>::iterator it_cam;

    while(true)
    {
        for(it_cam = camerasIp.begin(); it_cam != camerasIp.end(); ++it_cam)
        {
            GetCamFps(it_cam->second);
        }

        cout << "" << endl;
    }

    //Send FPS to server
    ...

    return 0;
}

This is the GetCamFps method:

void GetCamFps(string url)
{
    cout << "VideoCapture" << endl;
    VideoCapture video(url);

    cout << "Get frames" << endl;
    double fps = video.get(CAP_PROP_FPS);
    cout <<"Frames: " << fps << endl;

    video.release();
}

And this is the exit:

VideoCapture
Get frames
Frames: 30
VideoCapture
corrupted double-linked list
Aborted (core dumped)

I tried adding a sleep to let some time between opening one url and another but didn't works. I checked the map and it's correct.

When I comment the two firsts cout in the method it works but after a while it fail again.

Output of gdb with backtrace:

Thread 1 "Fps_Monitoring" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) backtrace
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff51cc801 in __GI_abort () at abort.c:79
#2  0x00007ffff5215897 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff5342b9a "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3  0x00007ffff521c90a in malloc_printerr (str=str@entry=0x7ffff5340cba "corrupted double-linked list") at malloc.c:5350
#4  0x00007ffff521cac4 in malloc_consolidate (av=av@entry=0x7ffff5577c40 <main_arena>) at malloc.c:4456
#5  0x00007ffff52207d8 in _int_malloc (av=av@entry=0x7ffff5577c40 <main_arena>, bytes=bytes@entry=1600) at malloc.c:3703
#6  0x00007ffff52214eb in _int_memalign (av=0x7ffff5577c40 <main_arena>, alignment=64, bytes=<optimized out>) at malloc.c:4694
#7  0x00007ffff5226fba in _mid_memalign (address=<optimized out>, bytes=1496, alignment=<optimized out>) at malloc.c:3314
#8  __posix_memalign (memptr=0x7fffffffdad0, alignment=<optimized out>, size=1496) at malloc.c:5369
#9  0x00007ffff028e7e3 in av_malloc () from /usr/local/lib/libavutil.so.56
#10 0x00007ffff06b253b in avformat_alloc_context () from /usr/local/lib/libavformat.so.58
#11 0x00007ffff5f8b9a3 in CvCapture_FFMPEG::open(char const*) () from /usr/local/lib/libopencv_videoio.so.4.2
#12 0x00007ffff5f8e9ff in cv::cvCreateFileCapture_FFMPEG_proxy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
   from /usr/local/lib/libopencv_videoio.so.4.2
#13 0x00007ffff5f71566 in cv::StaticBackend::createCapture(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const ()
   from /usr/local/lib/libopencv_videoio.so.4.2
#14 0x00007ffff5f4cc17 in cv::VideoCapture::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) ()
   from /usr/local/lib/libopencv_videoio.so.4.2
#15 0x00007ffff5f4f595 in cv::VideoCapture::VideoCapture(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) ()
   from /usr/local/lib/libopencv_videoio.so.4.2
#16 0x000055555555f9b3 in GetCamFps(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) ()
#17 0x000055555555d5df in main ()

Any idea why the second videocapture doesn't work?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文