Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is Java Imgcodecs.imwrite implemented in OpenCV 3.4.0?

I am trying to put an image on the screen with Imgcodecs.imwrite But, I get the error message

OpenCV Error: Unspecified error (could not find a writer for the specified extension) in cv::imwrite_, file C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\imgcodecs\src\loadsave.cpp, line 677 Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\imgcodecs\src\loadsave.cpp:677: error: (-2) could not find a writer for the specified extension in function cv::imwrite_ ] at org.opencv.imgcodecs.Imgcodecs.imwrite_1(Native Method) at org.opencv.imgcodecs.Imgcodecs.imwrite(Imgcodecs.java:197) at myfirstPackage.HelloCV5.main(HelloCV5.java:27)

Other commands work fine, but Imcodecs.imwrite gives me errors about C++ The code follows ...

package myfirstPackage;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.imgcodecs.Imgcodecs;

public class HelloCV5 {
    public static void main(String[] args){
            System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
            Mat mat = Mat.eye(3, 3, CvType.CV_8UC1);
            System.out.println("mat = " + mat.dump());
            System.out.println("mat = " + mat.dump());
            System.out.println("Class/Program HelloCV5");
            Mat src;
            src = Imgcodecs.imread("lena.jpg", Imgcodecs.IMREAD_COLOR);
            src = Imgcodecs.imread("lena.jpg", Imgcodecs.IMREAD_COLOR);
            System.out.println("Point 1");
            Imgcodecs.imwrite( "Window Name Literal", src );
            System.out.println("Point 2");
            System.out.println("1/27/2018");
            }
}