Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2017-04-20 11:26:59 -0600

Nbb gravatar image

why cant i read this yaml file ?

How do i read this yaml file into an opencv matrix ? It always prints an empty matrix.

cv::Mat dx;
cv::FileStorage fs;
fs.open("C:\\Users\\Documents\\Visual Studio 2015\\Projects\\UCM\\x64\\Release\\farid_x.yaml", cv::FileStorage::READ);
fs["data"] >> dx;
cout << dx;;

It always prints an empty matrix [].

%YAML:1.0
    dx: !!opencv-matrix
        rows: 9
        cols: 9
        dt: f
        data: [ 0.000003, 0.000048, 0.000282, 
            0.000744, 0.001015, 0.000744, 0.000282, 
            0.000048, 0.000003, 0.000032, 0.000530, 
            0.003114, 0.008213, 0.011194, 0.008213, 
            0.003114, 0.000530, 0.000032, 0.000109, 
            0.001802, 0.010595, 0.027946, 0.038087, 
            0.027946, 0.010595, 0.001802, 0.000109, 
            0.000134, 0.002208, 0.012985, 0.034251, 
            0.046681, 0.034251, 0.012985, 0.002208, 
            0.000134, 0.000000, 0.000000, 0.000000, 
            0.000000, 0.000000, 0.000000, 0.000000, 
            0.000000, 0.000000, -0.000134, -0.002208, 
            -0.012985, -0.034251, -0.046681, -0.034251, 
            -0.012985, -0.002208, -0.000134, -0.000109, 
            -0.001802, -0.010595, -0.027946, -0.038087, 
            -0.027946, -0.010595, -0.001802, -0.000109, 
            -0.000032, -0.000530, -0.003114, -0.008213, 
            -0.011194, -0.008213, -0.003114, -0.000530, 
            -0.000032, -0.000003, -0.000048, -0.000282, 
            -0.000744, -0.001015, -0.000744, -0.000282, 
            -0.000048, -0.000003]