#Region Base #AutoIt3Wrapper_UseX64=y #include "autoit_opencv_com-4.5.4\udf\opencv_udf_utils.au3" _OpenCV_Open_And_Register(_OpenCV_FindDLL("opencv_world4*", Default, "opencv-4.5.4"), _OpenCV_FindDLL("autoit_opencv_com4*", Default, "autoit_opencv_com-4.5.4")) #EndRegion Base Local $cv = _OpenCV_get() If IsObj($cv) Then Local $img1 = $cv.imread("pic\strawberry.jpg", $CV_IMREAD_UNCHANGED) ;$cv.imshow('$img1', $img1) $brows = $img1.rows $bcols = $img1.cols Local $img2 = $cv.imread("pic\Lena.png", $CV_IMREAD_UNCHANGED) ;$cv.imshow('$img2', $img2) $rows = $img2.rows $cols = $img2.cols $img2gray = $cv.cvtColor($img2, $CV_COLOR_RGB2GRAY) $cv.threshold($img2gray, 10, 255, $CV_THRESH_BINARY) $mask = $cv.extended[1] $mask_inv = $cv.bitwise_not($mask) ;$cv.imshow('mask_inv', $mask_inv) Local $rect[4] = [($bcols-$cols)/2, ($brows-$rows)/2, $cols, $rows] $roi = ObjCreate("OpenCV.cv.Mat").create($img1, $rect) $img1_bg = $cv.bitwise_and($roi, $roi, $mask_inv) ;$cv.imshow('$img1_bg', $img1_bg) $img2_fg = $cv.bitwise_and($img2, $img2, $mask) ;$cv.imshow('$img2_fg', $img2_fg) $dst = $cv.add($img1_bg, $img2_fg) $dst.copyTo($roi) $cv.imshow('$img1', $img1) $cv.waitKey() EndIf _OpenCV_Unregister_And_Close()