Skip to content

Scripts....

Augusto Luis Ballardini edited this page Oct 20, 2020 · 5 revisions

To generate Q-Matrices

this matrices are used in class GenerateBev(object)

simulation in python, for kitti360, but we made similar with standard-kitti. taking the values of the two matrices.

import numpy as np
P_rect_00 = "552.554261 0.000000 682.049453 0.000000 0.000000 552.554261 238.769549 0.000000 0.000000 0.000000 1.000000 0.000000"
P_rect_01 = "552.554261 0.000000 682.049453 -328.318735 0.000000 552.554261 238.769549 0.000000 0.000000 0.000000 1.000000 0.000000"
np.array(P_rect_00.strip().split(" ")).astype('float32').reshape(3, -1)
array([[552.55426,   0.     , 682.04944,   0.     ],
       [  0.     , 552.55426, 238.76955,   0.     ],
       [  0.     ,   0.     ,   1.     ,   0.     ]], dtype=float32)
calib_matrix_1 = np.array(P_rect_00.strip().split(" ")).astype('float32').reshape(3, -1)
calib_matrix_2 = np.array(P_rect_01.strip().split(" ")).astype('float32').reshape(3, -1)

Tmat = np.array([0.60, 0., 0.])     <<< these are for kitti-360, standard kitti were: Tmat = np.array([0.54, 0., 0.])       
rev_proj_matrix = np.zeros((4, 4))  <<< these are for kitti-360, standard kitti were: rev_proj_matrix = np.zeros((4, 4)) 

cv2.stereoRectify(cameraMatrix1=cam1, cameraMatrix2=cam2,
                  distCoeffs1=0, distCoeffs2=0,
                  imageSize=(376,1408),
                  R=np.identity(3), T=Tmat,
                  R1=None, R2=None,
                  P1=None, P2=None, Q=rev_proj_matrix)

then check rev_proj_matrix

376 and 1408 came from:

>>> img_left_color  = cv2.imread("/media/augusto/500GBHECTOR/augusto/kitti360-augusto/1/left/2013_05_28_drive_0002_sync_0000013954.png")
>>> img_left_color.shape
(376, 1408, 3)
>>> img_left_color.shape[:2]
(376, 1408)

this is the perspective.txt found after downloading kitti360

calib_time: 17-Feb-2016 14:23:48
corner_dist: 0.100000
S_00: 1392.000000 512.000000
K_00: 788.629315 0.000000 687.158398 0.000000 786.382230 317.752196 0.000000 0.000000 0.000000
D_00: -0.344441 0.141678 0.000414 -0.000222 -0.029608
R_00: 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000
T_00: 0.000000 0.000000 0.000000
S_rect_00: 1408.000000 376.000000
R_rect_00: 0.999974 -0.007141 -0.000089 0.007141 0.999969 -0.003247 0.000112 0.003247 0.999995
>>>P_rect_00: 552.554261 0.000000 682.049453 0.000000 0.000000 552.554261 238.769549 0.000000 0.000000 0.000000 1.000000 0.000000
S_01: 1392.000000 512.000000
K_01: 785.134093 0.000000 686.437073 0.000000 782.346289 321.352788 0.000000 0.000000 0.000000
D_01: -0.353195 0.161996 0.000383 -0.000242 -0.041476
R_01: 0.999837 0.004862 -0.017390 -0.004974 0.999967 -0.006389 0.017358 0.006474 0.999828
T_01: -0.594052 0.007198 -0.010233
S_rect_01: 1408.000000 376.000000
R_rect_01: 0.999778 -0.012115 0.017222 0.012059 0.999922 0.003351 -0.017261 -0.003143 0.999846
>>>P_rect_01: 552.554261 0.000000 682.049453 -328.318735 0.000000 552.554261 238.769549 0.000000 0.000000 0.000000 1.000000 0.000000

To generate the REAL OSM (from kitti)

NEEDED:
	/home/ballardini/alvaro_ws

cat spintina.bash
roscd
cd
cd alvaro_ws/devel/
source setup.bash
roscd road_intersection_detector/launch/multilaunch/
rostopic pub /kitti_player/synch std_msgs/Bool "data: true"

