Spaces:
Runtime error
Runtime error
File size: 880 Bytes
b9e0048 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import cv2
import numpy as np
import os
def generate_synthetic_puzzle(num_images: int, output_dir: str):
os.makedirs(output_dir, exist_ok=True)
for i in range(num_images):
# Create blank image
image = np.ones((1000, 1000, 3), dtype=np.uint8) * 255
# Add random puzzle pieces (simplified)
for _ in range(np.random.randint(10, 50)):
x = np.random.randint(100, 900)
y = np.random.randint(100, 900)
size = np.random.randint(50, 200)
color = (np.random.randint(0, 256), np.random.randint(0, 256), np.random.randint(0, 256))
cv2.rectangle(image, (x, y), (x + size, y + size), color, -1)
# Save image
cv2.imwrite(os.path.join(output_dir, f'puzzle_{i}.jpg'), image)
if __name__ == '__main__':
generate_synthetic_puzzle(10, 'synthetic_puzzles') |