Ask Your Question

CvMlData read_csv in java

asked 2013-12-27 05:31:10 -0500

DonCossack gravatar image


I would like to ask how to read the csv file in java environment? As the opencv docs said, we can use CvMldata read_csv(), it is available for both C/C++ and Python. However, I searched on the docs for java, there is not the equivalent.

Any suggestions, if you please?

I would like to add the database for my feature matching algorithm.


edit retag flag offensive close merge delete


"it is available for both C/C++ and Python" - where did you find that ? it does not seem to be wrapped for any scripting. i don't think, you can use it from java.

berak gravatar imageberak ( 2013-12-27 06:05:38 -0500 )edit

Well it seems so..

Do you have any suggestion on the alternative method?

The purpose is to construct a training set database so that I can apply the matching algorithm on the input.

DonCossack gravatar imageDonCossack ( 2013-12-27 07:09:56 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2020-09-17 14:35:17 -0500

JojoF gravatar image
    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;
    Mat res = new Mat(rows, cols, 0);
    res.put(0, 0, buffRes);

    HighGui.imshow("Picture", res);
edit flag offensive delete link more

Question Tools


Asked: 2013-12-27 05:31:10 -0500

Seen: 174 times

Last updated: Dec 27 '13