1. create folder /tmp/GT 
2. the PYTHON script that creates the png's is particle_filter.py
3. execute the modified launch script below, changing the map/sequence. 
	roslaunch alvaro_BASE_process.launch
4. send "spintina" with 
	rostopic pub /kitti_player/synch std_msgs/Bool "data: true"

2011_09_30_drive_0018_sync
2011_09_30_drive_0020_sync
2011_09_30_drive_0027_sync
2011_09_30_drive_0028_sync
2011_09_30_drive_0033_sync
2011_09_30_drive_0034_sync
2011_10_03_drive_0027_sync
2011_10_03_drive_0034_sync

you need the OXTS from the KITTI DATASET inside 
/home/ballardini/alvaro_ws/src/kitti_player/dataset

these files were retrieved from 
sftp://iralab@i7g4.ira.disco.unimib.it/media/RAIDONE/DATASETS/KITTI/RESIDENTIAL

to change the filenames

 for i in $( ls *.png ); do alvaroFilename=`echo $i | cut -d '_' -f 2 ` ; mv $i 00000$alvaroFilename; done

Miscellaneous


/media/ballardini/4tb/ALVARO/aanet
/media/ballardini/4tb/ALVARO/mask

python reproject.py 000000.png mask/000000.png out_aanet.ply out_aanet.pcd


