Esempio n. 1
0
from util.blending_average import blending_average
from util.draw import Draw
from util.gradient import calclulate_gradient, calculate_gradient_graph, gradient_gradient
from util.image_info import Image_info
import optimization
import texture_mapping

from util.triangle_similar import get_triangle_coefficient

if __name__ == '__main__':
    src = cv2.imread("image/DSC00318.JPG")
    dst = cv2.imread("image/DSC00319.JPG")
    cv2.imshow("src", src)
    cv2.imshow("dst", dst)

    match = Match(src, dst)
    match.getInitialFeaturePairs()
    src_point = match.src_match
    dst_point = match.dst_match

    draw = Draw()
    H, no = cv2.findHomography(src_point, dst_point)
    img_info = Image_info()
    img_info.get_final_size(src, dst, H)

    # TODO stitching tow image by global homography, the fusion methed is feathering
    src_warp = cv2.warpPerspective(src, H, (img_info.width, img_info.height))
    dst_warp = np.zeros_like(src_warp)
    dst_warp[img_info.offset_y:dst.shape[0] + img_info.offset_y,
             img_info.offset_x:dst.shape[1] +
             img_info.offset_x, :] = dst[:, :, :]
Esempio n. 2
0
from util.blending_average import blending_average
from util.draw import Draw
from util.gradient import calclulate_gradient, calculate_gradient_graph, gradient_gradient
from util.image_info import Image_info
import optimization
import texture_mapping

from util.triangle_similar import get_triangle_coefficient

if __name__ == '__main__':
    img1 = cv2.imread("image/DSC00319.JPG")
    img2 = cv2.imread("image/DSC00318.JPG")
    img3 = cv2.imread("image/DSC00317.JPG")
    cv2.imshow("img1", img1)
    # 求img1,img2的匹配信息
    match_1_2 = Match(img1, img2)
    match_1_2.getInitialFeaturePairs()
    img1_point = match_1_2.src_match
    img2_point = match_1_2.dst_match

    H_1_2, no = cv2.findHomography(img2_point, img1_point)

    # 求img2,img3的匹配信息
    match_2_3 = Match(img2, img3)
    match_2_3.getInitialFeaturePairs()
    img2_point = match_2_3.src_match
    img3_point = match_2_3.dst_match
    H_2_3, no = cv2.findHomography(img3_point, img2_point)

    H_1_3 = H_1_2.dot(H_2_3)