Datasets:
Formats:
imagefolder
Sub-tasks:
multi-class-image-classification
Languages:
English
Size:
1K - 10K
License:
File size: 954 Bytes
a26ae4f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import os, glob
import cv2
import numpy as np
from tqdm import tqdm
# adjust these paths
color_dir = "path/to/your/color/images"
depth_dir = "path/to/your/depth/images"
out_dir = "path/to/your/rgbd/images"
os.makedirs(out_dir, exist_ok=True)
print("Processing color and depth images...")
for color_path in tqdm(glob.glob(os.path.join(color_dir, "*.png"))):
base = os.path.basename(color_path)
depth_path = os.path.join(depth_dir, base)
if not os.path.exists(depth_path):
continue
rgb = cv2.imread(color_path, cv2.IMREAD_UNCHANGED) # H×W×3
depth = cv2.imread(depth_path, cv2.IMREAD_UNCHANGED) # H×W (raw depth)
depth = cv2.normalize(depth, None, 0, 255, cv2.NORM_MINMAX)
depth = depth.astype(np.uint8)
# merge to H×W×4 (B,G,R,Depth)
rgba = cv2.merge([ rgb[:,:,0], rgb[:,:,1], rgb[:,:,2], depth ])
cv2.imwrite(os.path.join(out_dir, base), rgba)
print("RGBD data preparation completed.")
|