forked from Mieos/markersAssociation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorrectInterResults.m
69 lines (56 loc) · 2 KB
/
correctInterResults.m
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
%% Correct associations
clear all;
close all;
numTest = "09";
masterPath = "/media/rmodrzejewski/Maxtor/data/metalPigsXP/";
%% Include mex
mexOCVpath = '/home/rmodrzejewski/Install/mexopencv';
contribPath = mexOCVpath + "/opencv_contrib";
contribPath = char(contribPath);
% OpenCV
addpath(mexOCVpath)
addpath(contribPath);
%% Association Init
associationsOf05=masterPath+"targets/05/resultsAssociations/v1/associations.yml";
associationsOf05=char(associationsOf05);
associationsFound=masterPath+"targets/"+numTest+"/results/associations_with05.yml";
associationsFound=char(associationsFound);
%% PC
pointsPath_GT=masterPath+"model/segmentations/ballsAndClips/markers.yml";
pointsPath_GT=char(pointsPath_GT);
pointsPath_Used=masterPath+"targets/"+numTest+"/markers.yml";
pointsPath_Used=char(pointsPath_Used);
%% Path for saving
resultPath = masterPath+"targets/"+numTest+"/resultsAssociations/v1/associations.yml";
resultPath=char(resultPath);
resultPLYPath = masterPath+"targets/"+numTest+"/resultsAssociations/v1/associations_U.ply";
resultPLYPath=char(resultPLYPath);
resultPLYPathGT = masterPath+"targets/"+numTest+"/resultsAssociations/v1/associations_GT.ply";
resultPLYPathGT=char(resultPLYPathGT);
%% Get asso files
asso5 = cv.FileStorage(associationsOf05);
assoF = cv.FileStorage(associationsFound);
asso5Data=asso5.Association;
assoFData=assoF.Association;
%% New asso
%newAsso = asso5Data(assoFData(:));
newAsso = assoFData(asso5Data(:));
%% Points
% Read matrix
p_GT = cv.FileStorage(pointsPath_GT);
p_Used = cv.FileStorage(pointsPath_Used);
ballsGT = p_GT.centroidsBalls;
ballsUsed = p_Used.centroidsBalls;
clipsGT = p_GT.centroidsClips;
clipsUsed = p_Used.centroidsClips;
pGT = horzcat(ballsGT,clipsGT);
pUsed = horzcat(ballsUsed,clipsUsed);
%% Color
r = randi([0 255],60,3,'uint8');
pcU = pointCloud(pUsed(:,newAsso(:))','Color', r);
pcGT = pointCloud(pGT','Color',r);
S = struct('Association',newAsso);
cv.FileStorage(resultPath,S);
% Point clouds for visualisation
pcwrite(pcU,resultPLYPath);
pcwrite(pcGT,resultPLYPathGT);