<reponame>stevelee55/Images2Points_Python_Module<filename>Images2Points Files/testDriver.py
# Written by <NAME>
# 10/14/2018
# <EMAIL>

from Images2Points import Images2Points

# For reading in the images.
import cv2

moduler = Images2Points()

image1Name = "TestData/hatcher6.jpg"
image2Name = "TestData/hatcher3.jpg"

#hatcher3 and 6

# Reading in the images using the image names.
img1 = cv2.imread(image1Name, 0)
img2 = cv2.imread(image2Name, 0)

# Getting the matching points from the images.
# Example 1: File name specified, exports the points in csv file.
pointsFromImage1, pointsFromImage2 = moduler.getPointsFromImages(firstImage=img1, secondImage=img2, outputcsvFileName="matchedPointsRaw.csv")

# Getting the matching points from the images.
# Example 2: File name not specified.
pointsFromImage1, pointsFromImage2 = moduler.getPointsFromImages(firstImage=img1, secondImage=img2)


pointsFromImage1, pointsFromImage2 = moduler.getPointsFromImages(firstImage=img1, secondImage=img2, outputcsvFileName="matchedPointsRaw.csv", detectorType="ORB", crossCheck=True, normType=cv2.NORM_HAMMING, createImageWithPtsAndLines="imageWithPtsAndLines.jpg", numOfPtsAndLinesToShow=20, enableSingleColor=True)

###

# find_robust_matches_ranscac using the points.
# Option 1: File name specified. Exports the points in csv file.
robustMatchesFromImage1, robustMatchesFromImage2 = moduler.find_robust_matches_ranscac(inputPointsFromImage1=pointsFromImage1, inputPointsFromImage2=pointsFromImage2, outputcsvFileName="robustMatches.csv")

# find_robust_matches_ranscac using the points.
# Option 2: File name not specified.
robustMatchesFromImage1, robustMatchesFromImage2 = moduler.find_robust_matches_ranscac(inputPointsFromImage1=pointsFromImage1, inputPointsFromImage2=pointsFromImage2)


# find_robust_matches_ranscac using the csv file.
# Option 1: Import file name specified, imports the points in matched points that are raw in csv file.
robustMatchesFromImage1, robustMatchesFromImage2 = moduler.find_robust_matches_ranscac(inputcsvFileName="matchedPointsRaw.csv")

# find_robust_matches_ranscac using the csv file.
# Option 2: Import file name not specified, uses the points that were previously matched.
robustMatchesFromImage1, robustMatchesFromImage2 = moduler.find_robust_matches_ranscac(inputPointsFromImage1=pointsFromImage1, inputPointsFromImage2=pointsFromImage2)

# find_robust_matches_ranscac using the csv file.
# Option 3: Export file name specified, imports the points in matched points that are raw in csv file.
robustMatchesFromImage1, robustMatchesFromImage2 = moduler.find_robust_matches_ranscac(inputcsvFileName="matchedPointsRaw.csv", outputcsvFileName="robustMatches.csv")

###
# Example of using the points.
###

# Using the points to find transformation matrix and applying it to the image to warp it.
tform, status = cv2.findHomography(robustMatchesFromImage2, robustMatchesFromImage1, cv2.RANSAC, 5.0)
transimg2 = cv2.warpPerspective(img2, tform, (len(img2[0]), len(img2)))
# Original position.
cv2.imwrite("firstImage.jpg", img1)
# Warped second image but not "shifted" relative to the first image.
cv2.imwrite("secondImage.jpg", transimg2)
Files/testDriver.py
# Written by <NAME>
# 10/14/2018
# <EMAIL>

from Images2Points import Images2Points

# For reading in the images.
import cv2

moduler = Images2Points()

image1Name = "TestData/hatcher6.jpg"
image2Name = "TestData/hatcher3.jpg"

#hatcher3 and 6

# Reading in the images using the image names.
img1 = cv2.imread(image1Name, 0)
img2 = cv2.imread(image2Name, 0)

