Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

imread in iOS

Hi all, I'm working with OpenCV 2.4.3 in iOS. I want to read an image, so I use imread() function, but result Mat image is always empty.

    NSString *nsFileName = [destPath stringByAppendingPathComponent:imgSVMList[i]];
    std::string fileName = std::string([nsFileName UTF8String]);
    img = imread(fileName,CV_LOAD_IMAGE_GRAYSCALE);
    if (!img.data) {
        NSLog(@"Errore nella lettura dell'immagine");
    } else {
        NSLog(@"Rows: %i; Cols: %i",img.rows,img.cols);
    }

destPath is a Documets subfolder (/Documents/ImgSVM/) and imgSVMLista[] is a vector with images filename. So, nsFileName is, for example, <...>/Documents/ImgSVM/Img1.jpg. Well, img is alway empty.

image description

As you can see rows and cols are 0. This is an example of image I want to read:

image description

Any suggestion? Costantino

imread in iOS

Hi all, I'm working with OpenCV 2.4.3 in iOS. I want to read an image, so I use imread() function, but result Mat image is always empty.

    NSString *nsFileName = [destPath stringByAppendingPathComponent:imgSVMList[i]];
    std::string fileName = std::string([nsFileName UTF8String]);
    img = imread(fileName,CV_LOAD_IMAGE_GRAYSCALE);
    if (!img.data) {
        NSLog(@"Errore nella lettura dell'immagine");
    } else {
        NSLog(@"Rows: %i; Cols: %i",img.rows,img.cols);
    }

destPath is a Documets subfolder (/Documents/ImgSVM/) and imgSVMLista[] is a vector with images filename. So, nsFileName is, for example, <...>/Documents/ImgSVM/Img1.jpg. Well, img is alway empty.

image descriptionimage description

image description

As you can see rows and cols are 0. 0 (The screenshot of the log was taken after the reading of the image). This is an example of image I want to read:

image description

Any suggestion? Costantino