mirror of
https://github.com/balajsra/EECS-442-WN19-DIC-Project.git
synced 2025-09-02 17:03:15 +00:00
Fixed Displacement Calculation
* Changed displacement calculation to account for the template matching function returning the upper-left corner of the matching window rather than the center.
This commit is contained in:
@@ -111,8 +111,8 @@ def find_displacement(match_method):
|
||||
|
||||
plt.figure(1)
|
||||
|
||||
reference = images[8]
|
||||
compare_img = images[9]
|
||||
reference = images[560]
|
||||
compare_img = images[561]
|
||||
|
||||
plt.imshow(reference, cmap="gray", vmin=0, vmax=255)
|
||||
|
||||
@@ -138,18 +138,18 @@ def find_displacement(match_method):
|
||||
|
||||
res = cv2.matchTemplate(image=search, templ=subset, method=match_method)
|
||||
|
||||
minVal, maxVal, minLoc, maxLoc = cv2.minMaxLoc(res)
|
||||
minVal, maxVal, minLoc, maxLoc = cv2.minMaxLoc(src=res)
|
||||
|
||||
dx = None
|
||||
dy = None
|
||||
|
||||
if match_method in [cv2.TM_SQDIFF, cv2.TM_SQDIFF_NORMED]:
|
||||
dx = minLoc[0] - search_size
|
||||
dy = minLoc[1] - search_size
|
||||
dx = (minLoc[0] + (subset_size // 2)) - search_size
|
||||
dy = (minLoc[1] + (subset_size // 2)) - search_size
|
||||
elif match_method in [cv2.TM_CCORR, cv2.TM_CCORR_NORMED,
|
||||
cv2.TM_CCOEFF, cv2.TM_CCOEFF_NORMED]:
|
||||
dx = maxLoc[0] - search_size
|
||||
dy = maxLoc[1] - search_size
|
||||
dx = (maxLoc[0] + (subset_size // 2)) - search_size
|
||||
dy = (maxLoc[1] + (subset_size // 2)) - search_size
|
||||
|
||||
im_data.dx[j, i] = dx
|
||||
im_data.dy[j, i] = dy
|
||||
|
Reference in New Issue
Block a user