[JAVA] Desktop: OpenCV Find Transform ECC

Goal
Test OpenCV find transform ECC.

OpenCV_FindTransformECC.java


import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.TermCriteria;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
import org.opencv.video.Video;


public class OpenCV_FindTransformECC {
    static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }

    public static void main(String[] args) {

        Mat templste = Imgcodecs.imread("D:\\projects\\Java\\OpenCV_Samples\\resource\\imgs\\DSC_0675.jpg ",Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
        Mat needToBeAdjusted = Imgcodecs.imread("D:\\projects\\Java\\OpenCV_Samples\\resource\\imgs\\DSC_0663.jpg ",Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);


        //Definition motion model warp matrix
        Mat warp_matrix2=Mat.eye(2, 3, CvType.CV_32F);

        int maxIterations=5000;
        Mat mask=new Mat();

        //Enforced ECC algorithm. Result Pregnant warp matrix
        Video.findTransformECC(templste, needToBeAdjusted, warp_matrix2,Video.MOTION_EUCLIDEAN,new TermCriteria(TermCriteria.COUNT | TermCriteria.EPS, maxIterations, 1E-10),mask);
        Mat aligned=new Mat();

        //for  Euclidean and Affine
        Imgproc.warpAffine(needToBeAdjusted, aligned, warp_matrix2, templste.size(),Imgproc.INTER_LINEAR+Imgproc.WARP_INVERSE_MAP);
        Imgcodecs.imwrite("D:\\projects\\Java\\OpenCV_Samples\\resource\\imgs\\findTransformECC2.jpg ",aligned);
    }
}
Result
![DSC_0675.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/276243/4d17afd5-c2a7-83ae-ba5b-fe7da3baa318.jpeg) ![DSC_0663.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/276243/8c5f1b76-ff50-f954-ac6f-6909ed66e512.jpeg) ![findTransformECC2.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/276243/3b0222ad-0d19-3105-e5f0-617ee33f808e.jpeg)

Recommended Posts

Desktop: OpenCV Find Transform ECC
Desktop: OpenCV BilateralFilterBlur
Desktop: OpenCV Dilate
Desktop: OpenCV Expand
Desktop: OpenCV Affine
Desktop: OpenCV Emboss
Desktop: OpenCV CLAHE
Desktop: OpenCV Ellipse2Poly
Desktop: OpenCV HDR
Desktop: OpenCV Polylines
Desktop: OpenCV Denoise
Desktop: OpenCV Sharpness
Desktop: OpenCV Concat
Desktop: OpenCV OpenCV_SalonUseBlurAddWeighted
Desktop: OpenCV Mosaic
Desktop: OpenCV Erode
Desktop: OpenCV Denoise
Desktop: OpenCV Find Chessboard Corners By WebCam
Desktop: OpenCV Rectangle
Desktop: OpenCV Watershed
Desktop: OpenCV Text
Desktop: OpenCV Inpaint
Desktop: OpenCV NormalizeBlur
Desktop: OpenCV StereoSGBM
Desktop: OpenCV Find Chessboard Corners By WebCam
Desktop: OpenCV Spot
Desktop: OpenCV Canny
Desktop: OpenCV Denoise3
Desktop: OpenCV Histogram
Desktop: OpenCV Dft
Desktop: OpenCV Decolor
Desktop: OpenCV FaceDetector
Desktop: OpenCV Denoise2
Desktop: OpenCV StereoBM
Desktop: OpenCV Kirsch Filter
Desktop: OpenCV Laplacian Filter 2
Desktop: OpenCV Illumination Change
Desktop: OpenCV Add WaterMark
Desktop: OpenCV Sharpness Gui
Desktop: OpenCV Color Change
Desktop: OpenCV Freichennel Filter
Desktop: OpenCV Adaptive Threshold
Desktop: OpenCV Draw Circle
Desktop: OpenCV Fill Poly
Desktop: OpenCV Mean Filter
Desktop: OpenCV Java Repository
Desktop: OpenCV Sobel Filter2
Desktop: OpenCV pyrMeanShift Filter
Desktop: OpenCV OpticalFlow PyrLK
Desktop: OpenCV Virtual Piano
Desktop: OpenCV merge Picture
Desktop: OpenCV Scharr Filter
Desktop: Opencv webcam preview
Desktop: OpenCV Laplacian Filter
Desktop: OpenCV Median Blur
Desktop: OpenCV Add Broad
Desktop: OpenCV Robinson Filter
Desktop: OpenCV record video
Desktop: OpenCV Texture Flatting
Desktop: OpenCV Flood Fill
Desktop: OpenCV color space