Ask Your Question

Revision history [back]

    File file = new File("infraImage_045_270.csv");
    int rows = 240;
    int cols = 320;
    double buffRes[] = new double[cols*rows]; 
    String line = "";
    int k = 0;
    try (BufferedReader br = new BufferedReader(new FileReader(file))) {
        while ((line = br.readLine()) != null) {
            String[] vpLine = line.split(",");
            for(String s : vpLine) {
                try {
                    buffRes[k] = Double.parseDouble(s);
                }catch(NumberFormatException e) {
                    buffRes[k] = -Double.MAX_VALUE;
                    System.out.println("NAN");
                }
                k++;  
            }
        }
    }
    Mat res = new Mat(rows, cols, 0);
    res.put(0, 0, buffRes);

    HighGui.imshow("Picture", res);
    HighGui.waitKey(0);
    System.exit(0);