mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
repair tabs spaces
This commit is contained in:
@ -85,7 +85,7 @@ YOLODLL_API Detector::Detector(std::string cfg_filename, std::string weight_file
|
|||||||
wait_stream = 0;
|
wait_stream = 0;
|
||||||
int old_gpu_index;
|
int old_gpu_index;
|
||||||
#ifdef GPU
|
#ifdef GPU
|
||||||
check_cuda(cudaGetDevice(&old_gpu_index));
|
check_cuda( cudaGetDevice(&old_gpu_index) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
detector_gpu_ptr = std::make_shared<detector_gpu_t>();
|
detector_gpu_ptr = std::make_shared<detector_gpu_t>();
|
||||||
@ -122,7 +122,7 @@ YOLODLL_API Detector::Detector(std::string cfg_filename, std::string weight_file
|
|||||||
for (j = 0; j < l.classes; ++j) detector_gpu.track_id[j] = 1;
|
for (j = 0; j < l.classes; ++j) detector_gpu.track_id[j] = 1;
|
||||||
|
|
||||||
#ifdef GPU
|
#ifdef GPU
|
||||||
check_cuda(cudaSetDevice(old_gpu_index));
|
check_cuda( cudaSetDevice(old_gpu_index) );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ YOLODLL_API Detector::~Detector()
|
|||||||
|
|
||||||
free(detector_gpu.avg);
|
free(detector_gpu.avg);
|
||||||
for (int j = 0; j < FRAMES; ++j) free(detector_gpu.predictions[j]);
|
for (int j = 0; j < FRAMES; ++j) free(detector_gpu.predictions[j]);
|
||||||
for (int j = 0; j < FRAMES; ++j) if (detector_gpu.images[j].data) free(detector_gpu.images[j].data);
|
for (int j = 0; j < FRAMES; ++j) if(detector_gpu.images[j].data) free(detector_gpu.images[j].data);
|
||||||
|
|
||||||
int old_gpu_index;
|
int old_gpu_index;
|
||||||
#ifdef GPU
|
#ifdef GPU
|
||||||
@ -184,8 +184,8 @@ static image load_image_stb(char *filename, int channels)
|
|||||||
for (k = 0; k < c; ++k) {
|
for (k = 0; k < c; ++k) {
|
||||||
for (j = 0; j < h; ++j) {
|
for (j = 0; j < h; ++j) {
|
||||||
for (i = 0; i < w; ++i) {
|
for (i = 0; i < w; ++i) {
|
||||||
int dst_index = i + w * j + w * h*k;
|
int dst_index = i + w*j + w*h*k;
|
||||||
int src_index = k + c * i + c * w*j;
|
int src_index = k + c*i + c*w*j;
|
||||||
im.data[dst_index] = (float)data[src_index] / 255.;
|
im.data[dst_index] = (float)data[src_index] / 255.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@ YOLODLL_API std::vector<bbox_t> Detector::detect(image_t img, float thresh, bool
|
|||||||
int old_gpu_index;
|
int old_gpu_index;
|
||||||
#ifdef GPU
|
#ifdef GPU
|
||||||
cudaGetDevice(&old_gpu_index);
|
cudaGetDevice(&old_gpu_index);
|
||||||
if (cur_gpu_id != old_gpu_index)
|
if(cur_gpu_id != old_gpu_index)
|
||||||
cudaSetDevice(net.gpu_index);
|
cudaSetDevice(net.gpu_index);
|
||||||
|
|
||||||
net.wait_stream = wait_stream; // 1 - wait CUDA-stream, 0 - not to wait
|
net.wait_stream = wait_stream; // 1 - wait CUDA-stream, 0 - not to wait
|
||||||
@ -291,7 +291,7 @@ YOLODLL_API std::vector<bbox_t> Detector::detect(image_t img, float thresh, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
free_detections(dets, nboxes);
|
free_detections(dets, nboxes);
|
||||||
if (sized.data)
|
if(sized.data)
|
||||||
free(sized.data);
|
free(sized.data);
|
||||||
|
|
||||||
#ifdef GPU
|
#ifdef GPU
|
||||||
@ -327,9 +327,9 @@ YOLODLL_API std::vector<bbox_t> Detector::tracking_id(std::vector<bbox_t> cur_bb
|
|||||||
for (size_t m = 0; m < cur_bbox_vec.size(); ++m) {
|
for (size_t m = 0; m < cur_bbox_vec.size(); ++m) {
|
||||||
bbox_t const& k = cur_bbox_vec[m];
|
bbox_t const& k = cur_bbox_vec[m];
|
||||||
if (i.obj_id == k.obj_id) {
|
if (i.obj_id == k.obj_id) {
|
||||||
float center_x_diff = (float)(i.x + i.w / 2) - (float)(k.x + k.w / 2);
|
float center_x_diff = (float)(i.x + i.w/2) - (float)(k.x + k.w/2);
|
||||||
float center_y_diff = (float)(i.y + i.h / 2) - (float)(k.y + k.h / 2);
|
float center_y_diff = (float)(i.y + i.h/2) - (float)(k.y + k.h/2);
|
||||||
unsigned int cur_dist = sqrt(center_x_diff*center_x_diff + center_y_diff * center_y_diff);
|
unsigned int cur_dist = sqrt(center_x_diff*center_x_diff + center_y_diff*center_y_diff);
|
||||||
if (cur_dist < max_dist && (k.track_id == 0 || dist_vec[m] > cur_dist)) {
|
if (cur_dist < max_dist && (k.track_id == 0 || dist_vec[m] > cur_dist)) {
|
||||||
dist_vec[m] = cur_dist;
|
dist_vec[m] = cur_dist;
|
||||||
cur_index = m;
|
cur_index = m;
|
||||||
@ -340,7 +340,7 @@ YOLODLL_API std::vector<bbox_t> Detector::tracking_id(std::vector<bbox_t> cur_bb
|
|||||||
bool track_id_absent = !std::any_of(cur_bbox_vec.begin(), cur_bbox_vec.end(),
|
bool track_id_absent = !std::any_of(cur_bbox_vec.begin(), cur_bbox_vec.end(),
|
||||||
[&i](bbox_t const& b) { return b.track_id == i.track_id && b.obj_id == i.obj_id; });
|
[&i](bbox_t const& b) { return b.track_id == i.track_id && b.obj_id == i.obj_id; });
|
||||||
|
|
||||||
if (cur_index >= 0 && track_id_absent) {
|
if (cur_index >= 0 && track_id_absent){
|
||||||
cur_bbox_vec[cur_index].track_id = i.track_id;
|
cur_bbox_vec[cur_index].track_id = i.track_id;
|
||||||
cur_bbox_vec[cur_index].w = (cur_bbox_vec[cur_index].w + i.w) / 2;
|
cur_bbox_vec[cur_index].w = (cur_bbox_vec[cur_index].w + i.w) / 2;
|
||||||
cur_bbox_vec[cur_index].h = (cur_bbox_vec[cur_index].h + i.h) / 2;
|
cur_bbox_vec[cur_index].h = (cur_bbox_vec[cur_index].h + i.h) / 2;
|
||||||
|
Reference in New Issue
Block a user