I'm converting hand_dataset annotations to such a format I could use it in YOLOv3. Annotations are in .mat binary format and I want to extract it, convert and reorganize in .csv.
I have tried mat = scipy.io.loadmat(file)
, but extracting data goes in strange format.
mat = scipy.io.loadmat(file)
bboxes = np.transpose(mat['boxes'])
Gives output:
[[array([[(array([[488.42954942, 345.62261032]]), array([[461.57045058, 348.37738968]]), array([[465.57045058, 387.37738968]]), array([[492.42954942, 384.62261032]]))]],
dtype=[('a', 'O'), ('b', 'O'), ('c', 'O'), ('d', 'O')])]
where shape is (2,1)
and numpy.array type.
I am capable to extract points iterating over whole dataset annotations like that:
points = np.array([point[0] for point in bboxes[0][0][0][0]])
Where hierarchy is:
print(bboxes[0])
print(bboxes[0][0])
print(bboxes[0][0][0])
print(bboxes[0][0][0][0])
print(bboxes[0][0][0][0][0])
print(bboxes[0][0][0][0][0][0][1])
Is there any "nicer" way to extract needed points?
Output from given prints:
[[(array([[488.42954942, 345.62261032]]), array([[461.57045058, 348.37738968]]), array([[465.57045058, 387.37738968]]), array([[492.42954942, 384.62261032]]))]]
[(array([[488.42954942, 345.62261032]]), array([[461.57045058, 348.37738968]]), array([[465.57045058, 387.37738968]]), array([[492.42954942, 384.62261032]]))]
(array([[488.42954942, 345.62261032]]), array([[461.57045058, 348.37738968]]), array([[465.57045058, 387.37738968]]), array([[492.42954942, 384.62261032]]))
[[488.42954942 345.62261032]]
345.6226103157693
Any help would be appreciate! Thanks!