Upload 7 files
Browse files- DroneCrowd/README.md +41 -0
- DroneCrowd/make_data_density.py +65 -0
- DroneCrowd/make_data_localization.py +63 -0
- DroneCrowd/saveGT.m +21 -0
- DroneCrowd/testlist.txt +30 -0
- DroneCrowd/trainlist.txt +82 -0
- DroneCrowd/xml2mat.m +38 -0
DroneCrowd/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The DroneCrowd Dataset
|
| 2 |
+
The DroneCrowd Dataset is a large-scale video based dataset for crowd counting, crowd localization and crowd tracking on drone-captured scenes. It includes 112 video clips with 33,600 frames with a resolution of 1920x1080 pixels. Notably,
|
| 3 |
+
we annotate 20,800 people trajectories with 4.8 million heads and several video-level attributes. The dataset is collected by the AISKYEYE team at Lab of Machine Learning and Data Mining, Tianjin University, China.
|
| 4 |
+
|
| 5 |
+
## Data Format
|
| 6 |
+
|
| 7 |
+
1. The dataset consists of train set (82 sequences) and test set (30 sequences). Each line in ```train.txt``` and ```test.txt``` is the index of the sequence.
|
| 8 |
+
|
| 9 |
+
2. The sequences are converted into consecutive frames in the train set, val set and test set, which is recorded as ```img{seqID:%03d}{frID:%03d}.jpg``` images. For example, ```img001001.jpg``` denotes the ```001```-th frame in the ```001```-th sequence. Note that the val set is sampled from the test set.
|
| 10 |
+
|
| 11 |
+
3. The original annotation is saved in the ```.xml``` format. For convenience, we can generate the corresponding ```.mat``` format ground-truth by the `xml2mat.m` function. In each line, the points order is ```frame, id, xmin, ymin, xmax, ymax```. Moreover, the ```GT_img*.mat``` annotation in the ground-truth folder is consistent with the Shanghaitech dataset. The points order is ```x, y, id```, generated by the `saveGT.m` function.
|
| 12 |
+
|
| 13 |
+
4. The ground-truth density and localization maps are generated by `make_data_density.py` and `make_data_localization.py` respectively for network training.
|
| 14 |
+
|
| 15 |
+
## License
|
| 16 |
+
|
| 17 |
+
This dataset is only for academic and non-commercial uses. We strictly comply with local laws and regulations in China when using unmanned aircraft/drones, and avoid restricted areas to capture videos. Since the scales of objects are extremely small, no identity information such as faces and vehicle plates could be retrieved. If you find yourself or your personal belongings in the dataset, please contact us, and we will immediately remove the corresponding frames.
|
| 18 |
+
|
| 19 |
+
## Reference
|
| 20 |
+
|
| 21 |
+
The dataset and codes can be found in [github](https://github.com/VisDrone/DroneCrowd). If you use our dataset and codes, please cite the following paper:
|
| 22 |
+
|
| 23 |
+
@inproceedings{dronecrowd_cvpr2021,
|
| 24 |
+
author = {Longyin Wen and
|
| 25 |
+
Dawei Du and
|
| 26 |
+
Pengfei Zhu and
|
| 27 |
+
Qinghua Hu and
|
| 28 |
+
Qilong Wang and
|
| 29 |
+
Liefeng Bo and
|
| 30 |
+
Siwei Lyu},
|
| 31 |
+
title = {Detection, Tracking, and Counting Meets Drones in Crowds: A Benchmark},
|
| 32 |
+
booktitle = {CVPR},
|
| 33 |
+
year = {2021}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
DroneCrowd/make_data_density.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import h5py
|
| 2 |
+
import scipy
|
| 3 |
+
import scipy.io as io
|
| 4 |
+
import numpy as np
|
| 5 |
+
import os
|
| 6 |
+
import glob
|
| 7 |
+
from matplotlib import pyplot as plt
|
| 8 |
+
from scipy import spatial
|
| 9 |
+
from multiprocessing import Pool
|
| 10 |
+
from functools import partial
|
| 11 |
+
|
| 12 |
+
def gaussian_filter_density(gt):
|
| 13 |
+
density = np.zeros(gt.shape, dtype=np.float32)
|
| 14 |
+
gt_count = np.count_nonzero(gt)
|
| 15 |
+
if gt_count == 0:
|
| 16 |
+
return density
|
| 17 |
+
|
| 18 |
+
pts = np.array(list(zip(np.nonzero(gt)[1], np.nonzero(gt)[0])))
|
| 19 |
+
leafsize = 2048
|
| 20 |
+
# build kdtree
|
| 21 |
+
tree = spatial.KDTree(pts.copy(), leafsize=leafsize)
|
| 22 |
+
# query kdtree
|
| 23 |
+
distances, locations = tree.query(pts, k=4)
|
| 24 |
+
|
| 25 |
+
for i, pt in enumerate(pts):
|
| 26 |
+
pt2d = np.zeros(gt.shape, dtype=np.float32)
|
| 27 |
+
pt2d[pt[1],pt[0]] = 1.
|
| 28 |
+
if gt_count > 1:
|
| 29 |
+
sigma = (distances[i][1]+distances[i][2]+distances[i][3])*0.1
|
| 30 |
+
else:
|
| 31 |
+
sigma = np.average(np.array(gt.shape))/2./2. #case: 1 point
|
| 32 |
+
density += scipy.ndimage.filters.gaussian_filter(pt2d, sigma, mode='constant')
|
| 33 |
+
|
| 34 |
+
return density
|
| 35 |
+
|
| 36 |
+
def process(idx, img_paths):
|
| 37 |
+
img_path = img_paths[idx]
|
| 38 |
+
mat = io.loadmat(img_path.replace('.jpg','.mat').replace('images','ground_truth').replace('img','GT_img'))
|
| 39 |
+
img = plt.imread(img_path)
|
| 40 |
+
k = np.zeros((int(img.shape[0]/2),int(img.shape[1]/2)))
|
| 41 |
+
gt = mat["image_info"][0,0][0,0][0]
|
| 42 |
+
for i in range(0,len(gt)):
|
| 43 |
+
if int(gt[i][1]/2)<img.shape[0]/2 and int(gt[i][0]/2)<img.shape[1]/2:
|
| 44 |
+
k[int(gt[i][1]/2),int(gt[i][0]/2)]=1
|
| 45 |
+
k = gaussian_filter_density(k)
|
| 46 |
+
|
| 47 |
+
with h5py.File(img_path.replace('.jpg','.h5').replace('images','ground_truth'), 'w') as hf:
|
| 48 |
+
hf['density'] = k
|
| 49 |
+
|
| 50 |
+
print(idx,len(img_paths))
|
| 51 |
+
|
| 52 |
+
part_train = os.path.join('train_data','images')
|
| 53 |
+
part_test = os.path.join('val_data','images')
|
| 54 |
+
|
| 55 |
+
img_paths = []
|
| 56 |
+
for img_path in glob.glob(os.path.join(part_train, '*.jpg')):
|
| 57 |
+
img_paths.append(img_path)
|
| 58 |
+
|
| 59 |
+
for img_path in glob.glob(os.path.join(part_test, '*.jpg')):
|
| 60 |
+
img_paths.append(img_path)
|
| 61 |
+
img_paths.sort()
|
| 62 |
+
|
| 63 |
+
pool = Pool(10)
|
| 64 |
+
partial = partial(process, img_paths=img_paths)
|
| 65 |
+
_ = pool.map(partial, range(len(img_paths)))
|
DroneCrowd/make_data_localization.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import h5py
|
| 2 |
+
import scipy.io as io
|
| 3 |
+
import numpy as np
|
| 4 |
+
import os
|
| 5 |
+
import glob
|
| 6 |
+
from matplotlib import pyplot as plt
|
| 7 |
+
from multiprocessing import Pool
|
| 8 |
+
from functools import partial
|
| 9 |
+
|
| 10 |
+
def process(idx, img_paths):
|
| 11 |
+
img_path = img_paths[idx]
|
| 12 |
+
mat = io.loadmat(img_path.replace('.jpg','.mat').replace('images','ground_truth').replace('img','GT_img'))
|
| 13 |
+
img = plt.imread(img_path)
|
| 14 |
+
base_range = 5
|
| 15 |
+
off1 = np.zeros((int(img.shape[0]/2),int(img.shape[1]/2),2))
|
| 16 |
+
off2 = np.zeros((int(img.shape[0]/4),int(img.shape[1]/4),2))
|
| 17 |
+
off3 = np.zeros((int(img.shape[0]/8),int(img.shape[1]/8),2))
|
| 18 |
+
ids = np.zeros((int(img.shape[0]/2),int(img.shape[1]/2)), np.int16)
|
| 19 |
+
gt = mat["image_info"][0,0][0,0][0]
|
| 20 |
+
|
| 21 |
+
for i in range(len(gt)):
|
| 22 |
+
for j in range(3):
|
| 23 |
+
h, w = int(img.shape[0]/2**(j+1)), int(img.shape[1]/2**(j+1))
|
| 24 |
+
y, x = int(gt[i][1]/2**(j+1)), int(gt[i][0]/2**(j+1))
|
| 25 |
+
if x < w and y < h:
|
| 26 |
+
if j == 0:
|
| 27 |
+
ids[y,x] = gt[i][2]
|
| 28 |
+
trk_range = int(base_range/(j+1.))
|
| 29 |
+
left = max(0, x - trk_range)
|
| 30 |
+
right = min(w-1, x + trk_range)
|
| 31 |
+
top = max(0, y - trk_range)
|
| 32 |
+
down = min(h-1, y + trk_range)
|
| 33 |
+
for n in range(left,right+1,1):
|
| 34 |
+
for m in range(top,down+1,1):
|
| 35 |
+
if j == 0:
|
| 36 |
+
off1[m,n,0], off1[m,n,1] = y-m, x-n
|
| 37 |
+
elif j == 1:
|
| 38 |
+
off2[m,n,0], off2[m,n,1] = y-m, x-n
|
| 39 |
+
elif j == 2:
|
| 40 |
+
off3[m,n,0], off3[m,n,1] = y-m, x-n
|
| 41 |
+
|
| 42 |
+
with h5py.File(img_path.replace('.jpg','_max.h5').replace('images','ground_truth'), 'w') as hf:
|
| 43 |
+
hf['identity'] = ids
|
| 44 |
+
hf['offset1'] = off1
|
| 45 |
+
hf['offset2'] = off2
|
| 46 |
+
hf['offset3'] = off3
|
| 47 |
+
|
| 48 |
+
print(idx, len(img_paths))
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
part_train = os.path.join('train_data','images')
|
| 52 |
+
part_test = os.path.join('val_data','images')
|
| 53 |
+
|
| 54 |
+
img_paths = []
|
| 55 |
+
for img_path in glob.glob(os.path.join(part_train, '*.jpg')):
|
| 56 |
+
img_paths.append(img_path)
|
| 57 |
+
for img_path in glob.glob(os.path.join(part_test, '*.jpg')):
|
| 58 |
+
img_paths.append(img_path)
|
| 59 |
+
img_paths.sort()
|
| 60 |
+
|
| 61 |
+
pool = Pool(10)
|
| 62 |
+
partial = partial(process, img_paths=img_paths)
|
| 63 |
+
_ = pool.map(partial, range(len(img_paths)))
|
DroneCrowd/saveGT.m
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
clear, clc, close all;
|
| 2 |
+
setName = 'test'; % train set or test set
|
| 3 |
+
seqList = importdata([setName 'list.txt']);
|
| 4 |
+
|
| 5 |
+
for k = 1:length(seqList)
|
| 6 |
+
disp(['processing the ' num2str(k) '-th sequence...']);
|
| 7 |
+
trainID = seqList(k);
|
| 8 |
+
seqName = sprintf('%05d',trainID);
|
| 9 |
+
annoPath = 'annotations\'; % annotation path
|
| 10 |
+
newPath = [setName '_data\'];
|
| 11 |
+
[anno, countNum, label] = xml2mat(annoPath, seqName);
|
| 12 |
+
for i = 1:300
|
| 13 |
+
idx = anno(:,1)==i-1;
|
| 14 |
+
image_info = cell(1);
|
| 15 |
+
number = nnz(idx);
|
| 16 |
+
location = [(anno(idx,3)+anno(idx,5))/2, (anno(idx,4)+anno(idx,6))/2, anno(idx,2)+1];
|
| 17 |
+
image_info{1}.location = location;
|
| 18 |
+
image_info{1}.number = number;
|
| 19 |
+
save([newPath '\ground_truth\GT_' sprintf('img%03d%03d',trainID,i) '.mat'], 'image_info');
|
| 20 |
+
end
|
| 21 |
+
end
|
DroneCrowd/testlist.txt
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
00011
|
| 2 |
+
00015
|
| 3 |
+
00016
|
| 4 |
+
00017
|
| 5 |
+
00018
|
| 6 |
+
00022
|
| 7 |
+
00023
|
| 8 |
+
00024
|
| 9 |
+
00034
|
| 10 |
+
00035
|
| 11 |
+
00042
|
| 12 |
+
00043
|
| 13 |
+
00044
|
| 14 |
+
00061
|
| 15 |
+
00062
|
| 16 |
+
00063
|
| 17 |
+
00065
|
| 18 |
+
00069
|
| 19 |
+
00070
|
| 20 |
+
00074
|
| 21 |
+
00075
|
| 22 |
+
00082
|
| 23 |
+
00088
|
| 24 |
+
00095
|
| 25 |
+
00101
|
| 26 |
+
00103
|
| 27 |
+
00105
|
| 28 |
+
00108
|
| 29 |
+
00111
|
| 30 |
+
00112
|
DroneCrowd/trainlist.txt
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
00001
|
| 2 |
+
00002
|
| 3 |
+
00003
|
| 4 |
+
00004
|
| 5 |
+
00005
|
| 6 |
+
00006
|
| 7 |
+
00007
|
| 8 |
+
00008
|
| 9 |
+
00009
|
| 10 |
+
00010
|
| 11 |
+
00012
|
| 12 |
+
00013
|
| 13 |
+
00014
|
| 14 |
+
00019
|
| 15 |
+
00020
|
| 16 |
+
00021
|
| 17 |
+
00025
|
| 18 |
+
00026
|
| 19 |
+
00027
|
| 20 |
+
00028
|
| 21 |
+
00029
|
| 22 |
+
00030
|
| 23 |
+
00031
|
| 24 |
+
00032
|
| 25 |
+
00033
|
| 26 |
+
00036
|
| 27 |
+
00037
|
| 28 |
+
00038
|
| 29 |
+
00039
|
| 30 |
+
00040
|
| 31 |
+
00041
|
| 32 |
+
00045
|
| 33 |
+
00046
|
| 34 |
+
00047
|
| 35 |
+
00048
|
| 36 |
+
00049
|
| 37 |
+
00050
|
| 38 |
+
00051
|
| 39 |
+
00052
|
| 40 |
+
00053
|
| 41 |
+
00054
|
| 42 |
+
00055
|
| 43 |
+
00056
|
| 44 |
+
00057
|
| 45 |
+
00058
|
| 46 |
+
00059
|
| 47 |
+
00060
|
| 48 |
+
00064
|
| 49 |
+
00066
|
| 50 |
+
00067
|
| 51 |
+
00068
|
| 52 |
+
00071
|
| 53 |
+
00072
|
| 54 |
+
00073
|
| 55 |
+
00076
|
| 56 |
+
00077
|
| 57 |
+
00078
|
| 58 |
+
00079
|
| 59 |
+
00080
|
| 60 |
+
00081
|
| 61 |
+
00083
|
| 62 |
+
00084
|
| 63 |
+
00085
|
| 64 |
+
00086
|
| 65 |
+
00087
|
| 66 |
+
00089
|
| 67 |
+
00090
|
| 68 |
+
00091
|
| 69 |
+
00092
|
| 70 |
+
00093
|
| 71 |
+
00094
|
| 72 |
+
00096
|
| 73 |
+
00097
|
| 74 |
+
00098
|
| 75 |
+
00099
|
| 76 |
+
00100
|
| 77 |
+
00102
|
| 78 |
+
00104
|
| 79 |
+
00106
|
| 80 |
+
00107
|
| 81 |
+
00109
|
| 82 |
+
00110
|
DroneCrowd/xml2mat.m
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function [anno, countNum, label] = xml2mat(annoPath, seqName)
|
| 2 |
+
|
| 3 |
+
matfile = [annoPath seqName '.mat'];
|
| 4 |
+
if(exist(matfile, 'file'))
|
| 5 |
+
load(matfile);
|
| 6 |
+
return;
|
| 7 |
+
end
|
| 8 |
+
|
| 9 |
+
xmlfilename = [annoPath, seqName '.xml'];
|
| 10 |
+
xDoc = xmlread(xmlfilename);
|
| 11 |
+
xRoot = xDoc.getDocumentElement();
|
| 12 |
+
track = xRoot.getElementsByTagName('track');
|
| 13 |
+
count = char(xRoot.getAttribute('count'));
|
| 14 |
+
countNum = str2double(count);
|
| 15 |
+
anno = [];
|
| 16 |
+
for i = 0:countNum-1
|
| 17 |
+
thisItem = track.item(i);
|
| 18 |
+
label = char(thisItem.getAttribute('label'));
|
| 19 |
+
id = str2double(char(thisItem.getAttribute('id')));
|
| 20 |
+
childNode = thisItem.getFirstChild;
|
| 21 |
+
childNode = childNode.getNextSibling;
|
| 22 |
+
while ~isempty(childNode)
|
| 23 |
+
frame = str2double(char(childNode.getAttribute('frame')));
|
| 24 |
+
xtl = str2double(char(childNode.getAttribute('xtl')));
|
| 25 |
+
ytl = str2double(char(childNode.getAttribute('ytl')));
|
| 26 |
+
xbr = str2double(char(childNode.getAttribute('xbr')));
|
| 27 |
+
ybr = str2double(char(childNode.getAttribute('ybr')));
|
| 28 |
+
outside = str2double(char(childNode.getAttribute('outside')));
|
| 29 |
+
occluded = str2double(char(childNode.getAttribute('occluded')));
|
| 30 |
+
if(outside~=1 && occluded~=1)
|
| 31 |
+
anno = cat(1, anno, [frame id xtl ytl xbr ybr]);
|
| 32 |
+
end
|
| 33 |
+
childNode = childNode.getNextSibling;
|
| 34 |
+
childNode = childNode.getNextSibling;
|
| 35 |
+
end % End WHILE
|
| 36 |
+
end
|
| 37 |
+
|
| 38 |
+
save(matfile, 'anno', 'countNum', 'label');
|