Using bayer encoding for images.

This commit is contained in:
Daniel
2025-01-13 16:50:08 +01:00
parent 53543368c4
commit 2f52521b9a
3 changed files with 2657 additions and 2613 deletions

View File

@ -227,6 +227,23 @@ def load_image(path: str):
# ==================================================================================================
def rgb2bayer(img):
bayer = np.zeros((img.shape[0], img.shape[1]), dtype=img.dtype)
bayer[0::2, 0::2] = img[0::2, 0::2, 0]
bayer[0::2, 1::2] = img[0::2, 1::2, 1]
bayer[1::2, 0::2] = img[1::2, 0::2, 1]
bayer[1::2, 1::2] = img[1::2, 1::2, 2]
return bayer
def bayer2rgb(bayer):
img = cv2.cvtColor(bayer, cv2.COLOR_BayerBG2RGB)
return img
# ==================================================================================================
def update_keypoints(poses_2d: list, joint_names: List[str]) -> list:
new_views = []
for view in poses_2d:
@ -314,6 +331,8 @@ def main():
for i in range(len(sample["cameras_color"])):
imgpath = sample["imgpaths_color"][i]
img = load_image(imgpath)
img = rgb2bayer(img)
img = bayer2rgb(img)
images_2d.append(img)
# Get 2D poses