hou-yz/MVDet

Wrong MultiviewX grid visualization

JohnPekl opened this issue · 1 comments

I use calibration from MultivewX to run grid_visualize.py, code shown below.

import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
import cv2
from multiview_detector.utils import projection
from multiview_detector.datasets.MultiviewX import MultiviewX

if __name__ == '__main__':
    img = Image.open('D:/dataset/tracking/CMC/data/images/MultiviewX/Image_subsets/C1/0000.png')
    dataset = MultiviewX('D:/dataset/tracking/CMC/data/images/MultiviewX')
    xi = np.arange(0, 480, 40)
    yi = np.arange(0, 1440, 40)
    world_grid = np.stack(np.meshgrid(xi, yi, indexing='ij')).reshape([2, -1])
    world_coord = dataset.get_worldcoord_from_worldgrid(world_grid)
    img_coord = projection.get_imagecoord_from_worldcoord(world_coord, dataset.intrinsic_matrices[0],
                                                          dataset.extrinsic_matrices[0])
    img_coord = img_coord[:, np.where((img_coord[0] > 0) & (img_coord[1] > 0) &
                                      (img_coord[0] < 1920) & (img_coord[1] < 1080))[0]]
    plt.imshow(img)
    plt.show()
    img_coord = img_coord.astype(int).transpose()
    img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
    for point in img_coord:
        cv2.circle(img, tuple(point.astype(int)), 5, (0, 255, 0), -1)
    img = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
    img.save('img_grid_visualize_mx.png')
    plt.imshow(img)
    plt.show()
    pass

However, the result of grid visualization seems not to be corrected. Could you please help me correct it?

image

Here is the grid visualization for the Wildtrack dataset
image

please check these two lines in your code, as the current version refers to a ground plane shape of [480, 1440], which only matches the Wildtrack dataset but not the MultiviewX dataset. try [640, 1000] instead.

    xi = np.arange(0, 480, 40)
    yi = np.arange(0, 1440, 40)