Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

the image you're trying to encode was never loaded / is empty() !

please add a check after the imread() call:

String file = "C:/EXAMPLES/OpenCV/sample.jpg"; 
Mat image = Imgcodecs.imread(file); 
if (image.empty() {
      // can't go on !
}

the image you're trying to encode was never loaded / is empty() !

please add a check after the imread() call:

String file = "C:/EXAMPLES/OpenCV/sample.jpg"; 
Mat image = Imgcodecs.imread(file); 
if (image.empty() (image.empty()) {
      // can't go on !
}