Commit b0f1856a authored by Simon Madec's avatar Simon Madec
Browse files

Commit for Jin

still have to work on it to adapt for every image size
parent 6dbb6f0c
% test and validation
clc
clear all
close all
%% INPUT
addpath('fonctions')
tic
cgsd = 0;
% LOAD HEIGHT
writeIm=1 % option to write image
Color_map = colorcube(17);
datasetTable = ;
nameIm_1 =
boxPy = csvread([dataset '\' nameIm_1 '_box_' num2str((imodel1)) '.csv']);
scorePy = single(csvread([dataset '\' nameIm_1 '_Score_' num2str((imodel1)) '.csv']));
Indice = csvread([dataset '\' nameIm_1 '_Indice_' num2str((imodel1)) '.csv']);
% filtering
disp('fitlering box')
[boxPy,scorePy,~] = filteringBox_nobord(boxPy,scorePy,Indice,0.5,0.915);
label_str1 = cell(size(boxPy,1),1);
for i=1:size(boxPy,1)
label_str1{i} = num2str(scorePy(i));
end
img = imread([datasetImg '\' nameIm_1 '.JPG']);
disp('insert box in the image')
img = insertShape(img,'FilledRectangle',GroundTruth_1_1,'Color', colorT(30,:)*255,'Opacity',0.32);
img = insertObjectAnnotation(img, 'rectangle', GroundTruth_1_1,label_str1,'LineWidth',9,'FontSize',20,'Color','yellow');
disp('write image')
imwrite(img(:,:,:),['D:\Home\SimonMADEC\forHiphen\visu\' nameIm_1 '_' num2str(imodel1) '_newPara.jpg'])
function [boxPy,scorePy,Indice] = filteringBox_nobord(boxPy,scorePy,Indice,threshold,ovThresold)
%UNTITLED8 Summary of this function goes here
% Detailed explanation goes here
if nargin<4
threshold=0.5;
end
if nargin<5
ovThresold=0.8;
end
boxPy = round(boxPy);
boxPy(:,3) = boxPy(:,3)-boxPy(:,1);
boxPy(:,4) = boxPy(:,4)-boxPy(:,2);
boxPyOld = boxPy;
boxPy(:,1) = boxPyOld(:,2);
boxPy(:,2) = boxPyOld(:,1);
boxPy(:,3) = boxPyOld(:,4);
boxPy(:,4) = boxPyOld(:,3);
cond1 = (boxPy(:,1) < 20);
cond2 = (boxPy(:,1) + boxPy(:,3) > 5980);
cond3 = (boxPy(:,2) < 20);
cond4 = (boxPy(:,2) + boxPy(:,4) > 3980);
cond = [cond1,cond2,cond3,cond4];
vec = sum(cond')';
boxPyA = boxPy((vec==1),:);
scorePyA = scorePy( (vec==1),:);
boxPy = boxPy((Indice==0) & (vec==0),:);
scorePy = scorePy((Indice==0) & (vec==0),:);
boxPy = [boxPy;boxPyA];
scorePy = [scorePy;scorePyA];
boxPy = boxPy(scorePy>threshold,:);
scorePy = scorePy(scorePy>threshold);
if size(scorePy,1)>1
[boxPy,scorePy] = selectStrongestBbox(boxPy,scorePy,'RatioType','Min','OverlapThreshold',ovThresold); % #todo 0.73 !! #TODO
end
end
......@@ -21,7 +21,7 @@ def returnBound(MODEL_NAME,pathIm):
from PIL import Image
# # Model preparation
# Path to frozen detection graph. This is the actual model that is used for the object detection.
# Path to frozen detection graph. This is the actual model that is used for the object detection. lalalalalalla
detection_graph = tf.Graph()
with detection_graph.as_default():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment