Ask Your Question

Revision history [back]

imread fail reading jpg image

Hi all I'm new in CV and I'm trying to execute the calibration example in folder ../opencv/samples/cpp but it doesn't work! My system is: Ubuntu 14.04 Lts and opencv 3.1.0 As a test images I'm using the ones in folder ../opencv/samples/data named leftxx.jpg To trace the activity I introduced a little changes in function "main" in calibration.cpp file, as reported here below.

    if( capture.isOpened() )
    {
        Mat view0;
        capture >> view0;
        view0.copyTo(view);
    }
    else if( i < (int)imageList.size() ) {
    printf("TMP MPa: 001 Reading image: %d\n", i);
        view = imread(imageList[i], 1);
    printf("TMP MPa: Image dims = %d; Image Rows = %d; Image Cols = %d;\n", view.dims, view.rows, view.cols);
}

    if(view.empty()) 
{
    printf("TMP MPa: 002.01: Empty image read\n");
        if( imagePoints.size() > 0 )
            runAndSave(outputFilename, imagePoints, imageSize,
                       boardSize, pattern, squareSize, aspectRatio,
                       flags, cameraMatrix, distCoeffs,
                       writeExtrinsics, writePoints);
        break;
    }
else {
    printf("TMP MPa: 002.02: Correct image read\n");
}

Executing the code by the following command

/opt/opencv/samples/cpp/cpp-example-CalibrationMauro -w=9 -h=6 -s=0.025 -o=/ntfs/Progetti/VR0/CV/CameraCalibTestImages/CamParams.yml -op -oe /ntfs/Progetti/VR0/CV/CameraCalibTestImages/TestImageList.xml

I obtain the following wrong result

TMP MPa: 001 Reading image: 0

TMP MPa: Image dims = 2; Image Rows = 480; Image Cols = 640;

TMP MPa: 002.02: Correct image read

TMP MPa:003: switch

TMP MPa: 004 CHESSBOARD

TMP MPa: 001 Reading image: 1

TMP MPa: Image dims = 0; Image Rows = 0; Image Cols = 0;

TMP MPa: 002.01: Empty image read

RMS error reported by calibrateCamera: 0.163928

Calibration succeeded. avg reprojection error = 0.16

It seems to read only the first image of the list, not all. But all images can be visualized by a viewer tool or read and showed by Matlab imread function!!

Can somebody help me please?

Thank you very much for your help

Mauro