update 3d viewer to display deform instead of arrows

This commit is contained in:
ykcheungab
2026-06-02 21:12:17 +08:00
parent 8a50492465
commit 9fe93b23e4
26 changed files with 1314 additions and 99 deletions
@@ -0,0 +1,46 @@
#%%
import numpy as np
import cv2
def generate_checker_pattern(height, width, patch_size):
"""
Generate a black-and-white checkerboard pattern.
Each `patch_size x patch_size` block alternates between black and white.
Partial blocks at the image borders are also filled correctly.
"""
pattern = np.zeros((height, width, 3), dtype=np.uint8)
num_patches_x = (height + patch_size - 1) // patch_size
num_patches_y = (width + patch_size - 1) // patch_size
for i in range(num_patches_x):
for j in range(num_patches_y):
color = 255 if (i + j) % 2 == 0 else 0
y0 = i * patch_size
y1 = min((i + 1) * patch_size, height)
x0 = j * patch_size
x1 = min((j + 1) * patch_size, width)
pattern[y0:y1, x0:x1] = color
print("Patch ({}, {}) -> {}".format(i, j, "white" if color == 255 else "black"))
return pattern
def main():
height = 1200
width = 1000
patch_size = 12
pattern = generate_checker_pattern(height, width, patch_size)
cv2.imshow("Checker Pattern", pattern)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.imwrite("checker_pattern.png", pattern)
if __name__ == '__main__':
main()