OpenCV_MergeTwoImage.java
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Rect;
import org.opencv.imgcodecs.Imgcodecs;
public class OpenCV_MergeTwoImage {
public static void main( String[] args )
{
try{
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
Mat source = Imgcodecs.imread("D:\\projects\\Java\\OpenCV_Samples\\resource\\imgs\\ncku.jpg ",Imgcodecs.CV_LOAD_IMAGE_COLOR);
Mat source1 = Imgcodecs.imread("D:\\projects\\Java\\OpenCV_Samples\\resource\\imgs\\jelly_studio_logo.jpg ",Imgcodecs.CV_LOAD_IMAGE_COLOR);
Mat destination=source.clone();
//Imgproc.resize
Rect roi=new Rect(50,50,90,62);
Mat destinationROI = source.submat( roi );
source1.copyTo( destinationROI , source1);
Imgcodecs.imwrite("D:\\projects\\Java\\OpenCV_Samples\\resource\\imgs\\merge2.jpg ", source);
}catch (Exception e) {
System.out.println("error: " + e.getMessage());
}
}
}
Recommended Posts