# Getting the matching points from the images.
# Example 1: File name specified, exports the points in csv file.
pointsFromImage1, pointsFromImage2 = moduler.getPointsFromImages(firstImage=img1, secondImage=img2, outputcsvFileName="matchedPointsRaw.csv")

# Getting the matching points from the images.
# Example 2: File name not specified.
pointsFromImage1, pointsFromImage2 = moduler.getPointsFromImages(firstImage=img1, secondImage=img2)


pointsFromImage1, pointsFromImage2 = moduler.getPointsFromImages(firstImage=img1, secondImage=img2, outputcsvFileName="matchedPointsRaw.csv", detectorType="ORB", crossCheck=True, normType=cv2.NORM_HAMMING, createImageWithPtsAndLines="imageWithPtsAndLines.jpg", numOfPtsAndLinesToShow=20, enableSingleColor=True)

###

# find_robust_matches_ranscac using the points.
# Option 1: File name specified. Exports the points in csv file.
robustMatchesFromImage1, robustMatchesFromImage2 = moduler.find_robust_matches_ranscac(inputPointsFromImage1=pointsFromImage1, inputPointsFromImage2=pointsFromImage2, outputcsvFileName="robustMatches.csv")

# find_robust_matches_ranscac using the points.
# Option 2: File name not specified.
robustMatchesFromImage1, robustMatchesFromImage2 = moduler.find_robust_matches_ranscac(inputPointsFromImage1=pointsFromImage1, inputPointsFromImage2=pointsFromImage2)


# find_robust_matches_ranscac using the csv file.
# Option 1: Import file name specified, imports the points in matched points that are raw in csv file.
robustMatchesFromImage1, robustMatchesFromImage2 = moduler.find_robust_matches_ranscac(inputcsvFileName="matchedPointsRaw.csv")

# find_robust_matches_ranscac using the csv file.
# Option 2: Import file name not specified, uses the points that were previously matched.
robustMatchesFromImage1, robustMatchesFromImage2 = moduler.find_robust_matches_ranscac(inputPointsFromImage1=pointsFromImage1, inputPointsFromImage2=pointsFromImage2)

# find_robust_matches_ranscac using the csv file.
# Option 3: Export file name specified, imports the points in matched points that are raw in csv file.
robustMatchesFromImage1, robustMatchesFromImage2 = moduler.find_robust_matches_ranscac(inputcsvFileName="matchedPointsRaw.csv", outputcsvFileName="robustMatches.csv")

###
# Example of using the points.
###

# Using the points to find transformation matrix and applying it to the image to warp it.
tform, status = cv2.findHomography(robustMatchesFromImage2, robustMatchesFromImage1, cv2.RANSAC, 5.0)
transimg2 = cv2.warpPerspective(img2, tform, (len(img2[0]), len(img2)))
# Original position.
cv2.imwrite("firstImage.jpg", img1)
# Warped second image but not "shifted" relative to the first image.
cv2.imwrite("secondImage.jpg", transimg2)
# Written by <NAME> # 10/14/2018 # <EMAIL> # For reading in the images. #hatcher3 and 6 # Reading in the images using the image names. # Getting the matching points from the images. # Example 1: File name specified, exports the points in csv file. # Getting the matching points from the images. # Example 2: File name not specified. ### # find_robust_matches_ranscac using the points. # Option 1: File name specified. Exports the points in csv file. # find_robust_matches_ranscac using the points. # Option 2: File name not specified. # find_robust_matches_ranscac using the csv file. # Option 1: Import file name specified, imports the points in matched points that are raw in csv file. # find_robust_matches_ranscac using the csv file. # Option 2: Import file name not specified, uses the points that were previously matched. # find_robust_matches_ranscac using the csv file. # Option 3: Export file name specified, imports the points in matched points that are raw in csv file. ### # Example of using the points. ### # Using the points to find transformation matrix and applying it to the image to warp it. # Original position. # Warped second image but not "shifted" relative to the first image.