MVDet icon indicating copy to clipboard operation
MVDet copied to clipboard

Wrong MultiviewX grid visualization

Open JohnPekl opened this issue 6 months ago • 0 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

JohnPekl avatar Jan 02 '24 08:01 JohnPekl