是否可以使用多个Intel D435存储动态阵列

问题描述

我正在为我的大学设计一个项目。我对c ++,opencv还是很陌生,希望您能理解我的问题(和代码)。我的项目的简短介绍:我正在使用五个Intel Realsense D435进行外部多摄像机校准。

当前,我正在尝试接收相机的第一张图像,附加一些不再重要的功能获取特征点等等。在最后一步中,我将“ NewColor”存储为“ CurrentColor”,然后再次开始循环。

首先这是我的代码

std::vector<rs2::pipeline> pipes;
rs2::device_list devices_Main = getdevices::GetDevices(ctx,pipes);
int ConDev = getdevices::deviceList.size();

....之间有一些联系,但没有一定的联系

static std::map<std::pair<std::string,std::string>,rs2::frame> collect_frames;
cv::Mat* NewDepth = new cv::Mat[ConDev]();
cv::Mat* NewColor = new cv::Mat[ConDev]();
cv::Mat* CurrentDepth = new cv::Mat[ConDev]();
cv::Mat* CurrentColor = new cv::Mat[ConDev]();


    int k = 0;
    while (waitKey(1)<0)
    {

当我在此处插入ShowVideoStream-Method时,一切都很好

*if (CurrentColor->empty() == 0)
        {
            ShowVideoStream(CurrentColor,"CurrentPics");
        }*

std::vector<rs2::frame> new_frames;
for (auto&& pipe : enabledevices::pipelines)
{
    rs2::frameset fs;

    if (pipe.poll_for_frames(&fs))
    {
        for (const rs2::frame& f : fs)
            new_frames.emplace_back(f);         
    }
}

for (const auto& frame : new_frames)
{
    auto serial = rs2::sensor_from_frame(frame)->get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);
    collect_frames[std::make_pair(serial,frame.get_profile().stream_name())] = frame;
}

int n = 0;
for (size_t d = 0; d < collect_frames.size(); d++)
{
    auto dt = collect_frames.begin();
    std::advance(dt,d);


    rs2::frame pic;

    if (dt->first.second == STREAM)
    {
        pic = dt->second;
        
         images[t] = cv::Mat(Size(enabledevices::getWidth(pic),enabledevices::getHeigth(pic)),arraytype,(void*)pic.get_data(),Mat::AUTO_STEP);

        if (STREAM == "Color")
        {
            cv::cvtColor(images[t],images[t],COLOR_BGR2RGB);
        }
}

但是在这里绘制我的ShowVideoStream-方法时,出现错误:引发异常:读取访问冲突“ ptr”为“ 0x5A64760”。注意:NewColor-Print可在所有位置打印

ShowVideoStream(NewColor,"NewPics");
*if (CurrentColor->empty() == 0)
        {
            
            imagecontainer::ShowVideoStream(CurrentColor,"CurrentPics");
        }*
        n++;
    }

在这里将NewColor的地址赋予CurrentColor

CurrentColor = NewColor;

}

... ShowVideoStream是我显示各种流的功能。该代码可以在下面看到:

void ShowVideoStream(cv::Mat* Pics,const std::string& winname)
{
for (size_t t = 0; t < getdevices::deviceList.size(); t++)
{
    std::stringstream sstm;
    sstm << winname << t;
    std::string result = sstm.str();

    imshow(result,Pics[t]);
}
}

也许您可以帮助我解决我的问题。我的这个错误的Google研究导致缺少初始化,我认为这不是问题。我也可以更改代码,但是我认为这是一种聪明的方法

很抱歉格式错误。复制相关地点并非易事

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)