Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从yaml文件访问opencv对象_Java_Opencv_Yaml_Javacv - Fatal编程技术网

Java 从yaml文件访问opencv对象

Java 从yaml文件访问opencv对象,java,opencv,yaml,javacv,Java,Opencv,Yaml,Javacv,以下代码用于在java中读取.yaml文件。实际上,我想把文件值解析成一个映射,并访问它的值 public static void main(String[] args) { // The path of your YAML file. final String fileName = "test.yml"; ArrayList<String> key = new ArrayList<String>(); ArrayLis

以下代码用于在java中读取.yaml文件。实际上,我想把文件值解析成一个映射,并访问它的值

    public static void main(String[] args) {
    // The path of your YAML file.
    final String fileName = "test.yml";      
    ArrayList<String> key = new ArrayList<String>();
    ArrayList<String> value = new ArrayList<String>();
    ArrayList<Object> obj = new ArrayList<Object>();
    opencvmatrix ob = new opencvmatrix();
    Yaml yaml = new Yaml();

    try {
        InputStream ios = new FileInputStream(new File(fileName));
        // Parse the YAML file and return the output as a series of Maps and Lists
        Map< String, Object> result = (Map< String, Object>) yaml.load(ios);
        for (Object name : result.keySet()) {   
            key.add(name.toString());
            obj.add(result.get(name));   
        }     
    } catch (Exception e) {
        e.printStackTrace();
    }     
     System.out.println(key + " " + obj.get(0).getClass());

}

我怎么能找到那个女地址

我的问题通过创建opencvmatrix类并将其对象强制转换为地图内的返回对象来解决:

 public static void main(String[] args) {
    // The path of your YAML file.
    final String fileName = "test.yml";
    ArrayList<String> key = new ArrayList<String>();
    ArrayList<String> value = new ArrayList<String>();
    ArrayList<Object> obj = new ArrayList<Object>();
    ArrayList<Object> objected = new ArrayList<Object>();
    opencvmatrix obj1 = new opencvmatrix();
    opencvmatrix obj2 = new opencvmatrix();
    opencvmatrix obj3 = new opencvmatrix();
    opencvmatrix obj4 = new opencvmatrix();
    opencvmatrix obj5 = new opencvmatrix();
    ArrayList<opencvmatrix> objects = new ArrayList<opencvmatrix>();
    Yaml yaml = new Yaml();

    try {
        InputStream ios = new FileInputStream(new File(fileName));
        // Parse the YAML file and return the output as a series of Maps and Lists
        Map< String, Object> result = (Map< String, Object>) yaml.load(ios);
        for (Object name : result.keySet()) {
            key.add(name.toString());
            obj.add(result.get(name));                
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

        obj1 =(opencvmatrix)(obj.get(0));
        obj2 =(opencvmatrix)(obj.get(1));
        obj3 =(opencvmatrix)(obj.get(2));
        objected.add((obj.get(3)));
        obj4 =(opencvmatrix)(obj.get(4));

        for (int i = 0; i < 3600; i++) {
            for (int j = 0; j < 19; j++) {

                System.out.print(obj3.data.get(i*j));
            }
            System.out.println();

        }



}
publicstaticvoidmain(字符串[]args){
//YAML文件的路径。
最终字符串fileName=“test.yml”;
ArrayList键=新的ArrayList();
ArrayList值=新的ArrayList();
ArrayList obj=新的ArrayList();
ArrayList objected=新的ArrayList();
opencvmatrix obj1=新的opencvmatrix();
opencvmatrix obj2=新的opencvmatrix();
opencvmatrix obj3=新的opencvmatrix();
opencvmatrix obj4=新的opencvmatrix();
opencvmatrix obj5=新的opencvmatrix();
ArrayList对象=新的ArrayList();
Yaml Yaml=新的Yaml();
试一试{
InputStream ios=新文件InputStream(新文件(文件名));
//解析YAML文件并将输出作为一系列映射和列表返回
Mapresult=(Map)yaml.load(ios);
for(对象名称:result.keySet()){
key.add(name.toString());
obj.add(result.get(name));
}
}捕获(例外e){
e、 printStackTrace();
}
obj1=(opencvmatrix)(obj.get(0));
obj2=(opencvmatrix)(obj.get(1));
obj3=(opencvmatrix)(obj.get(2));
objected.add((obj.get(3));
obj4=(opencvmatrix)(obj.get(4));
对于(int i=0;i<3600;i++){
对于(int j=0;j<19;j++){
System.out.print(obj3.data.get(i*j));
}
System.out.println();
}
}
 public static void main(String[] args) {
    // The path of your YAML file.
    final String fileName = "test.yml";
    ArrayList<String> key = new ArrayList<String>();
    ArrayList<String> value = new ArrayList<String>();
    ArrayList<Object> obj = new ArrayList<Object>();
    ArrayList<Object> objected = new ArrayList<Object>();
    opencvmatrix obj1 = new opencvmatrix();
    opencvmatrix obj2 = new opencvmatrix();
    opencvmatrix obj3 = new opencvmatrix();
    opencvmatrix obj4 = new opencvmatrix();
    opencvmatrix obj5 = new opencvmatrix();
    ArrayList<opencvmatrix> objects = new ArrayList<opencvmatrix>();
    Yaml yaml = new Yaml();

    try {
        InputStream ios = new FileInputStream(new File(fileName));
        // Parse the YAML file and return the output as a series of Maps and Lists
        Map< String, Object> result = (Map< String, Object>) yaml.load(ios);
        for (Object name : result.keySet()) {
            key.add(name.toString());
            obj.add(result.get(name));                
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

        obj1 =(opencvmatrix)(obj.get(0));
        obj2 =(opencvmatrix)(obj.get(1));
        obj3 =(opencvmatrix)(obj.get(2));
        objected.add((obj.get(3)));
        obj4 =(opencvmatrix)(obj.get(4));

        for (int i = 0; i < 3600; i++) {
            for (int j = 0; j < 19; j++) {

                System.out.print(obj3.data.get(i*j));
            }
            System.out.println();

        }



}