index=0;for i in $( ls -v /media/ballardini/4tb/ALVARO/aanet/*.png ); do printf -v paddednum "%06d" $index;  echo python reproject.py $i /media/ballardini/4tb/ALVARO/mask/$paddednum.png out_aanet.ply ./pcds/$paddednum.pcd; ((index++));done;

pcl_transform_point_cloud -quat 0.5,-0.5,-0.5,0.5 ../000000.pcd 000000.pcd

index=0;for i in $( ls -v ../*.pcd ); do printf -v paddednum "%06d" $index; echo pcl_transform_point_cloud -quat 0.5,-0.5,-0.5,0.5 $i $paddednum.pcd ; ((index++));done;

pcl_viewer 000090.pcd /media/ballardini/4tb/ALVARO/poinclouds/000090.pcd -multiview 1 -ax 5  -bc .98,1.,.77


pcl_pcd_grabber_viewer -dir /home/ballardini/PycharmProjects/reproject/pcds/rotated -bc .98,1.,.77 -ax 5 -fps 10 &
pcl_pcd_grabber_viewer -dir /media/ballardini/4tb/ALVARO/poinclouds -bc .98,1.,.77 -ax 5 -fps 10 &
wait $(jobs -p)

====

Alvaro used the INTERSECTION GROUND TRUTH to create the MASKS with "ROAD/NOT_ROAD" images
https://ira.disco.unimib.it/research/robotic-perception-research/road-layout-estimation/an-online-probabilistic-road-intersection-detector/intersection-ground-truth/


la struttura delle cartelle per aanet è questa

augusto@ivan-pc:~/Datasets/KITTI/sequences/00/testing$ ll
total 420K
drwxrwxr-x 5 augusto augusto 4,0K jun 22 17:47 ./
drwxrwxr-x 3 augusto augusto 4,0K jun 19 13:19 ../
drwxrwxr-x 2 augusto augusto 132K jun 19 16:46 image_2/
drwxrwxr-x 2 augusto augusto 132K jun 19 16:29 image_3/
lrwxrwxrwx 1 augusto augusto    7 jun 22 17:47 left -> image_2/
drwxrwxr-x 2 augusto augusto 140K jun 22 18:29 pred/
lrwxrwxrwx 1 augusto augusto    7 jun 22 17:47 right -> image_3/


---

in Secuencias 
ls aanet_2011_* -d1 > folders.txt

while read folder
do echo $folder
for i in $( ls -v /media/ballardini/4tb/ALVARO/Secuencias/$folder/*.png ); do alvaroFilename=`cut -d '/' -f 8 <<< $i | tr -d _`  ; echo python reproject.py $i /media/ballardini/4tb/ALVARO/Secuencias/$folder/$alvaroFilename out_aanet.ply ./pcds/$paddednum.pcd; ((index++));done;
done < folders.txt

#create folders
while read line; do newFolder=`sed 's/aanet_//;s/_sync//' <<< $line`; mkdir $newFolder\_pcd; done < folders.txt

#indentation REQUIRES 2 spaces, NO TABS
while read folder; do echo $folder
  for i in $( ls -v /media/ballardini/4tb/ALVARO/Secuencias/$folder/*.png )
    do alvaroFilename=`cut -d '/' -f 8 <<< $i | tr -d _` 
    alvaroFolder=`sed 's/aanet_//' <<< $i` 
    filenameKITTI=`sed "s|pred||" <<< $alvaroFilename`
    image_02=`sed "s|_sync/|_sync/image_02/|;s|_pred||;s|aanet_||" <<< $i`
    image_03=`sed "s|_sync/|_sync/image_03/|;s|_pred||;s|aanet_||" <<< $i`
    alvaroFolder2=`sed 's/_pred/pred/' <<< $alvaroFolder`
    pcdName=`sed 's/pred.png//' <<< $alvaroFilename`
    pcdFolder=`sed 's/000.*//;s/_sync/_pcd/;s/aanet_//' <<< $i` 
    echo python reproject.py $i $alvaroFolder2 out_aanet.ply $pcdFolder$pcdName.pcd $image_02 $image_03  
  done
done < /media/ballardini/4tb/ALVARO/Secuencias/folders.txt


while read folder; do echo $folder
  for i in $( ls -v /media/ballardini/4tb/ALVARO/Secuencias/$folder/*.png )
    do echo $i
  done
done < /media/ballardini/4tb/ALVARO/Secuencias/folders.txt



example of parameters (use in pycharm for debug)
/media/ballardini/4tb/ALVARO/Secuencias/aanet_2011_09_30_drive_0018_sync/0000000417_pred.png 
/media/ballardini/4tb/ALVARO/Secuencias/2011_09_30_drive_0018_sync/0000000417pred.png 
out_aanet.ply 
/media/ballardini/4tb/ALVARO/Secuencias/2011_09_30_drive_0018_pcd/0000000417.pcd
/media/ballardini/4tb/ALVARO/Secuencias/2011_09_30_drive_0018_sync/image_02/0000000000.png 
/media/ballardini/4tb/ALVARO/Secuencias/2011_09_30_drive_0018_sync/image_03/0000000000.png

/media/ballardini/4tb/ALVARO/Secuencias/2011_09_30_drive_0018_sync/pred/0000000000_pred.npz 
/media/ballardini/4tb/ALVARO/Secuencias/2011_09_30_drive_0018_sync/alvaromask/0000000000pred.png 
out_aanet.ply 
/media/ballardini/4tb/ALVARO/Secuencias/2011_09_30_drive_0018_sync/pcd/0000000000.pcd 
/media/ballardini/4tb/ALVARO/Secuencias/2011_09_30_drive_0018_sync/image_02/alvaromask/0000000000pred.png 
/media/ballardini/4tb/ALVARO/Secuencias/2011_09_30_drive_0018_sync/image_03/alvaromask/0000000000pred.png 
/media/ballardini/4tb/ALVARO/Secuencias/2011_09_30_drive_0018_sync/bev/0000000000





=======================
AANET
augusto_aanet+_predict.sh

#!/usr/bin/env bash                                                                                                                                  #--data_dir /home/augusto/aanet/data/KITTI/sequences/00/testing \                                                                                                                        
                                                                
        # Predict                                                                                                
CUDA_VISIBLE_DEVICES=0 python predict.py \                                                  
--data_dir /home/malvaro/Documentos/DualBiSeNet/data_raw/2011_09_30/2011_09_30_drive_0018_sync \                      
--pretrained_aanet pretrained/aanet+_kitti15-2075aea1.pth \       
--feature_type ganet \                                                    
--feature_pyramid \                                                                                                                                              
--refinement_type hourglass \                                                                                                                                                
--no_intermediate_supervision

CUDA_VISIBLE_DEVICES=0

while read line; do echo python predict.py \
--data_dir $line \
--pretrained_aanet pretrained/aanet+_kitti15-2075aea1.pth \
--feature_type ganet \
--feature_pyramid \
--refinement_type hourglass \
--no_intermediate_supervision ; done < folders_alvaro.txt