Quotation marks surrounding string during writing to file with OpenCV FileStorage

  • Hi Everybody
    My problem are quotation marks during writing to file. The code is

    cv::FileStorage fs(outputname.toStdString(), cv::FileStorage::WRITE);
    std::string str="test";
    fs << str.c_str();

    In file I got "test", but what I want is just test without quotations marks. Can anybody give me a hand?

    best regards

  • Hi
    Actually I found solution, but I'm not sure why it solved problem ?

        cv::FileStorage fs(outputname.toStdString(), cv::FileStorage::WRITE);
        fs << "imagelist" << "[";
        // This doesn't work for me, put quotes
        // std::string str=imagesList.join(" ").toStdString().c_str();
        // I tried that but it doesn't help
        // str.erase(str.begin(),str.end()-(str.length()-1));
        // fs << str.c_str();
        // Finally iterator solved problem
        QStringList::const_iterator constIterator;
             for (constIterator = imagesList.constBegin(); constIterator != imagesList.constEnd(); ++constIterator)
                 fs << (*constIterator).toLocal8Bit().constData();
        fs << "]";

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.