// Write data
FileStorage fs("test.yml", FileStorage::WRITE);
fs << "MyString" << "123abc";
fs.release(); // Read data
FileStorage fs2("test.yml", FileStorage::READ);
string str = fs2["MyString"];
cout << "MyString = " << str << endl;
fs2.release();

In OpenCV, the FileStorage class can read and write data in the file. If you write the string "123abc" into the file, it will shows with quotation mark in the file. Now I want to read this string from the file into a string variable, you need to keep the quotation mark in the file which should be see as follows:

MyString: "123abc"

Now it can be read without problem, but if you change it to the followings:

MyString: 123abc

This will not gonna work this time, but if the string is not start with a number, it will work. I might treat it as a bug in the OpenCV. The three different situation is as follows:

MyString: "123abc"    // Work
MyString: 123abc // NOT work
MyString: abc123 // Work

In sum, when you want to read a string into a variable, if it starts with a number, you need to add the quotation marker to the whole string in the file.

FileStorage Read String Start With Number Need Quotation Mark 读取数字开头的字符串需要加引号的更多相关文章

  1. This sample is for changing from “float64” to “int” for values did unmarshal using map[string]interface{}. When it did unmarshal using map[string]interface{}, a number with “int” was changed to “floa

    This sample is for changing from “float64” to “int” for values did unmarshal using map[string]interf ...

  2. js或者jq的string类型或者number类型的相互转换及json对象与字符串的转换

    1.将值乘以1,将string类型转为number类型 //算合计价值function summoney(money) { var zijin = $("#main_xm_dam09&quo ...

  3. java基础知识回顾之---java String final类普通方法的应用之“按照字节截取字符串”

    /*需求:在java中,字符串“abcd”与字符串“ab你好”的长度是一样,都是四个字符.但对应的字节数不同,一个汉字占两个字节.定义一个方法,按照最大的字节数来取子串.如:对于“ab你好”,如果取三 ...

  4. java算法:统计数字-将数字转换成字符串,然后使用字符串String.valueOf()方法进行判断

    题目: 计算数字 k 在 0 到 n 中的出现的次数,k 可能是 0~9 的一个值. 样例 样例 1: 输入: k = 1, n = 1 输出: 1 解释: 在 [0, 1] 中,我们发现 1 出现了 ...

  5. 判断一个string是否以数字开头

    public static void main(String[] args) {        Pattern pattern =null;    String content = "30. ...

  6. switch case :在JDK 7中,又加入了对String类型的支持,从此不用再写If-Else来判断字符串了

    switch的case语句可以处理int,short,byte,char类型的值, 因为short,byte,char都会转换成int进行处理,这一点也可以从生成的字节码看出. char a = 'e ...

  7. Long.parseLong(String s) 其中s必须是数字形式的字符串,才能运用该函数转化为长整型。

    public class ConverTo { public static void main(String [] args) { String numberIn =args[0]; convertN ...

  8. 一道前端面试题:定义一个方法将string的每个字符串间加个空格返回,调用的方式'hello world'.spacify();

    偶然在群里看到了这道题:定义一个方法将string的每个字符串间加个空格返回,调用的方式'hello world'.spacify(); 这道题主要是对JavaScript对象原型的考察.

  9. BUGFIX 09 - 记一次Java中String的split正则表达式匹配 - 引发`OutOfMemoryError: Java heap space`的oom异常 排查及解决 -Java根据指定分隔符分割字符串,忽略在引号里面的分隔符

    问题简述 说白了,Java根据指定分隔符分割字符串,忽略在引号(单引号和双引号)里面的分隔符; oom压测的时候,正则匹配"(?=(?:[^\"]*\"[^\" ...

随机推荐

  1. Sybase IQ导出文件的几种方式

    IQ有四种方法,将表的数据导出为文本文件:1.重定向 SELECT * FROM TABLE1 ># D:MYDATATABLE1.TXT -- 文件生成在执行语句的客户端上 2.通过选项导出 ...

  2. php的socket通信(一)

    什么是TCP/IP.UDP? TCP/IP(Transmission Control Protocol/Internet Protocol)即传输控制协议/网间协议,是一个工业标准的协议集,它是为广域 ...

  3. Android实现支持缩放平移图片

    本文主要用到了以下知识点 Matrix GestureDetector 能够捕捉到长按.双击 ScaleGestureDetector 用于检测缩放的手势 自由的缩放 需求:当图片加载时,将图片在屏幕 ...

  4. 新浪SAE部署 503 JDK版本冲突解决

    上午把本地调试好的微信应用部署到SAE上,结果访问503错误.关键日志:—————————————————————————————————org.eclipse.jetty.servlet.Servl ...

  5. Android中几种定位 方式

    介绍的几种定位方式 http://www.cnblogs.com/cuihongyu3503319/p/3863867.html 百度地图api: http://lbsyun.baidu.com/in ...

  6. hdu 1010:Tempter of the Bone(DFS + 奇偶剪枝)

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  7. Java Hour 57 Java Architecture

    Java 的架构中有4个重要的组成部分: 1 Java programming langrage 2 Java class file format 3 Java API 4 Java virtual ...

  8. html select 下拉箭头隐藏

    html select 下拉箭头隐藏 <!DOCTYPE html> <html> <head lang="en"> <meta char ...

  9. Effective C++笔记:构造/析构/赋值运算

    条款05:了解C++默默编写并调用哪些函数 默认构造函数.拷贝构造函数.拷贝赋值函数.析构函数构成了一个类的脊梁,只有良好的处理这些函数的定义才能保证类的设计良好性. 当我们没有人为的定义上面的几个函 ...

  10. DEDE织梦常用的调用方法

    DEDE织梦常用的调用常规调用: 网站名称调用:<title>{dede:global.cfg_webname/}</title> 网站关键词调用:<meta name= ...